libgocrypfs: OpenSSL as git submodule
This commit is contained in:
parent
4f32853ae5
commit
b221d4cf3c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
/build
|
||||
/include
|
||||
/lib
|
||||
/openssl*
|
||||
|
||||
# temporary files created by the tests
|
||||
/tmp
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "openssl"]
|
||||
path = openssl
|
||||
url = https://github.com/openssl/openssl.git
|
36
build.sh
36
build.sh
@ -1,9 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z ${ANDROID_NDK_HOME+x} ]; then
|
||||
echo "Error: \$ANDROID_NDK_HOME is not defined." >&2
|
||||
exit 1
|
||||
else
|
||||
OPENSSL_PATH="openssl"
|
||||
NDK_BIN_PATH="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||
declare -a ABIs=("x86_64" "x86" "arm64-v8a" "armeabi-v7a")
|
||||
|
||||
@ -23,31 +26,28 @@ else
|
||||
elif [ "$1" = "armeabi-v7a" ]; then
|
||||
OPENSSL_ARCH="android-arm"
|
||||
else
|
||||
invalid_abi $1
|
||||
fi
|
||||
if [ -z ${OPENSSL_PATH+x} ]; then
|
||||
echo "Error: \$OPENSSL_PATH is not defined." >&2
|
||||
exit 1
|
||||
invalid_abi "$1"
|
||||
fi
|
||||
|
||||
export CFLAGS=-D__ANDROID_API__=21
|
||||
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
|
||||
(
|
||||
cd "$OPENSSL_PATH"
|
||||
export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME"
|
||||
if [ -f "Makefile" ]; then
|
||||
make clean
|
||||
fi
|
||||
./Configure $OPENSSL_ARCH -D__ANDROID_API__=21 &&
|
||||
make -j $(nproc --all) build_libs
|
||||
) &&
|
||||
mkdir -p "./lib/$1" "./include/$1" &&
|
||||
cp "$OPENSSL_PATH/libcrypto.a" "$OPENSSL_PATH/libssl.a" "./lib/$1" &&
|
||||
cp -r "$OPENSSL_PATH"/include/* "./include/$1/" || exit 1
|
||||
./Configure $OPENSSL_ARCH -D__ANDROID_API__=21
|
||||
make -j "$(nproc --all)" build_libs
|
||||
)
|
||||
mkdir -p "./lib/$1" "./include/$1"
|
||||
cp "$OPENSSL_PATH/libcrypto.a" "$OPENSSL_PATH/libssl.a" "./lib/$1"
|
||||
cp -r "$OPENSSL_PATH"/include/* "./include/$1/"
|
||||
fi
|
||||
}
|
||||
|
||||
compile_for_arch() {
|
||||
compile_openssl $1
|
||||
compile_openssl "$1"
|
||||
if [ "$1" = "x86_64" ]; then
|
||||
CFN="x86_64-linux-android21-clang"
|
||||
elif [ "$1" = "x86" ]; then
|
||||
@ -62,7 +62,7 @@ else
|
||||
export GOARCH=arm
|
||||
export GOARM=7
|
||||
else
|
||||
invalid_abi $1
|
||||
invalid_abi "$1"
|
||||
fi
|
||||
|
||||
export CC="$NDK_BIN_PATH/$CFN"
|
||||
@ -71,16 +71,16 @@ else
|
||||
export GOOS=android
|
||||
export CGO_CFLAGS="-I ${PWD}/include/$1"
|
||||
export CGO_LDFLAGS="-Wl,-soname=libgocryptfs.so -L${PWD}/lib/$1"
|
||||
go build -o build/$1/libgocryptfs.so -buildmode=c-shared || exit 1
|
||||
go build -o "build/$1/libgocryptfs.so" -buildmode=c-shared
|
||||
}
|
||||
|
||||
cd $(dirname $0) || exit 1
|
||||
cd "$(dirname "$0")"
|
||||
if [ "$#" -eq 1 ]; then
|
||||
compile_for_arch $1
|
||||
compile_for_arch "$1"
|
||||
else
|
||||
for abi in ${ABIs[@]}; do
|
||||
for abi in "${ABIs[@]}"; do
|
||||
echo "Compiling for $abi..."
|
||||
compile_for_arch $abi
|
||||
compile_for_arch "$abi"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module libgocryptfs/v2
|
||||
|
||||
go 1.19
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/aperturerobotics/jacobsa-crypto v1.0.1
|
||||
|
1
openssl
Submodule
1
openssl
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit db2ac4f6ebd8f3d7b2a60882992fbea1269114e2
|
Loading…
Reference in New Issue
Block a user