[coreboot-gerrit] Patch set updated for coreboot: buildgcc: Make package build() function more versatile

Nico Huber (nico.h@gmx.de) gerrit at coreboot.org
Wed Apr 20 15:30:28 CEST 2016


Nico Huber (nico.h at gmx.de) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13471

-gerrit

commit e2370eb04e34ac2b1c71f8ad984c6060cbbbd8f0
Author: Nico Huber <nico.huber at secunet.com>
Date:   Tue Jan 26 16:09:31 2016 +0100

    buildgcc: Make package build() function more versatile
    
    Refactor build() to make things more flexible:
    
    Add a parameter that tells if we build a package for the host or for a
    target architecture. This is just passed to the build_$package()
    function and can be used later to take different steps in each case
    (e.g. for bootstrapping a host gcc).
    
    Move .success files into the destination directory. That way we can tell
    that a package has been built even if the package build directory has
    been removed.
    
    Change-Id: I52a7245714a040d11f6e1ac8bdbff8057bb7f0a1
    Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
 util/crossgcc/buildgcc | 50 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index d4655ca..fae8bd3 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -297,39 +297,57 @@ package_uses_targetarch()
 	fi
 }
 
-build() {
+generic_build()
+{
 	package=$1
+	host_target=$2
+	builddir=$3
+	success=$4
 
 	fn_exists build_$package || return
 
 	version="$(eval echo \$$package"_VERSION")"
-	package_uses_targetarch "$package" && \
-		BUILDDIR=build-${TARGETARCH}-$package || \
-		BUILDDIR=build-$package
 
-	mkdir -p ${BUILDDIR}
+	mkdir -p "$builddir"
 
-	is_package_enabled "$package" && \
-	if [ -f ${BUILDDIR}/.success ]; then
+	if [ -f "$success" ]; then
 		printf "Skipping $package as it is already built\n"
 	else
 		printf "Building $package $version ... "
-		DIR=$PWD
-		cd ${BUILDDIR}
+		DIR="$PWD"
+		cd "$builddir"
 		rm -f .failed
-		build_${package} > build.log 2>&1
-		cd $DIR/${BUILDDIR}
-		if [ ! -f .failed ]; then touch .success; fi
-		cd ..
-
-		if [ -r "${BUILDDIR}/.failed" ]; then
-			printf "${RED}failed${NC}. Check ${BUILDDIR}/build.log.\n"
+		build_${package} $host_target > build.log 2>&1
+		cd "$DIR"
+		if [ ! -f "$builddir/.failed" ]; then
+			touch "$success";
+		else
+			printf "${RED}failed${NC}. Check $builddir/build.log.\n"
 			exit 1
 		fi
 		printf "${green}ok${NC}\n"
 	fi
 }
 
+build_for_host()
+{
+	generic_build $1 host build-$1 "${TARGETDIR}/.$1.success"
+}
+
+build_for_target()
+{
+	generic_build $1 target build-${TARGETARCH}-$1 "${TARGETDIR}/.${TARGETARCH}-$1.success"
+}
+
+build()
+{
+	if package_uses_targetarch $1; then
+		build_for_target $1
+	else
+		build_for_host $1
+	fi
+}
+
 cleanup()
 {
 	if [ $SAVETEMPS -ne 0 ]; then



More information about the coreboot-gerrit mailing list