Skip to content

Commit 1d3e95a

Browse files
authored
Merge pull request #3 from PeteClubSeven/feature/secp256-script-improvements
Fix 64-bit Android ABIs & allow manual ABI selection
2 parents 38c913d + 20400fa commit 1d3e95a

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

README.md

+3
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

contrib/bitcoin-core/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ add_library(${PROJECT_NAME} STATIC
8989
if (NOT ${USE_EXTERNAL_SECP256K1})
9090
if (ANDROID)
9191
add_library(libsecp256k1 STATIC IMPORTED)
92-
set_target_properties(libsecp256k1 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/src/secp256k1/build/android/${ANDROID_ABI}/lib/libsecp256k1.a)
92+
93+
# Ensure we use the lib folder for 32-bit and lib64 folder for 64-bit
94+
if (${CMAKE_ANDROID_ARCH} MATCHES "^(arm|mips|x86)$")
95+
set_target_properties(libsecp256k1 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/src/secp256k1/build/android/${ANDROID_ABI}/lib/libsecp256k1.a)
96+
else()
97+
set_target_properties(libsecp256k1 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/src/secp256k1/build/android/${ANDROID_ABI}/lib64/libsecp256k1.a)
98+
endif()
99+
93100
set_target_properties(libsecp256k1 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/src/secp256k1/include)
94101
elseif(IOS)
95102
add_library(libsecp256k1 STATIC IMPORTED)

tools/build_android.sh

+30-6
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)