Skip to content

Commit 20400fa

Browse files
committed
Allow caller to specify which ABI to build for libsecp256k1
1 parent f173e63 commit 20400fa

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Build secp256k1.
2222
``` bash
2323
# Android
2424
$ ./tools/build_android.sh
25+
# Alternatively you can specify the ABI to build:
26+
$ ARCHS=arm64-v8a ./tools/build_android.sh
27+
# all, armeabi-v7a, arm64-v8a, x86 or x86_64 are supported
2528

2629
# iOS
2730
$ PLATFORM_NAME=iphoneos CONFIGURATION=debug ARCHS=arm64 ./tools/build_ios.sh

tools/build_android.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
#!/bin/bash
22

3-
set -e
4-
53
if [ -z "$ANDROID_NDK" ]; then
64
echo "export the ANDROID_NDK environment variable"
75
exit 1
86
fi
97

8+
# Allow the caller to specify which build to run
9+
abiToBuild="all"
10+
if [ -n "$ARCHS" ]; then
11+
abiRegex="^(all|armeabi-v7a|arm64-v8a|x86|x86_64)$"
12+
[[ $ARCHS =~ $abiRegex ]]
13+
14+
if [[ $? == 0 ]]; then
15+
abiToBuild="$ARCHS"
16+
echo "manually selected ABI: $abiToBuild"
17+
else
18+
echo "invalid ARCHS environment variable, the following are accepted: all, armeabi-v7a, arm64-v8a, x86 or x86_64"
19+
exit 1
20+
fi
21+
fi
22+
23+
# Ensure all commands after this point exit upon erroring
24+
set -e
25+
1026
# Get the location of the android NDK build tools to build with
1127
asm=""
1228
if [ "$(uname)" == "Darwin" ]; then
@@ -66,10 +82,18 @@ build()
6682
make install
6783
}
6884

69-
build armeabi-v7a armv7a-linux-androideabi
70-
build arm64-v8a aarch64-linux-android
71-
build x86 i686-linux-android
72-
build x86_64 x86_64-linux-android
85+
if [[ $abiToBuild == "all" ]] || [[ $abiToBuild == "armeabi-v7a" ]]; then
86+
build armeabi-v7a armv7a-linux-androideabi
87+
fi
88+
if [[ $abiToBuild == "all" ]] || [[ $abiToBuild == "arm64-v8a" ]]; then
89+
build arm64-v8a aarch64-linux-android
90+
fi
91+
if [[ $abiToBuild == "all" ]] || [[ $abiToBuild == "x86" ]]; then
92+
build x86 i686-linux-android
93+
fi
94+
if [[ $abiToBuild == "all" ]] || [[ $abiToBuild == "x86_64" ]]; then
95+
build x86_64 x86_64-linux-android
96+
fi
7397

7498
make clean
7599

0 commit comments

Comments
 (0)