diff options
author | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-09 11:47:28 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-10 06:04:50 +0200 |
commit | 1c70e052aa7d4a177549ddc07e572b4699f3e4ce (patch) | |
tree | 81a3d675f0a5d41b08dd3ca3ff8eb0615ff854b6 | |
parent | 93b4745d93433788281653f2927d22ed5d8a77c3 (diff) |
buildgcc: solidify and remove boilerplate code
- don't capture build_$package in a subshell by piping it
- move HOSTCFLAGS to build_GMP
- only create a build directory if a build happens
- automatically collect packages to build
Change-Id: Ic5a9f3f222faecd3381b413e5f25dff87262a855
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: http://review.coreboot.org/10475
Reviewed-by: Alexander Couzens <lynxis@fe80.eu>
Tested-by: build bot (Jenkins)
-rwxr-xr-x | util/crossgcc/buildgcc | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index a0474bbc7d..1b49cc8be1 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -235,29 +235,37 @@ unpack_and_patch() { ) } -wait_for_build() { - # $1: directory in which log file and failure marker are stored - cat > "$1/crossgcc-build.log" - test -r "$1/.failed" && printf "${RED}failed${NC}. Check $1/crossgcc-build.log.\n" || \ - printf "${green}ok${NC}\n" - test -r "$1/.failed" && exit 1 - true +fn_exists() +{ + type $1 2>/dev/null | grep -q 'is a function' } build() { package=$1 version="$(eval echo \$$package"_VERSION")" + + fn_exists build_$package || return + + mkdir -p ${BUILDDIRPREFIX}-$package + [[ "$PACKAGES" == *$package* ]] && \ if [ -f ${BUILDDIRPREFIX}-$package/.success ]; then printf "Skipping $package as it is already built\n" else printf "Building $package $version ... " - ( - cd ${BUILDDIRPREFIX}-$package - rm -f .failed - build_${package} - if [ ! -f .failed ]; then touch .success; fi - ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-$package" || exit 1 + DIR=$PWD + cd ${BUILDDIRPREFIX}-$package + rm -f .failed + build_${package} > build.log 2>&1 + cd $DIR/${BUILDDIRPREFIX}-$package + if [ ! -f .failed ]; then touch .success; fi + cd .. + + if [ -r "${BUILDDIRPREFIX}-$package/.failed" ]; then + printf "${RED}failed${NC}. Check ${BUILDDIRPREFIX}-$package/build.log.\n" + exit 1 + fi + printf "${green}ok${NC}\n" fi } @@ -322,6 +330,11 @@ build_GMP() { $MAKE install DESTDIR=$DESTDIR || touch .failed normalize_dirs + + # Now set CFLAGS to match GMP CFLAGS but strip out -pedantic + # as GCC 4.6.x fails if it's there. + export HOSTCFLAGS=$(grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\ + sed s,-pedantic,,) } build_MPFR() { @@ -538,11 +551,11 @@ if [ $SKIPGDB -eq 1 ]; then SKIPPYTHON=1 fi else + if [ $SKIPPYTHON -eq 0 ]; then + PACKAGES="$PACKAGES EXPAT PYTHON" + fi PACKAGES="$PACKAGES GDB" fi -if [ $SKIPPYTHON -eq 0 ]; then - PACKAGES="$PACKAGES EXPAT PYTHON" -fi # coreboot does not like the GOLD linker # USE_GOLD="--enable-gold" @@ -558,7 +571,7 @@ printf "Downloaded tar balls ... ${green}ok${NC}\n" printf "Unpacking and patching ... \n" for P in $PACKAGES; do - unpack_and_patch $P + unpack_and_patch $P || exit 1 done printf "Unpacked and patched ... ${green}ok${NC}\n" @@ -591,30 +604,12 @@ if [ "$USECCACHE" = 1 ]; then CC="ccache $CC" fi -for package in $PACKAGES; do - mkdir -p ${BUILDDIRPREFIX}-$package -done - mkdir -p $DESTDIR$TARGETDIR/bin export PATH=$DESTDIR$TARGETDIR/bin:$PATH -build GMP - -# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic -# as GCC 4.6.x fails if it's there. -HOSTCFLAGS=$(grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\ - sed s,-pedantic,,) - -build MPFR -build MPC -build LIBELF -build BINUTILS -build GCC -build EXPAT -build PYTHON -build GDB -build IASL -build LLVM +for package in $PACKAGES; do + build $package +done # Adding git information of current tree to target directory # for reproducibility |