From ab23698c3ede84f3dda5a65b6e8169d4b2e31347 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 24 Feb 2010 14:43:10 -0800 Subject: [PATCH] Allow the build-toolchain.sh script to apply source packages. All you need to do is place name them like the following: build/tools/toolchain-patches//.patch And they will be applied with 'patch -p1' into: / This is useful to experiment with toolchain changes without having to regenerate a whole new source package tarball each time. --- build/tools/build-toolchain.sh | 47 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/build/tools/build-toolchain.sh b/build/tools/build-toolchain.sh index 80bb4e9..51f3fa7 100755 --- a/build/tools/build-toolchain.sh +++ b/build/tools/build-toolchain.sh @@ -389,14 +389,13 @@ download_package () } # Unpack a given package in a target location -# $1: package name -# $2: target directory +# $1: package name (e.g. toolchain) +# $2: target directory (e.g. /tmp/foo) # unpack_package () { - WORKSPACE=$ANDROID_NDK_ARCHIVE/$1 - SRCDIR=$2 SRCPKG=`var_value PKG_$1` + SRCDIR=$2 if ! timestamp_check $1 unpack; then echo "Unpack : $1 sources" echo " from $SRCPKG" @@ -413,6 +412,45 @@ unpack_package () exit 1 fi timestamp_set $1 unpack + timestamp_force $1 patch + fi +} + +# Patch a given package at a target location +# $1: package name (e.g. toolchain) +# $2: target directory (e.g. /tmp/foo) +# $3: patch directory (e.g. build/tools/toolchain-patches) +# +# The rationale here is that anything named like $3//.patch +# will be applied with "patch -p1" under $2/ +# +# Patches are listed and applied in alphanumerical order of their names +# as returned by 'find'. Consider using numbered prefixes like the patch +# files generated by "git format-patch" are named. +# +patch_package () +{ + SRCPKG=`var_value PKG_$1` + SRCDIR=$2 + if ! timestamp_check $1 patch; then + PATCH_FILES=`(cd $3 && find . -name "*.patch") 2> /dev/null` + if [ -z "$PATCH_FILES" ] ; then + echo "Patch : none provided" + return + fi + for PATCH in $PATCH_FILES; do + echo "Patch : $1 sources" + echo " from $PATCH" + echo " into $SRCDIR" + PATCHDIR=`dirname $PATCH` + PATCHNAME=`basename $PATCH` + cd $SRCDIR/$PATCHDIR && patch -p1 < $3/$PATCH + if [ $? != 0 ] ; then + echo "Patch failure !! Please check toolchain package !" + exit 1 + fi + done + timestamp_set $1 patch timestamp_force $1 configure fi } @@ -443,6 +481,7 @@ else fi unpack_package toolchain $ANDROID_TOOLCHAIN_SRC +patch_package toolchain $ANDROID_TOOLCHAIN_SRC $ANDROID_NDK_ROOT/build/tools/toolchain-patches # remove all info files from the unpacked toolchain sources # they create countless little problems during the build -- 2.11.0