From c8b09b2f2ad897803a1cf2d074f31ba259f49638 Mon Sep 17 00:00:00 2001 From: marshall Date: Sat, 10 Sep 2011 16:24:47 -0500 Subject: [PATCH] added a build script for building v8 against our patch / the NDK, and bundling into a tarball for use by titanium_mobile. created a script for reversing our patch, and updating v8 to the latest on trunk --- .gitignore | 1 + build_v8.sh | 144 +++++++++++++++++++++++++++++++++++++++++++ patches/ndk_v8.patch | 26 ++++++++ update_v8.sh | 16 +++++ 4 files changed, 187 insertions(+) create mode 100644 .gitignore create mode 100755 build_v8.sh create mode 100644 patches/ndk_v8.patch create mode 100755 update_v8.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/build_v8.sh b/build_v8.sh new file mode 100755 index 0000000..6345aba --- /dev/null +++ b/build_v8.sh @@ -0,0 +1,144 @@ +#!/bin/sh +# +# Appcelerator Titanium Mobile +# Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved. +# Licensed under the terms of the Apache Public License +# Please see the LICENSE included with this distribution for details. +# +# Build and bundling script for v8 / NDK toolchain + +# set this to the where the NDK is installed + +usage() +{ +cat < The path to the Android NDK. Alternatively, you may set the ANDROID_NDK environment variable + -j The number of processors to use in building (passed on to scons) + -m The v8 build mode (release, debug. default: release) + -t Build a thirdparty tarball for uploading +EOF +} + +NUM_CPUS=1 +MODE=release +while getopts "htn:j:m:" OPTION; do + case $OPTION in + h) + usage + exit + ;; + n) + NDK_DIR=$OPTARG + ;; + m) + MODE=$OPTARG + ;; + j) + NUM_CPUS=$OPTARG + ;; + t) + THIRDPARTY=1 + ;; + ?) + usage + exit + ;; + esac +done + +if [ "$NDK_DIR" = "" ]; then + NDK_DIR=$ANDROID_NDK +fi + +if [ "$NDK_DIR" = "" ]; then + echo "Error: No Android NDK directory was specified, supply '-n ' or set ANDROID_NDK" + usage + exit 1 +fi + +echo "Building against Android NDK: $NDK_DIR" + +THIS_DIR=$(cd "$(dirname "$0")"; pwd) +BUILD_DIR=$THIS_DIR/build + +if [ ! -d "$BUILD_DIR" ]; then + mkdir $BUILD_DIR +fi + +V8_DIR=$THIS_DIR/v8 +TOOLCHAIN_DIR=$BUILD_DIR/ndk_toolchain +PLATFORM_VERSION=android-8 + +buildToolchain() +{ + # remove the previous toolchain + rm -rf ${TOOLCHAIN_DIR} + + # create stand alone toolchain + ${NDK_DIR}/build/tools/make-standalone-toolchain.sh --platform=${PLATFORM_VERSION} --ndk-dir=${NDK_DIR} --install-dir=${TOOLCHAIN_DIR} +} + +applyPatch() +{ + # we assume that errors are just an existing applied patch, so we remove rejects.. + patch -p0 -N -i patches/ndk_v8.patch || find v8 -name '*.rej' -exec rm \{\} \; +} + +buildV8() +{ + AR=${TOOLCHAIN_DIR}/bin/arm-linux-androideabi-ar + CXX="${TOOLCHAIN_DIR}/bin/arm-linux-androideabi-g++ -DANDROID=1 -D__STDC_INT64__=1" + RANLIB=${TOOLCHAIN_DIR}/bin/arm-linux-androideabi-ranlib + + cd ${V8_DIR} + AR=${AR} CXX=${CXX} RANLIB=${RANLIB} \ + scons -j $NUM_CPUS mode=$MODE snapshot=off library=static arch=arm os=linux +} + +buildThirdparty() +{ + # Copied from v8/tools/push-to-trunk.sh + VERSION_FILE=$V8_DIR/src/version.cc + MAJOR=$(grep "#define MAJOR_VERSION" "$VERSION_FILE" | awk '{print $NF}') + MINOR=$(grep "#define MINOR_VERSION" "$VERSION_FILE" | awk '{print $NF}') + BUILD=$(grep "#define BUILD_NUMBER" "$VERSION_FILE" | awk '{print $NF}') + + V8_VERSION="$MAJOR.$MINOR.$BUILD" + cd $V8_DIR + V8_GIT_REVISION=$(git rev-parse HEAD) + V8_GIT_BRANCH=$(git status -s -b | grep \#\# | sed 's/\#\# //') + V8_SVN_REVISION=$(git log -n 1 | grep git-svn-id | perl -ne 's/\s+git-svn-id: [^@]+@([^\s]+) .+/\1/; print') + + DATE=$(date '+%Y-%m-%d %H:%M:%S') +cat < $BUILD_DIR/libv8.json +{ + "version": "$V8_VERSION", + "git_revision": "$V8_GIT_REVISION", + "git_branch": "$V8_GIT_BRANCH", + "svn_revision": "$V8_SVN_REVISION", + "timestamp": "$DATE" +} +EOF + + cp $V8_DIR/libv8.a $BUILD_DIR + cd $BUILD_DIR + + echo "Building libv8-$V8_VERSION.tar.bz2..." + tar -cvj -f libv8-$V8_VERSION.tar.bz2 libv8.json libv8.a +} + +if [ ! -d "$TOOLCHAIN_DIR" ]; then + buildToolchain +fi + +applyPatch +buildV8 + +if [ "$THIRDPARTY" = "1" ]; then + buildThirdparty +fi diff --git a/patches/ndk_v8.patch b/patches/ndk_v8.patch new file mode 100644 index 0000000..d3f3cb1 --- /dev/null +++ b/patches/ndk_v8.patch @@ -0,0 +1,26 @@ +unchanged: +--- v8_orig/src/platform-linux.cc 2011-09-09 19:48:25.536842403 -0500 ++++ v8/src/platform-linux.cc 2011-09-09 14:05:42.845135548 -0500 +@@ -1085,7 +1085,7 @@ + if (result != 0 && errno != EINTR) { + fprintf(stderr, + "SignalSender usleep error; interval = %u, errno = %d\n", +- interval, ++ (unsigned int)interval, + errno); + ASSERT(result == 0 || errno == EINTR); + } +only in patch2: +unchanged: +--- v8_orig/src/platform-posix.cc 2011-09-09 19:48:25.540842403 -0500 ++++ v8/src/platform-posix.cc 2011-09-09 19:55:02.772842683 -0500 +@@ -48,7 +48,8 @@ + + #if defined(ANDROID) + #define LOG_TAG "v8" +-#include // LOG_PRI_VA ++#include ++#define LOG_PRI_VA __android_log_print + #endif + + #include "v8.h" diff --git a/update_v8.sh b/update_v8.sh new file mode 100755 index 0000000..eeba173 --- /dev/null +++ b/update_v8.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Appcelerator Titanium Mobile +# Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved. +# Licensed under the terms of the Apache Public License +# Please see the LICENSE included with this distribution for details. +# +# Reverse our patches, and update (and index) the v8 submodule to the latest from trunk + +patch -p0 --reverse -i patches/ndk_v8.patch + +cd v8 +git pull + +cd .. +git add v8