From 8aa6a2a0cb44098ede490dd44ea05f7bedf52205 Mon Sep 17 00:00:00 2001 From: Tom Keel Date: Mon, 11 Feb 2013 12:17:31 +0100 Subject: [PATCH 1/2] Parameterize for CPU architecture, API level, etc. This enables choosing to build - for ARM or x86 - for a particular Android API level - using a particular version of the cross toolchain by setting a few variables at the top of the build script. This also allows specifying where to install the NDK and SDK by setting variables at the top of the build script. The default is to install them in the $HOME directory. --- android-env.sh | 4 +- build-clutter-android.sh | 126 ++++++++++++++++++++++++++++++--------- jhbuildrc-android | 17 +----- 3 files changed, 103 insertions(+), 44 deletions(-) diff --git a/android-env.sh b/android-env.sh index 70a6f84..25f61fe 100644 --- a/android-env.sh +++ b/android-env.sh @@ -30,8 +30,8 @@ export CXX=arm-linux-androideabi-g++ export C_INCLUDE_PATH=$PREFIX/include export CPLUS_INCLUDE_PATH=$PREFIX/include -export ANDROID_SDK_DIR="$PWD/android-sdk-linux" -export ANDROID_NDK_DIR=`find $PWD/* -maxdepth 0 -type d -name 'android-ndk-r*'` +export ANDROID_SDK_DIR="$HOME/android-sdk-linux" +export ANDROID_NDK_DIR=`find $HOME -maxdepth 1 -type d -name 'android-ndk-*'` export ANDROID_NDK_TOOLCHAIN="$PWD/toolchain" export gl_cv_header_working_stdint_h=yes diff --git a/build-clutter-android.sh b/build-clutter-android.sh index 101aaa8..da7dc4b 100755 --- a/build-clutter-android.sh +++ b/build-clutter-android.sh @@ -16,42 +16,114 @@ set -ex -# download Android NDK and create standalone toolchain -if ! test -d android-ndk-r8c; then - wget http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2 - tar jxf android-ndk-r8c-linux-x86.tar.bz2 - rm android-ndk-r8c-linux-x86.tar.bz2 - pushd android-ndk-r8c - ./build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=../toolchain - popd +# Which target architecture (arm or x86). +ARCH=x86 + +# Which Android "API Level" to build for. +API_LEVEL=14 + +# Which version of the Android NDK toolchain to use (e.g. 4.6). +TOOLCHAIN_VERSION=4.6 + +# Where the Android NDK lives. +NDK_NAME=android-ndk-r8d +NDK_DIR=$HOME/$NDK_NAME + +# Where the Android SDK lives. +SDK_NAME=android-sdk-linux +SDK_DIR=$HOME/$SDK_NAME + +# Download the Android NDK if necessary. +if ! test -d $NDK_DIR; then + mkdir -p $NDK_DIR + pushd $NDK_DIR/.. + wget http://dl.google.com/android/ndk/$NDK_NAME-linux-x86.tar.bz2 \ + && tar jxf $NDK_NAME-linux-x86.tar.bz2 \ + && rm $NDK_NAME-linux-x86.tar.bz2 + popd fi -JHB_PREFIX=$PWD/jhbuild/.local +# Download the Android SDK if necessary. +if ! test -d $SDK_DIR; then + mkdir -p $SDK_DIR + pushd $SDK_DIR/.. + wget http://dl.google.com/android/android-sdk_r21-linux.tgz \ + && tar zxf android-sdk_r21-linux.tgz \ + && rm android-sdk_r21-linux.tgz + popd +fi + +# Update the Android SDK if necessary. +#$SDK_DIR/tools/android update sdk -u --filter platform-tool,tool +#$SDK_DIR/tools/android update sdk -u --filter android-$API_LEVEL + +# Toolchain name: the prefix of toolchain command names +# Toolchain arg: passed to make-standalon-toolchain.sh +# Toolchain dir: where we put the standalone toolchain +case $ARCH in + arm) + export TOOLCHAIN_NAME=arm-linux-androideabi + TOOLCHAIN_ARG=arm-linux-androideabi-$TOOLCHAIN_VERSION + ;; + x86) + export TOOLCHAIN_NAME=i686-linux-android + TOOLCHAIN_ARG=x86-$TOOLCHAIN_VERSION + ;; +esac +TOOLCHAIN_DIR=$PWD/toolchain-$ARCH-$TOOLCHAIN_VERSION + +# Create the standalone toolchain. +$NDK_DIR/build/tools/make-standalone-toolchain.sh \ + --toolchain=$TOOLCHAIN_ARG \ + --platform=android-$API_LEVEL \ + --install-dir=$TOOLCHAIN_DIR -# set up patched version of jhbuild +# Set up patched version of jhbuild +JHB_PREFIX=$PWD/jhbuild/.local if ! test -d jhbuild; then - git clone git://git.gnome.org/jhbuild - pushd jhbuild - patch -p1 -i ../modulesets/patches/jhbuild/disable-clean-la-files.patch - ./autogen.sh --prefix=$JHB_PREFIX - make install - popd + git clone git://git.gnome.org/jhbuild + pushd jhbuild + patch -p1 -i ../modulesets/patches/jhbuild/disable-clean-la-files.patch + ./autogen.sh --prefix=$JHB_PREFIX + make install + popd fi mkdir -p $JHB_PREFIX/share/aclocal cp /usr/share/aclocal/gtk-doc.m4 $JHB_PREFIX/share/aclocal/ -source ./android-env.sh +export PREFIX="$PWD/install-$ARCH-$API_LEVEL" -# start the build -$JHB_PREFIX/bin/jhbuild -f jhbuildrc-android build -q mx libsoup +export CFLAGS= +export CC=$TOOLCHAIN_NAME-gcc +export CXX=$TOOLCHAIN_NAME-g++ -# download Android SDK -if ! test -d android-sdk-linux; then - wget http://dl.google.com/android/android-sdk_r21-linux.tgz - tar zxf android-sdk_r21-linux.tgz - rm android-sdk_r21-linux.tgz -fi +export C_INCLUDE_PATH=$PREFIX/include +export CPLUS_INCLUDE_PATH=$PREFIX/include + +export gl_cv_header_working_stdint_h=yes + +# remove other langauges +export LINGUAS=C + +# avoid picking up system libraries +export PKG_CONFIG_LIBDIR=/foo/bar +export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig + +export ac_cv_path_GLIB_COMPILE_RESOURCES=/usr/bin/glib-compile-resources +export ac_cv_path_GLIB_COMPILE_SCHEMAS=/usr/bin/glib-compile-schemas +export ac_cv_path_GLIB_GENMARSHAL=/usr/bin/glib-genmarshal + +export PATH="$TOOLCHAIN_DIR/bin:$NDK_DIR:$SDK_DIR/tools/:$SDK_DIR/platform-tools:$PATH" + +export NDK_MODULE_PATH=$PWD + +export PKG_CONFIG="pkg-config \ + --define-variable=glib_genmarshal=/usr/bin/glib-genmarshal \ + --define-variable=gobject_query=/usr/bin/gobject-query \ + --define-variable=glib_mkenums=/usr/bin/glib-mkenums \ + --define-variable=glib_compile_resources=/usr/bin/glib-compile-resources \ +" -android update sdk -u --filter platform-tool,tool -android update sdk -u --filter android-14 +# Do it. +$JHB_PREFIX/bin/jhbuild -f jhbuildrc-android -m modulesets/clutter-android.modules ${*:-build glib} diff --git a/jhbuildrc-android b/jhbuildrc-android index b493478..d0d4a9e 100644 --- a/jhbuildrc-android +++ b/jhbuildrc-android @@ -1,21 +1,8 @@ -moduleset = os.environ['PWD'] + '/modulesets/clutter-android.modules' checkoutroot = os.environ['PWD'] + '/sources' -prefix = os.environ['PWD'] + '/install' - +prefix = os.environ['PREFIX'] build_policy = 'updated' use_lib64 = False - use_local_modulesets = True partial_build = False -autogenargs = '--disable-shared --disable-gtk-doc --host=arm-linux-androideabi gl_cv_header_working_stdint_h=yes --disable-introspection ' +autogenargs = '--disable-shared --disable-gtk-doc gl_cv_header_working_stdint_h=yes --disable-introspection --build=x86_64-unknown-linux-gnu --host=' + os.environ['TOOLCHAIN_NAME'] makeargs = '-j 4' - - -os.environ['ac_cv_path_GLIB_COMPILE_RESOURCES']='/usr/bin/glib-compile-resources' -os.environ['ac_cv_path_GLIB_COMPILE_SCHEMAS']='/usr/bin/glib-compile-schemas' -os.environ['ac_cv_path_GLIB_GENMARSHAL']='/usr/bin/glib-genmarshal' - -os.environ['PATH'] += ':' + os.environ['PWD'] + '/toolchain/bin' -os.environ['CC'] = 'arm-linux-androideabi-gcc' - -os.environ['PKG_CONFIG'] = 'pkg-config --define-variable=glib_genmarshal=/usr/bin/glib-genmarshal --define-variable=gobject_query=/usr/bin/gobject-query --define-variable=glib_mkenums=/usr/bin/glib-mkenums --define-variable=glib_compile_resources=/usr/bin/glib-compile-resources' From 388ae2a2c0d66e81bc619d63bdc28a4a27131d93 Mon Sep 17 00:00:00 2001 From: Tom Keel Date: Mon, 11 Feb 2013 12:19:21 +0100 Subject: [PATCH 2/2] Remove dependency of glib upon zlib. Because libz is in the Android NDK. --- modulesets/clutter-android.modules | 1 - 1 file changed, 1 deletion(-) diff --git a/modulesets/clutter-android.modules b/modulesets/clutter-android.modules index 0bda580..002872e 100644 --- a/modulesets/clutter-android.modules +++ b/modulesets/clutter-android.modules @@ -97,7 +97,6 @@ -