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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
94 # As of now, we will only support cross compiling on Linux. | 94 # As of now, we will only support cross compiling on Linux. |
95 # libjpeg-turbo assembly code for x86 and x86-64 Android devices | 95 # libjpeg-turbo assembly code for x86 and x86-64 Android devices |
96 # must be disabled for Android on non-Linux platforms because | 96 # must be disabled for Android on non-Linux platforms because |
97 # of this issue. We still support compiling on Mac and other | 97 # of this issue. We still support compiling on Mac and other |
98 # variants for local development, but shipping versions of Skia | 98 # variants for local development, but shipping versions of Skia |
99 # should be compiled on Linux for performance reasons. | 99 # should be compiled on Linux for performance reasons. |
100 # TODO (msarett): Collect more information about this. | 100 # TODO (msarett): Collect more information about this. |
101 if [ $(uname) == "Linux" ]; then | 101 if [ $(uname) == "Linux" ]; then |
102 if [ -z $USE_CLANG ]; then | 102 if [ "$USE_CLANG" != "true" ]; then |
103 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 103 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
104 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" | 104 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" |
105 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 105 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
106 exportVar CC_host "$CCACHE cc" | 106 exportVar CC_host "$CCACHE cc" |
107 exportVar CXX_host "$CCACHE c++" | 107 exportVar CXX_host "$CCACHE c++" |
108 exportVar LINK_host "$CCACHE cc" | 108 exportVar LINK_host "$CCACHE cc" |
109 else | 109 else |
110 # temporarily disable ccache as it is generating errors | |
111 CCACHE="" | |
112 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 110 exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
113 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" | 111 exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" |
114 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 112 exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
115 exportVar CC_host "$CCACHE clang" | 113 exportVar CC_host "$CCACHE clang" |
116 exportVar CXX_host "$CCACHE clang++" | 114 exportVar CXX_host "$CCACHE clang++" |
117 exportVar LINK_host "$CCACHE clang" | 115 exportVar LINK_host "$CCACHE clang" |
118 fi | 116 fi |
119 | 117 |
120 exportVar AR_target "$ANDROID_TOOLCHAIN_PREFIX-ar" | 118 exportVar AR_target "$ANDROID_TOOLCHAIN_PREFIX-ar" |
121 exportVar RANLIB_target "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | 119 exportVar RANLIB_target "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
122 exportVar OBJCOPY_target "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | 120 exportVar OBJCOPY_target "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
123 exportVar STRIP_target "$ANDROID_TOOLCHAIN_PREFIX-strip" | 121 exportVar STRIP_target "$ANDROID_TOOLCHAIN_PREFIX-strip" |
124 exportVar AR_host "ar" | 122 exportVar AR_host "ar" |
125 exportVar RANLIB_host "ranlib" | 123 exportVar RANLIB_host "ranlib" |
126 exportVar OBJCOPY_host "objcopy" | 124 exportVar OBJCOPY_host "objcopy" |
127 exportVar STRIP_host "strip" | 125 exportVar STRIP_host "strip" |
128 else | 126 else |
129 if [ -z $USE_CLANG ]; then | 127 if [ "$USE_CLANG" != "true" ]; then |
130 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 128 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
131 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" | 129 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" |
132 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" | 130 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" |
133 else | 131 else |
134 # temporarily disable ccache as it is generating errors | |
135 CCACHE="" | |
136 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 132 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
137 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" | 133 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" |
138 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" | 134 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" |
139 fi | 135 fi |
140 | 136 |
141 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" | 137 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" |
142 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" | 138 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" |
143 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" | 139 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" |
144 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" | 140 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" |
145 fi | 141 fi |
146 | 142 |
147 # 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 |
148 # 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. |
149 # This is required to build using ninja on a Mac. | 145 # This is required to build using ninja on a Mac. |
150 if [ $(uname) == "Darwin" ]; then | 146 if [ $(uname) == "Darwin" ]; then |
151 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm | 147 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm |
152 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf | 148 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf |
153 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as | 149 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as |
154 fi | 150 fi |
155 | 151 |
| 152 # fix bug in the toolchain in order to enable ccache to work with clang |
| 153 if [ $(head -c 2 $ANDROID_TOOLCHAIN_PREFIX-clang) != "#!" ]; then |
| 154 echo -e "#!/bin/bash\n$(cat $ANDROID_TOOLCHAIN_PREFIX-clang)" > $ANDROID_TOOL
CHAIN_PREFIX-clang |
| 155 fi |
| 156 if [ $(head -c 2 $ANDROID_TOOLCHAIN_PREFIX-clang++) != "#!" ]; then |
| 157 echo -e "#!/bin/bash\n$(cat $ANDROID_TOOLCHAIN_PREFIX-clang++)" > $ANDROID_TO
OLCHAIN_PREFIX-clang++ |
| 158 fi |
| 159 |
156 exportVar PATH $ANDROID_TOOLCHAIN:$PATH | 160 exportVar PATH $ANDROID_TOOLCHAIN:$PATH |
OLD | NEW |