[coreboot-gerrit] Patch set updated for coreboot: util/crossgcc: Add ability to build host tools/libs
Nico Huber (nico.h@gmx.de)
gerrit at coreboot.org
Wed Jan 27 00:43:18 CET 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 d84fb90c7dffd23203f8b3b03cc3937143df184f
Author: Nico Huber <nico.huber at secunet.com>
Date: Tue Jan 26 16:09:31 2016 +0100
util/crossgcc: Add ability to build host tools/libs
We currently mix builds of host tools and libraries with builds of our
target toolchain. To end this, add the option to prefix a package name
with `host-` to build it only once for the host. Details:
o Resulting files will be installed into xgcc-host/ instead of xgcc/.
o .success files moved into the destination dir. That way we can tell
that a package has been built even if the package build directory
was removed.
Change-Id: I52a7245714a040d11f6e1ac8bdbff8057bb7f0a1
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
util/crossgcc/buildgcc | 88 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 69 insertions(+), 19 deletions(-)
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 138558a..d3a3cec 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -23,10 +23,12 @@ CROSSGCC_VERSION="1.33"
# default settings
PACKAGE=GCC
+HOSTDIR=$(pwd)/xgcc-host
TARGETDIR=$(pwd)/xgcc
TARGETARCH=i386-elf
LANGUAGES=c
DESTDIR=
+CLEANHOST=0
SAVETEMPS=0
SKIPPYTHON=1
@@ -94,6 +96,43 @@ NC='\033[0m' # No Color
UNAME=$(uname | grep -iq cygwin && echo Cygwin || uname)
HALT_FOR_TOOLS=0
+is_host_package()
+{
+ echo $1 | grep -q '^host-' >/dev/null 2>&1
+}
+
+package_name()
+{
+ echo $1 | sed -e 's/^host-//'
+}
+
+build_dir()
+{
+ if is_host_package $1; then
+ echo build-$1
+ else
+ echo build-${TARGETARCH}-$2
+ fi
+}
+
+install_dir()
+{
+ if is_host_package $1; then
+ echo $HOSTDIR
+ else
+ echo $TARGETDIR
+ fi
+}
+
+success_file()
+{
+ if is_host_package $1; then
+ echo .$2.success
+ else
+ echo .$2-$TARGETARCH.success
+ fi
+}
+
normalize_dirs()
{
mkdir -p $DESTDIR$TARGETDIR/lib
@@ -200,7 +239,7 @@ download_showing_percentage() {
}
download() {
- package=$1
+ package=$(package_name $1)
archive="$(eval echo \$$package"_ARCHIVE")"
FILE=$(basename $archive)
@@ -225,7 +264,7 @@ download() {
}
unpack_and_patch() {
- package=$1
+ package=$(package_name $1)
archive="$(eval echo \$$package"_ARCHIVE")"
dir="$(eval echo \$$package"_DIR")"
test -d ${dir} && test -f ${dir}/.unpack_success || (
@@ -260,29 +299,31 @@ is_package_enabled()
}
build() {
- package=$1
+ pkgspec=$1
+ package=$(package_name $pkgspec)
fn_exists build_$package || return
version="$(eval echo \$$package"_VERSION")"
- BUILDDIR=build-${TARGETARCH}-$package
+ SUCCESS=$(success_file $pkgspec $package)
+ BUILDDIR=$(build_dir $pkgspec $package)
+ INSTALLDIR=$(install_dir $pkgspec)
mkdir -p ${BUILDDIR}
- is_package_enabled "$package" && \
- if [ -f ${BUILDDIR}/.success ]; then
- printf "Skipping $package as it is already built\n"
+ is_package_enabled "$pkgspec" && \
+ if [ -f ${INSTALLDIR}/${SUCCESS} ]; then
+ printf "Skipping $pkgspec as it is already built\n"
else
- printf "Building $package $version ... "
+ printf "Building $pkgspec $version ... "
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
+ build_${package} $pkgspec > build.log 2>&1
+ cd $DIR
+ if [ ! -f ${BUILDDIR}/.failed ]; then
+ touch ${INSTALLDIR}/${SUCCESS};
+ else
printf "${RED}failed${NC}. Check ${BUILDDIR}/build.log.\n"
exit 1
fi
@@ -293,9 +334,13 @@ build() {
cleanup()
{
printf "Cleaning up temporary files... "
- for package in $PACKAGES; do
- rm -rf build-${TARGETARCH}-$package $(eval echo \$$package"_DIR")
+ for pkgspec in $PACKAGES; do
+ package=$(package_name $pkgspec)
+ rm -rf $(build_dir $pkgspec $package) $(eval echo \$$package"_DIR")
done
+ if [ $CLEANHOST = 1 ]; then
+ rm -rf $DESTDIR$HOSTDIR
+ fi
rm -f getopt
printf "${green}ok${NC}\n"
}
@@ -310,6 +355,7 @@ myhelp()
printf " [-V|--version] print version number and exit\n"
printf " [-h|--help] print this help and exit\n"
printf " [-c|--clean] remove temporary files before build\n"
+ printf " [-r|--cleanhost] remove temporary files for host libs and tools\n"
printf " [-t|--savetemps] don't remove temporary files after build\n"
printf " [-y|--ccache] Use ccache when building cross compiler\n"
printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
@@ -562,8 +608,12 @@ while true ; do
-V|--version) shift; myversion; exit 0;;
-h|--help) shift; myhelp; exit 0;;
-c|--clean) shift; clean=1;;
+ -r|--cleanhost) shift; CLEANHOST=1;;
-t|--savetemps) shift; SAVETEMPS=1;;
- -d|--directory) shift; TARGETDIR="$1"; shift;;
+ -d|--directory) shift
+ TARGETDIR="$(echo $1 | sed -e 's,/*$,,')"
+ HOSTDIR="$TARGETDIR-host"
+ shift;;
-p|--platform) shift; TARGETARCH="$1"; shift;;
-l|--languages) shift; LANGUAGES="$1"; shift;;
-D|--destdir) shift; DESTDIR="$1"; shift;;
@@ -702,8 +752,8 @@ fi
# Prepare target directory for building GCC
# (dependencies must be in the PATH)
-mkdir -p $DESTDIR$TARGETDIR/bin
-export PATH=$DESTDIR$TARGETDIR/bin:$PATH
+mkdir -p $DESTDIR$HOSTDIR/bin $DESTDIR$TARGETDIR/bin
+export PATH=$DESTDIR$HOSTDIR/bin:$DESTDIR$TARGETDIR/bin:$PATH
# Download, unpack, patch and build all packages
More information about the coreboot-gerrit
mailing list