| OLD | NEW |
| 1 # Copyright 2015 Google Inc. | 1 # Copyright 2015 Google Inc. |
| 2 # | 2 # |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 #!/bin/bash | 6 #!/bin/bash |
| 7 # | 7 # |
| 8 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. | 8 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. |
| 9 | 9 |
| 10 # Fail-fast if anything in the script fails. | 10 # Fail-fast if anything in the script fails. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 if [[ $ANDROID_ARCH == *64* ]]; then | 40 if [[ $ANDROID_ARCH == *64* ]]; then |
| 41 API=21 # Android 5.0 | 41 API=21 # Android 5.0 |
| 42 else | 42 else |
| 43 API=14 # Android 4.0 | 43 API=14 # Android 4.0 |
| 44 fi | 44 fi |
| 45 | 45 |
| 46 TOOLCHAIN=$ANDROID_ARCH-$NDK-$API | 46 TOOLCHAIN=$ANDROID_ARCH-$NDK-$API |
| 47 HOST=`uname | tr '[A-Z]' '[a-z]'` | 47 HOST=`uname | tr '[A-Z]' '[a-z]'` |
| 48 | 48 |
| 49 exportVar ANDROID_TOOLCHAIN "${TOOLCHAINS}/${TOOLCHAIN}/bin" | 49 exportVar ANDROID_TOOLCHAIN "${TOOLCHAINS}/${TOOLCHAIN}" |
| 50 | 50 |
| 51 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | 51 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then |
| 52 mkdir -p $TOOLCHAINS | 52 mkdir -p $TOOLCHAINS |
| 53 pushd $TOOLCHAINS | 53 pushd $TOOLCHAINS |
| 54 curl -o $NDK.zip https://dl.google.com/android/repository/android-ndk-$NDK-$
HOST-x86_64.zip | 54 curl -o $NDK.zip https://dl.google.com/android/repository/android-ndk-$NDK-$
HOST-x86_64.zip |
| 55 unzip $NDK.zip | 55 unzip $NDK.zip |
| 56 UNZIPPED=android-ndk-$NDK | 56 UNZIPPED=android-ndk-$NDK |
| 57 ./$UNZIPPED/build/tools/make-standalone-toolchain.sh \ | 57 ./$UNZIPPED/build/tools/make-standalone-toolchain.sh \ |
| 58 --use-llvm \ | 58 --use-llvm \ |
| 59 --arch=$ANDROID_ARCH \ | 59 --arch=$ANDROID_ARCH \ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 #check to see if the toolchain has been defined and if not setup the default too
lchain | 72 #check to see if the toolchain has been defined and if not setup the default too
lchain |
| 73 if [ -z "$ANDROID_TOOLCHAIN" ]; then | 73 if [ -z "$ANDROID_TOOLCHAIN" ]; then |
| 74 default_toolchain | 74 default_toolchain |
| 75 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then | 75 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then |
| 76 echo "ERROR: unable to download/setup the required toolchain (${ANDROID_TOOL
CHAIN})" | 76 echo "ERROR: unable to download/setup the required toolchain (${ANDROID_TOOL
CHAIN})" |
| 77 return 1; | 77 return 1; |
| 78 fi | 78 fi |
| 79 fi | 79 fi |
| 80 | 80 |
| 81 GCC=$(command ls $ANDROID_TOOLCHAIN/*-gcc | head -n1) | 81 GCC=$(command ls $ANDROID_TOOLCHAIN/bin/*-gcc | head -n1) |
| 82 if [ -z "$GCC" ]; then | 82 if [ -z "$GCC" ]; then |
| 83 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" | 83 echo "ERROR: Could not find Android cross-compiler in: ${ANDROID_TOOLCHAIN}/bi
n" |
| 84 return 1 | 84 return 1 |
| 85 fi | 85 fi |
| 86 | 86 |
| 87 # Remove the '-gcc' at the end to get the full toolchain prefix | 87 # Remove the '-gcc' at the end to get the full toolchain prefix |
| 88 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} | 88 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} |
| 89 | 89 |
| 90 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} | 90 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} |
| 91 | 91 |
| 92 # Cross compiling Android on Mac is not currently supported by gyp. | 92 # Cross compiling Android on Mac is not currently supported by gyp. |
| 93 # It doesn't appear to be supported on Windows either. | 93 # It doesn't appear to be supported on Windows either. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 # Create symlinks for nm & readelf and add them to the path so that the ninja | 143 # Create symlinks for nm & readelf and add them to the path so that the ninja |
| 144 # build uses them instead of attempting to use the one on the system. | 144 # build uses them instead of attempting to use the one on the system. |
| 145 # This is required to build using ninja on a Mac. | 145 # This is required to build using ninja on a Mac. |
| 146 if [ $(uname) == "Darwin" ]; then | 146 if [ $(uname) == "Darwin" ]; then |
| 147 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm | 147 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm |
| 148 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf | 148 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf |
| 149 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as | 149 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as |
| 150 fi | 150 fi |
| 151 | 151 |
| 152 exportVar PATH $ANDROID_TOOLCHAIN:$PATH | 152 exportVar PATH ${ANDROID_TOOLCHAIN}/bin:${PATH} |
| OLD | NEW |