|
7 | 7 | SODIUM_VERSION="1.0.21.0"
|
8 | 8 |
|
9 | 9 | if [ -z "$ANDROID_NDK_HOME" ]; then
|
10 |
| - echo "You should probably set ANDROID_NDK_HOME to the directory containing" |
11 |
| - echo "the Android NDK." |
| 10 | + echo "ANDROID_NDK_HOME must be set to the directory containing the Android NDK." |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +if [ ! -f "${ANDROID_NDK_HOME}/ndk-build" ]; then |
| 15 | + echo "The ANDROID_NDK_HOME directory does not contain an 'ndk-build' file." |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +if [ ! -d "${ANDROID_NDK_HOME}/toolchains" ]; then |
| 20 | + echo "The ANDROID_NDK_HOME directory does not contain a 'toolchains' directory." |
12 | 21 | exit 1
|
13 | 22 | fi
|
14 | 23 |
|
15 | 24 | if [ ! -f "${ANDROID_NDK_HOME}/source.properties" ]; then
|
16 |
| - sp=$(find "${ANDROID_NDK_HOME}" -depth 2 -type f -name source.properties | head -n1) |
17 |
| - if [ -n "$sp" ]; then |
18 |
| - export ANDROID_NDK_HOME=$(dirname "$sp") |
19 |
| - else |
20 |
| - echo "The ANDROID_NDK_HOME directory does not contain a 'source.properties' file." |
21 |
| - exit 1 |
22 |
| - fi |
| 25 | + echo "The ANDROID_NDK_HOME directory does not contain a 'source.properties' file." |
| 26 | + exit 1 |
23 | 27 | fi
|
24 | 28 |
|
25 | 29 | NDK_VERSION=$(grep "Pkg.Revision = " <"${ANDROID_NDK_HOME}/source.properties" | cut -f 2 -d '=' | cut -f 2 -d' ' | cut -f 1 -d'.')
|
26 | 30 | DEST_PATH=$(mktemp -d)
|
27 | 31 |
|
28 | 32 | if [ -z "$NDK_PLATFORM" ]; then
|
29 | 33 | export NDK_PLATFORM="android-21"
|
30 |
| - echo "Compiling for default platform: [${NDK_PLATFORM}] - That can be changed by setting an NDK_PLATFORM environment variable." |
| 34 | + echo "Compiling for default platform: [${NDK_PLATFORM}]" |
| 35 | + echo "That can be changed by setting an NDK_PLATFORM environment variable." |
31 | 36 | fi
|
32 | 37 |
|
33 | 38 | SDK_VERSION=$(echo "$NDK_PLATFORM" | cut -f2 -d"-")
|
| 39 | +if [ -z "$NDK_VERSION" ]; then |
| 40 | + echo "Failed to determine the NDK version." |
| 41 | + exit 1 |
| 42 | +fi |
| 43 | +if [ -z "$SDK_VERSION" ]; then |
| 44 | + echo "Failed to determine the SDK version." |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | +echo "NDK version: [$NDK_VERSION]" |
| 48 | +echo "SDK version: [$SDK_VERSION]" |
| 49 | + |
| 50 | +echo |
34 | 51 |
|
35 | 52 | if which zip >/dev/null; then
|
36 | 53 | echo "The 'zip' command is installed."
|
|
41 | 58 |
|
42 | 59 | cd "$(dirname "$0")/../" || exit
|
43 | 60 |
|
| 61 | +trap 'kill -TERM -$$' INT |
| 62 | + |
44 | 63 | make_abi_json() {
|
45 | 64 | echo "{\"abi\":\"${NDK_ARCH}\",\"api\":${SDK_VERSION},\"ndk\":${NDK_VERSION},\"stl\":\"none\"}" >"$1/abi.json"
|
46 | 65 | }
|
@@ -134,7 +153,9 @@ zip -9 -r "$AAR_PATH" META-INF prefab AndroidManifest.xml
|
134 | 153 | cd .. || exit
|
135 | 154 | rm -r "$DEST_PATH"
|
136 | 155 |
|
137 |
| -echo "Congrats you have built an AAR containing libsodium! |
| 156 | +echo " |
| 157 | +
|
| 158 | +Congrats you have built an AAR containing libsodium! |
138 | 159 | The build used a min Android SDK of version $SDK_VERSION
|
139 | 160 | You can build for a different SDK version by specifying NDK_PLATFORM=\"android-{SDK_VERSION}\"
|
140 | 161 | as an environment variable before running this script but the defaults should be fine.
|
@@ -168,4 +189,6 @@ gradle or cmake (as set by default for Android Studio projects):
|
168 | 189 | - 'sodium' for the full shared library,
|
169 | 190 | - 'sodium-static' for the full static library
|
170 | 191 | - 'sodium-minimal' for the minimal shared library, or
|
171 |
| - - 'sodium-minimal-static' for the minimal static library." |
| 192 | + - 'sodium-minimal-static' for the minimal static library. |
| 193 | +
|
| 194 | + " |
0 commit comments