Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 231 lines (194 sloc) 5.387 kb
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
1 #!/bin/sh
2 #
3 # Appcelerator Titanium Mobile
4 # Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
5 # Licensed under the terms of the Apache Public License
6 # Please see the LICENSE included with this distribution for details.
7 #
8 # Build and bundling script for v8 / NDK toolchain
9
10 usage()
11 {
12 cat <<EOF
13 Usage: $0 options
14
fb2475e @marshall quoted more paths, and exit the build script if scons fails. added LI…
marshall authored
15 This script builds v8 against the Android NDK.
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
16 Options:
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
17 -h Show this help message and exit
18 -n <ndk_dir> The path to the Android NDK. Alternatively, you may set the ANDROID_NDK environment variable
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
19 -j <num-cpus> The number of processors to use in building (passed on to make)
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
20 -m <mode> The v8 build mode (release, debug, all. default: release)
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
21 -l <lib-version> Architectures to build for (armeabi, armeabi-v7a, x86, all. default: armeabi-v7a)
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
22 -t Package a thirdparty tarball for uploading (don't build)
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
23 -s Enable V8 snapshot. Improves performance, but takes longer to compile. (default: off)
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
24 -c Clean the V8 build
29b6a98 @sptramer [TIMOB-9170] Add -p to USAGE
sptramer authored
25 -p The Android SDK version to support (android-8, android-9, etc.)
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
26 EOF
27 }
28
29 NUM_CPUS=1
30 MODE=release
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
31 LIB_VERSION=armeabi-v7a
32 THIRDPARTY=0
33 CLEAN=0
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
34 USE_V8_SNAPSHOT=0
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
35 PLATFORM_VERSION=android-8
36
37 while getopts "htscn:j:m:l:p:" OPTION; do
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
38 case $OPTION in
39 h)
40 usage
41 exit
42 ;;
43 n)
44 NDK_DIR=$OPTARG
45 ;;
46 m)
47 MODE=$OPTARG
48 ;;
49 j)
50 NUM_CPUS=$OPTARG
51 ;;
52 t)
53 THIRDPARTY=1
54 ;;
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
55 s)
56 USE_V8_SNAPSHOT=1
57 ;;
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
58 l)
59 LIB_VERSION=$OPTARG
60 ;;
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
61 c)
62 CLEAN=1
63 ;;
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
64 p)
65 PLATFORM_VERSION=$OPTARG
66 ;;
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
67 ?)
68 usage
69 exit
70 ;;
71 esac
72 done
73
74 if [ "$NDK_DIR" = "" ]; then
75 NDK_DIR=$ANDROID_NDK
76 fi
77
78 if [ "$NDK_DIR" = "" ]; then
79 echo "Error: No Android NDK directory was specified, supply '-n </path/to/ndk>' or set ANDROID_NDK"
80 usage
81 exit 1
82 fi
83
84 echo "Building against Android NDK: $NDK_DIR"
85
86 THIS_DIR=$(cd "$(dirname "$0")"; pwd)
87 BUILD_DIR=$THIS_DIR/build
88
89 if [ ! -d "$BUILD_DIR" ]; then
fb2475e @marshall quoted more paths, and exit the build script if scons fails. added LI…
marshall authored
90 mkdir "$BUILD_DIR"
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
91 fi
92
93 V8_DIR=$THIS_DIR/v8
94 TOOLCHAIN_DIR=$BUILD_DIR/ndk_toolchain
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
95
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
96
97 buildToolchain()
98 {
99 # remove the previous toolchain
fb2475e @marshall quoted more paths, and exit the build script if scons fails. added LI…
marshall authored
100 rm -rf "$TOOLCHAIN_DIR"
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
101
102 # create stand alone toolchain
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
103 "$NDK_DIR/build/tools/make-standalone-toolchain.sh" --platform=$PLATFORM_VERSION --ndk-dir="$NDK_DIR" --install-dir="$TOOLCHAIN_DIR" --arch="$ARCH"
2c7fc3f @sptramer [TIMOB-9170] Enable x86 snapshot and improve error handling
sptramer authored
104 if [ $? -ne 0 ]; then
105 exit 1
106 fi
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
107
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
108 # Copy the sources from NDK which the V8 build expects
109 # to be located in the NDK toolchain directory.
110 echo "Copying NDK sources..."
111 rm $TOOLCHAIN_DIR/SOURCES
112 cp -R $NDK_DIR/sources $TOOLCHAIN_DIR/
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
113 }
114
115 buildV8()
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
116 {
117 BUILD_MODE=$1
118 BUILD_LIB_VERSION=$2
119
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
120 # Build for ARM v7 if requested, otherwise target v5.
121 ARMV7="false"
122 if [ "$BUILD_LIB_VERSION" = "armeabi-v7a" ]; then
123 ARMV7="true"
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
124 fi
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
125
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
126 echo "Building V8 mode: $BUILD_MODE, lib: $BUILD_LIB_VERSION, arch: $ARCH, armv7: $ARMV7"
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
127
fb2475e @marshall quoted more paths, and exit the build script if scons fails. added LI…
marshall authored
128 cd "$V8_DIR"
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
129
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
130 # Setup for building V8.
131 make dependencies
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
132
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
133 # Disable snapshots if requested.
134 SNAPSHOT="on"
135 if [ $USE_V8_SNAPSHOT = 0 ]; then
136 SNAPSHOT="off"
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
137 fi
138
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
139 # Build V8
286f3b8 @ingo Reworked build targets
ingo authored
140 MAKE_TARGET="$BUILD_ARCH.$BUILD_MODE"
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
141 ANDROID_TOOLCHAIN=$TOOLCHAIN_DIR \
9b49f68 @ingo Removed debugging info from make
ingo authored
142 make -j$NUM_CPUS $MAKE_TARGET snapshot=$SNAPSHOT armv7=$ARMV7
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
143
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
144 # Copy the static library to our staging area.
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
145 DEST_DIR="$BUILD_DIR/$BUILD_MODE"
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
146 mkdir -p "$DEST_DIR/libs/$BUILD_LIB_VERSION" 2>/dev/null || echo
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
147 cp -R "$V8_DIR/out/$MAKE_TARGET/obj.target/tools/gyp/." \
148 "$DEST_DIR/libs/$BUILD_LIB_VERSION/"
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
149 }
150
151 buildThirdparty()
152 {
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
153 BUILD_MODE=$1
154
155 # Copied from v8/tools/push-to-trunk.sh
156 VERSION_FILE=$V8_DIR/src/version.cc
157 MAJOR=$(grep "#define MAJOR_VERSION" "$VERSION_FILE" | awk '{print $NF}')
158 MINOR=$(grep "#define MINOR_VERSION" "$VERSION_FILE" | awk '{print $NF}')
159 BUILD=$(grep "#define BUILD_NUMBER" "$VERSION_FILE" | awk '{print $NF}')
160
161 cd "$V8_DIR"
162 V8_VERSION="$MAJOR.$MINOR.$BUILD"
163 V8_GIT_REVISION=$(git rev-parse HEAD)
164 V8_GIT_BRANCH=$(git status -s -b | grep \#\# | sed 's/\#\# //')
165 V8_SVN_REVISION=$(git log -n 1 | grep git-svn-id | perl -ne 's/\s+git-svn-id: [^@]+@([^\s]+) .+/\1/; print')
166
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
167 DEST_DIR="$BUILD_DIR/$BUILD_MODE"
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
168 DATE=$(date '+%Y-%m-%d %H:%M:%S')
be96e38 @joshthecoder Upgrade V8 to latest 3.9. Enable snapshot builds.
joshthecoder authored
169
170 cat <<EOF > "$DEST_DIR/libv8.json"
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
171 {
172 "version": "$V8_VERSION",
173 "git_revision": "$V8_GIT_REVISION",
174 "git_branch": "$V8_GIT_BRANCH",
175 "svn_revision": "$V8_SVN_REVISION",
176 "timestamp": "$DATE"
177 }
178 EOF
179
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
180 mkdir -p "$DEST_DIR/libs" "$DEST_DIR/include" 2>/dev/null
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
181 cp -R "$V8_DIR/include" "$DEST_DIR"
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
182
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
183 cd "$DEST_DIR"
184 echo "Building libv8-$V8_VERSION-$BUILD_MODE.tar.bz2..."
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
185 tar -cvj -f libv8-$V8_VERSION-$BUILD_MODE.tar.bz2 libv8.json libs include
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
186 }
187
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
188 if [ "$CLEAN" = "1" ]; then
0d542ed @joshthecoder Switch to using GYP build system.
joshthecoder authored
189 cd v8 && make clean
f67b17b @marshall update libv8 packaging to use android naming conventions
marshall authored
190 exit;
191 fi
192
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
193 if [ "$LIB_VERSION" = "all" ]; then
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
194 LIB_VERSION="armeabi armeabi-v7a x86"
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
195 fi
196
197 if [ "$MODE" = "all" ]; then
198 MODE="release debug"
199 fi
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
200
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
201 if [ "$THIRDPARTY" = "0" ]; then
202 for build_lib_version in $LIB_VERSION; do
d7d22cc @sptramer [TIMOB-9170] Support for building v8 for Android x86. Updated v8 to l…
sptramer authored
203 # Switch between arm and x86/ia32 arch
204 echo $build_lib_version | grep '^arm' 1>/dev/null 2>/dev/null
205 IS_ARM=$?
206
207 if [ $IS_ARM -eq 0 ]; then
208 ARCH='arm'
209 BUILD_ARCH='arm'
210 else
211 REV=`echo ${PLATFORM_VERSION} | sed s/android-//`
212 if [ $REV -lt 9 ]; then
213 echo "Cannot build x86 with android rev lower than SDK 9; use -p option to specify a different SDK"
214 exit 1
215 fi;
216 ARCH='x86'
217 BUILD_ARCH='ia32'
218 fi
219
220 buildToolchain
221
5e921ac @marshall build emulator (armeabi=soft) and device (armeabi=softfp) versions of
marshall authored
222 for build_mode in $MODE; do
223 buildV8 $build_mode $build_lib_version
224 done
225 done
226 else
227 for build_mode in $MODE; do
228 buildThirdparty $build_mode
229 done
c8b09b2 @marshall added a build script for building v8 against our patch / the NDK, and…
marshall authored
230 fi
Something went wrong with that request. Please try again.