| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright 2012 the V8 project authors. All rights reserved. | 2 # Copyright 2012 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| 11 # disclaimer in the documentation and/or other materials provided | 11 # disclaimer in the documentation and/or other materials provided |
| 12 # with the distribution. | 12 # with the distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived | 14 # contributors may be used to endorse or promote products derived |
| 15 # from this software without specific prior written permission. | 15 # from this software without specific prior written permission. |
| 16 # | 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 if [ ${#@} -lt 4 ] ; then | 29 if [ ${#@} -lt 4 ] ; then |
| 30 echo "Error: $0 needs 4 arguments." | 30 echo "$0: Error: needs 4 arguments." |
| 31 exit 1 | 31 exit 1 |
| 32 fi | 32 fi |
| 33 | 33 |
| 34 ARCH=$1 | 34 ARCH=$1 |
| 35 MODE=$2 | 35 MODE=$2 |
| 36 OUTDIR=$3 | 36 OUTDIR=$3 |
| 37 GYPFLAGS=$4 | 37 GYPFLAGS=$4 |
| 38 | 38 |
| 39 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') | 39 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') |
| 40 | 40 |
| 41 case "${host_os}" in | 41 case "${host_os}" in |
| 42 "linux") | 42 "linux") |
| 43 toolchain_dir="linux-x86" | 43 toolchain_dir="linux-x86" |
| 44 ;; | 44 ;; |
| 45 "mac") |
| 46 toolchain_dir="darwin-x86" |
| 47 ;; |
| 45 *) | 48 *) |
| 46 echo "Host platform ${host_os} is not supported" >& 2 | 49 echo "$0: Host platform ${host_os} is not supported" >& 2 |
| 47 exit 1 | 50 exit 1 |
| 48 esac | 51 esac |
| 49 | 52 |
| 50 case "${ARCH}" in | 53 case "${ARCH}" in |
| 51 "android_arm") | 54 "android_arm") |
| 52 DEFINES=" target_arch=arm v8_target_arch=arm android_target_arch=arm" | 55 DEFINES=" target_arch=arm v8_target_arch=arm android_target_arch=arm" |
| 53 DEFINES+=" arm_neon=0 armv7=1" | 56 DEFINES+=" arm_neon=0 armv7=1" |
| 54 toolchain_arch="arm-linux-androideabi-4.4.3" | 57 toolchain_arch="arm-linux-androideabi-4.4.3" |
| 55 ;; | 58 ;; |
| 56 "android_ia32") | 59 "android_ia32") |
| 57 DEFINES=" target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86" | 60 DEFINES=" target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86" |
| 58 toolchain_arch="x86-4.4.3" | 61 toolchain_arch="x86-4.4.3" |
| 59 ;; | 62 ;; |
| 60 *) | 63 *) |
| 61 echo "Architecture: ${ARCH} is not supported." >& 2 | 64 echo "$0: Target architecture ${ARCH} is not supported." >& 2 |
| 62 echo "Current supported architectures: arm|ia32." >& 2 | 65 echo "$0: Current supported architectures: android_arm|android_ia32." >& 2 |
| 63 exit 1 | 66 exit 1 |
| 64 esac | 67 esac |
| 65 | 68 |
| 66 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/" | 69 toolchain_path="${ANDROID_NDK_ROOT}/toolchains/${toolchain_arch}/prebuilt/" |
| 67 ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin" | 70 ANDROID_TOOLCHAIN="${toolchain_path}/${toolchain_dir}/bin" |
| 68 if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then | 71 if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then |
| 69 echo "Cannot find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 | 72 echo "$0: Cannot find Android toolchain in ${ANDROID_TOOLCHAIN}." >& 2 |
| 70 echo "The NDK version might be wrong." >& 2 | 73 echo "$0: The NDK version might be wrong." >& 2 |
| 71 exit 1 | 74 exit 1 |
| 72 fi | 75 fi |
| 73 | 76 |
| 74 # The set of GYP_DEFINES to pass to gyp. | 77 # For mksnapshot host generation. |
| 78 DEFINES+=" host_os=${host_os}" |
| 79 |
| 80 # The set of GYP_DEFINES to pass to gyp. |
| 75 export GYP_DEFINES="${DEFINES}" | 81 export GYP_DEFINES="${DEFINES}" |
| 76 | 82 |
| 77 export GYP_GENERATORS=make | 83 # Use the "android" flavor of the Makefile generator for both Linux and OS X. |
| 84 export GYP_GENERATORS=make-android |
| 78 export CC=${ANDROID_TOOLCHAIN}/*-gcc | 85 export CC=${ANDROID_TOOLCHAIN}/*-gcc |
| 79 export CXX=${ANDROID_TOOLCHAIN}/*-g++ | 86 export CXX=${ANDROID_TOOLCHAIN}/*-g++ |
| 80 build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \ | 87 build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \ |
| 81 -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \ | 88 -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \ |
| 82 -S.${ARCH} ${GYPFLAGS} | 89 -S.${ARCH} ${GYPFLAGS} |
| 83 | 90 |
| 84 export AR=${ANDROID_TOOLCHAIN}/*-ar | 91 export AR=${ANDROID_TOOLCHAIN}/*-ar |
| 85 export RANLIB=${ANDROID_TOOLCHAIN}/*-ranlib | 92 export RANLIB=${ANDROID_TOOLCHAIN}/*-ranlib |
| 86 export LD=${ANDROID_TOOLCHAIN}/*-ld | 93 export LD=${ANDROID_TOOLCHAIN}/*-ld |
| 87 export LINK=${ANDROID_TOOLCHAIN}/*-g++ | 94 export LINK=${ANDROID_TOOLCHAIN}/*-g++ |
| 88 export BUILDTYPE=${MODE[@]^} | 95 export BUILDTYPE=$(echo ${MODE} | python -c "print raw_input().capitalize()") |
| 89 export builddir=$(readlink -f ${PWD})/${OUTDIR}/${ARCH}.${MODE} | 96 export builddir=${PWD}/${OUTDIR}/${ARCH}.${MODE} |
| 90 make -C "${OUTDIR}" -f Makefile.${ARCH} | 97 make -C "${OUTDIR}" -f Makefile.${ARCH} |
| OLD | NEW |