-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathandroid.sh
More file actions
executable file
·100 lines (89 loc) · 3.62 KB
/
Copy pathandroid.sh
File metadata and controls
executable file
·100 lines (89 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
set -e
# Ensure ANDROID_NDK_ROOT is set
if [ -z "$ANDROID_NDK_ROOT" ]; then
echo "Please set ANDROID_NDK_ROOT environment variable."
exit 1
fi
# Create deps directory if it doesn't exist
mkdir -p deps-android
# 1. Build GoogleTest
echo "Building Benchmark for Android..."
if [ ! -d "googletest" ]; then
echo "Cloning googletest repository..."
git clone --depth 1 https://github.com/google/googletest.git
fi
echo "Building GoogleTest for Android..."
cd googletest
rm -rf build-android
cmake -B build-android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_INSTALL_PREFIX=$PWD/../deps-android \
-DBUILD_GTEST=ON \
-DBUILD_GMOCK=ON \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-android --target install --parallel 8
cd ..
# 2. Build Benchmark
echo "Building Benchmark for Android..."
if [ ! -d "benchmark" ]; then
echo "Cloning benchmark repository..."
git clone --depth 1 https://github.com/google/benchmark.git
fi
cd benchmark
rm -rf build-android
cmake -B build-android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_INSTALL_PREFIX=$PWD/../deps-android \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-android --target install --parallel 8
cd ..
# 2.5 Build zstd
echo "Building zstd for Android..."
if [ ! -d "zstd" ]; then
echo "Cloning zstd repository..."
git clone --depth 1 https://github.com/facebook/zstd.git
fi
cd zstd
rm -rf build-android
cmake -B build-android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_INSTALL_PREFIX=$PWD/../deps-android \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-android --target install --parallel 8
cd ..
# 2.8 Build openssl
echo "Building openssl for Android..."
if [ ! -d "openssl" ]; then
echo "Cloning openssl"
git clone --depth 1 https://github.com/openssl/openssl.git
fi
cd openssl
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin:$PATH
CFLAGS=-Wno-macro-redefined ./Configure android-arm64 -D__ANDROID_API__=29 --prefix=$PWD/../deps-android \
no-autoalginit no-autoerrinit no-tls no-dtls no-legacy no-apps no-docs no-autoload-config no-quic \
no-zlib no-http no-threads no-mdc2 no-ui-console no-winstore \
no-idea no-cast no-poly1305 no-siphash no-cmac no-chacha no-cmp no-cms no-comp no-blake2 no-gost no-whirlpool no-camellia no-rc2 no-rc4 no-md4 no-ml-dsa no-ml-kem no-argon2 no-aria no-dsa no-scrypt no-slh-dsa no-sm2 no-sm3 no-sm4 no-sock no-srp no-siphash no-srtp no-siphash no-ssl-trace no-unstable-qlog no-uplink no-dso no-multiblock no-tls1_1 no-tls1_2
make -j 12 install
cd ..
# Remove shared libraries from deps to force static linking
echo "Removing shared libraries from deps to force static linking..."
rm -f deps-android/lib/*.so
# 3. Build Main Project Tests
echo "Building Main Project Tests for Android..."
rm -rf build-android-arm64
cmake -S lib -B build-android-arm64 \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=$PWD/deps-android
cmake --build build-android-arm64 --config Release --parallel 8