OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. | 3 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. |
4 | 4 |
5 # Fail-fast if anything in the script fails. | 5 # Fail-fast if anything in the script fails. |
6 set -e | 6 set -e |
7 | 7 |
8 # check that the preconditions for this script are met | 8 # check that the preconditions for this script are met |
9 if [ $(type -t verbose) != 'function' ]; then | 9 if [ $(type -t verbose) != 'function' ]; then |
10 echo "ERROR: The verbose function is expected to be defined" | 10 echo "ERROR: The verbose function is expected to be defined" |
11 return 1 | 11 return 1 |
12 fi | 12 fi |
13 | 13 |
14 if [ $(type -t exportVar) != 'function' ]; then | 14 if [ $(type -t exportVar) != 'function' ]; then |
15 echo "ERROR: The exportVar function is expected to be defined" | 15 echo "ERROR: The exportVar function is expected to be defined" |
16 return 1 | 16 return 1 |
17 fi | 17 fi |
18 | 18 |
19 if [ $(type -t absPath) != 'function' ]; then | 19 if [ $(type -t absPath) != 'function' ]; then |
20 echo "ERROR: The absPath function is expected to be defined" | 20 echo "ERROR: The absPath function is expected to be defined" |
21 return 1 | 21 return 1 |
22 fi | 22 fi |
23 | 23 |
24 if [ -z "$SCRIPT_DIR" ]; then | 24 if [ -z "$SCRIPT_DIR" ]; then |
25 echo "ERROR: The SCRIPT_DIR variable is expected to be defined" | 25 echo "ERROR: The SCRIPT_DIR variable is expected to be defined" |
26 return 1 | 26 return 1 |
27 fi | 27 fi |
28 | 28 |
29 function default_toolchain() { | 29 function default_toolchain() { |
30 API_LEVEL=14 | 30 NDK_REV=${NDK_REV-10exp} |
31 NDK_REV=${NDK_REV-8e} | |
32 ANDROID_ARCH=${ANDROID_ARCH-arm} | 31 ANDROID_ARCH=${ANDROID_ARCH-arm} |
| 32 |
| 33 if [[ $ANDROID_ARCH == *64* ]]; then |
| 34 API_LEVEL=L # Experimental Android L-Release system images |
| 35 else |
| 36 API_LEVEL=14 # Official Android 4.0 system images |
| 37 fi |
33 | 38 |
34 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains | 39 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains |
35 if [ $(uname) == "Darwin" ]; then | 40 if [ $(uname) == "Darwin" ]; then |
36 verbose "Using Mac toolchain." | 41 verbose "Using Mac toolchain." |
37 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL | 42 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-mac_v$API_LEVEL |
38 else | 43 else |
39 verbose "Using Linux toolchain." | 44 verbose "Using Linux toolchain." |
40 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL | 45 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL |
41 fi | 46 fi |
42 exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin" | 47 exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | 92 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
88 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | 93 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
89 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" | 94 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" |
90 | 95 |
91 # Create symlinks for nm & readelf and add them to the path so that the ninja | 96 # Create symlinks for nm & readelf and add them to the path so that the ninja |
92 # build uses them instead of attempting to use the one on the system. | 97 # build uses them instead of attempting to use the one on the system. |
93 # This is required to build using ninja on a Mac. | 98 # This is required to build using ninja on a Mac. |
94 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm | 99 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm |
95 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf | 100 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf |
96 exportVar PATH $ANDROID_TOOLCHAIN:$PATH | 101 exportVar PATH $ANDROID_TOOLCHAIN:$PATH |
OLD | NEW |