OLD | NEW |
| 1 # Copyright 2015 Google Inc. |
| 2 # |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
1 #!/bin/bash | 6 #!/bin/bash |
2 # | 7 # |
3 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. | 8 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts
. |
4 | 9 |
5 # Fail-fast if anything in the script fails. | 10 # Fail-fast if anything in the script fails. |
6 set -e | 11 set -e |
7 | 12 |
8 # check that the preconditions for this script are met | 13 # check that the preconditions for this script are met |
9 if [ $(type -t verbose) != 'function' ]; then | 14 if [ $(type -t verbose) != 'function' ]; then |
10 echo "ERROR: The verbose function is expected to be defined" | 15 echo "ERROR: The verbose function is expected to be defined" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if [ -z "$GCC" ]; then | 88 if [ -z "$GCC" ]; then |
84 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" | 89 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" |
85 return 1 | 90 return 1 |
86 fi | 91 fi |
87 | 92 |
88 # Remove the '-gcc' at the end to get the full toolchain prefix | 93 # Remove the '-gcc' at the end to get the full toolchain prefix |
89 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} | 94 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} |
90 | 95 |
91 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} | 96 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} |
92 | 97 |
93 if [ -z $USE_CLANG ]; then | 98 # Cross compiling Android on Mac is not currently supported by gyp. |
94 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 99 # It doesn't appear to be supported on Windows either. |
95 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" | 100 # As of now, we will only support cross compiling on Linux. |
96 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 101 # libjpeg-turbo assembly code for x86 and x86-64 Android devices |
| 102 # must be disabled for Android on non-Linux platforms because |
| 103 # of this issue. We still support compiling on Mac and other |
| 104 # variants for local development, but shipping versions of Skia |
| 105 # should be compiled on Linux for performance reasons. |
| 106 # TODO (msarett): Collect more information about this. |
| 107 if [ $(uname) == "Linux" ]; then |
| 108 if [ -z $USE_CLANG ]; then |
| 109 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 110 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" |
| 111 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
| 112 exportVar CC_host "$CCACHE cc" |
| 113 exportVar CXX_host "$CCACHE c++" |
| 114 exportVar LINK_host "$CCACHE cc" |
| 115 else |
| 116 # temporarily disable ccache as it is generating errors |
| 117 CCACHE="" |
| 118 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
| 119 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" |
| 120 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
| 121 exportVar CC_host "$CCACHE clang" |
| 122 exportVar CXX_host "$CCACHE clang++" |
| 123 exportVar LINK_host "$CCACHE clang" |
| 124 fi |
| 125 |
| 126 exportVar AR_target "$ANDROID_TOOLCHAIN_PREFIX-ar" |
| 127 exportVar RANLIB_target "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
| 128 exportVar OBJCOPY_target "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
| 129 exportVar STRIP_target "$ANDROID_TOOLCHAIN_PREFIX-strip" |
| 130 exportVar AR_host "ar" |
| 131 exportVar RANLIB_host "ranlib" |
| 132 exportVar OBJCOPY_host "objcopy" |
| 133 exportVar STRIP_host "strip" |
97 else | 134 else |
98 # temporarily disable ccache as it is generating errors | 135 if [ -z $USE_CLANG ]; then |
99 CCACHE="" | 136 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
100 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 137 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" |
101 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" | 138 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
102 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 139 else |
| 140 # temporarily disable ccache as it is generating errors |
| 141 CCACHE="" |
| 142 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
| 143 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" |
| 144 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
| 145 fi |
| 146 |
| 147 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" |
| 148 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
| 149 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
| 150 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" |
103 fi | 151 fi |
104 | 152 |
105 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" | |
106 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | |
107 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | |
108 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" | |
109 | |
110 # Create symlinks for nm & readelf and add them to the path so that the ninja | 153 # Create symlinks for nm & readelf and add them to the path so that the ninja |
111 # build uses them instead of attempting to use the one on the system. | 154 # build uses them instead of attempting to use the one on the system. |
112 # This is required to build using ninja on a Mac. | 155 # This is required to build using ninja on a Mac. |
113 if [ $(uname) == "Darwin" ]; then | 156 if [ $(uname) == "Darwin" ]; then |
114 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm | 157 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm |
115 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf | 158 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf |
116 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as | 159 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as |
117 fi | 160 fi |
118 | 161 |
119 exportVar PATH $ANDROID_TOOLCHAIN:$PATH | 162 exportVar PATH $ANDROID_TOOLCHAIN:$PATH |
OLD | NEW |