changeset 677:ada655f5be21

Teach build-static-toolchains to FORK multiple qemu instances, conceptually similar to how buildall.sh handles FORK.
author Rob Landley <rob@landley.net>
date Mon, 30 Mar 2009 03:28:36 -0500
parents 112dc7b787d3
children ea25e4da724e
files build-static-toolchains.sh
diffstat 1 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/build-static-toolchains.sh	Mon Mar 30 03:26:45 2009 -0500
+++ b/build-static-toolchains.sh	Mon Mar 30 03:28:36 2009 -0500
@@ -19,13 +19,11 @@
 
 source sources/include.sh || exit 1
 
-# run-from-build.sh needs things that aren't in build/host,
-# such as qemu and fsck.ext2
-PATH="$OLDPATH"
+# Grab host to build for.  (This is the system image we'll run under qemu.)
 
 STATIC_HOST="$1"
 shift
-[ -z "$@" ] && STATIC_TARGETS="$(echo $(cd sources/targets; ls))" || STATIC_TARGETS="$@"
+[ -z "$*" ] && STATIC_TARGETS="$(echo $(cd sources/targets; ls))" || STATIC_TARGETS="$@"
 
 # Step 1, make sure the appropriate host files exist.
 
@@ -39,24 +37,44 @@
 
 trap "kill 0" EXIT
 
-# Feed a script into qemu.  Pass data back and forth via netcat.
-# This intentionally _doesn't_ use $NICE, so the distcc master node is higher
-# priority than the distccd slave nodes.
+function build_for_static_host()
+{
+  # Feed a script into qemu.  Pass data back and forth via netcat.
+  # This intentionally _doesn't_ use $NICE, so the distcc master node is higher
+  # priority than the distccd slave nodes.
 
-./run-from-build.sh "$STATIC_HOST" << EOF
+  KERNEL_EXTRA="ro" ./run-from-build.sh "$STATIC_HOST" << EOF
           #
 export USE_UNSTABLE=$USE_UNSTABLE
 export CROSS_BUILD_STATIC=1
 rm -rf /home/firmware
 mkdir -p /home/firmware &&
 cd /home/firmware &&
-netcat 10.0.2.2 $(build/host/netcat -s 127.0.0.1 -l tar c *.sh sources packages build/sources) | tar xv 2>&1 | pipe_progress > /dev/null &&
+netcat 10.0.2.2 $(build/host/netcat -s 127.0.0.1 -l tar c *.sh sources build/sources) | tar xv 2>&1 | pipe_progress > /dev/null &&
 mkdir -p build/logs || exit 1
 for i in $STATIC_TARGETS
 do
-  ./cross-compiler.sh \$i | tee out-static-\$i.txt
+  ./cross-compiler.sh \$i
 done
-tar c out-*.txt build/cross-compiler-*.tar.bz2 | netcat 10.0.2.2 \
+tar cC build cross-compiler-*.tar.bz2 | netcat 10.0.2.2 \
   $(mkdir -p build/static; cd build/static; ../host/netcat -s 127.0.0.1 -l tar xv)
 exit
 EOF
+}
+
+# If FORK, fork one qemu instance for each target
+
+if [ ! -z "$FORK" ]
+then
+  for i in $STATIC_TARGETS
+  do
+    rm -f "${BUILD}/system-image-${STATIC_HOST}/hdb-${i}.img" 2>/dev/null
+    (HDB="hdb-$i.img" STATIC_TARGETS="$i" build_for_static_host | tee out-static-$i.txt | grep ===) &
+    rm -f "${BUILD}/system-image-${STATIC_HOST}/hdb-${i}.img" 2>/dev/null
+  done
+
+  wait4background 0
+else
+  build_for_static_host
+fi
+