diff --git a/scripts/buildall b/scripts/buildall index 63ba2988..81101eff 100755 --- a/scripts/buildall +++ b/scripts/buildall @@ -1,25 +1,17 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # build everything in the projects directory -PROJECTS=`echo project/*.mk | xargs -n1 basename | sed 's/\.mk//'` +PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//') FAILED="" -case `uname` in -Linux) - N=`cat /proc/cpuinfo | grep processor | wc -l` - PARALLEL=-j`expr $N + $N` - ;; -*) - PARALLEL=-j4 - ;; -esac - for p in $PROJECTS; do - PROJECT=$p nice make $PARALLEL || FAILED="$FAILED $p" + PROJECT=$p nice $DIR/make-parallel || FAILED="$FAILED $p" done if [ "$FAILED" != "" ]; then - echo - echo some projects have failed to build: - echo $FAILED + echo + echo some projects have failed to build: + echo $FAILED fi diff --git a/scripts/do-armemu-test b/scripts/do-armemu-test index 04c9e50a..7bd9b8bb 100755 --- a/scripts/do-armemu-test +++ b/scripts/do-armemu-test @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export PROJECT=armemu-test @@ -6,6 +8,6 @@ if [ ! -f blk.bin ]; then dd if=/dev/zero of=blk.bin bs=1024k count=16 fi -make -j8 -C ../armemu && -make -j8 && +$DIR/make-parallel -C ../armemu && +$DIR/make-parallel && (cd build-$PROJECT; ../../armemu/build-generic/armemu) diff --git a/scripts/do-or1ksim b/scripts/do-or1ksim index 421c316e..6da571f8 100755 --- a/scripts/do-or1ksim +++ b/scripts/do-or1ksim @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash -make or1ksim -j4 && +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +$DIR/make-parallel or1ksim && or1k-elf-sim -f platform/or1ksim/or1ksim.cfg build-or1ksim/lk.elf $@ diff --git a/scripts/do-osk5912-test b/scripts/do-osk5912-test deleted file mode 100755 index 175d1029..00000000 --- a/scripts/do-osk5912-test +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -export PROJECT=osk5912-test - -make && -scp build-osk5912-test/lk.bin four:/tftproot diff --git a/scripts/do-qemuarm b/scripts/do-qemuarm index ec985bab..bc579c1d 100755 --- a/scripts/do-qemuarm +++ b/scripts/do-qemuarm @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function HELP { echo "help:" @@ -95,6 +97,6 @@ elif [ $DO_MINIHEAP == 1 ]; then MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap fi -make $MAKE_VARS $PROJECT -j4 && +$DIR/make-parallel $MAKE_VARS $PROJECT && echo $SUDO $QEMU $ARGS $@ && $SUDO $QEMU $ARGS $@ diff --git a/scripts/do-qemum4 b/scripts/do-qemum4 index c776657a..3661b36e 100755 --- a/scripts/do-qemum4 +++ b/scripts/do-qemum4 @@ -1,5 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + DEFAULT_TOOLPATH="$DIR/toolpaths.default" if [ -e "$DEFAULT_TOOLPATH" ] then @@ -53,6 +55,6 @@ elif [ $DO_MINIHEAP == 1 ]; then MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap fi -make $MAKE_VARS $PROJECT -j4 && +$DIR/make-parallel $MAKE_VARS $PROJECT && echo $QEMUM4 $ARGS $@ && $QEMUM4 $ARGS $@ diff --git a/scripts/do-qemumicroblaze b/scripts/do-qemumicroblaze index 384ae99a..e752404a 100755 --- a/scripts/do-qemumicroblaze +++ b/scripts/do-qemumicroblaze @@ -1,4 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash -make qemu-microblaze-test -j4 && +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -e +set -x + +$DIR/make-parallel qemu-microblaze-test qemu-system-microblaze -kernel build-qemu-microblaze-test/lk.elf -nographic $@ diff --git a/scripts/do-qemumips b/scripts/do-qemumips index 84db33a4..4f230b70 100755 --- a/scripts/do-qemumips +++ b/scripts/do-qemumips @@ -1,4 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash -make qemu-mips-test -j4 && +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -e +set -x + +$DIR/make-parallel qemu-mips-test qemu-system-mips -machine mips -cpu M14K -kernel build-qemu-mips-test/lk.elf -nographic $@ diff --git a/scripts/do-qemuriscv32 b/scripts/do-qemuriscv32 index bc2f0a17..d2226698 100755 --- a/scripts/do-qemuriscv32 +++ b/scripts/do-qemuriscv32 @@ -1,4 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash -make sifive-e-test -j4 && +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +set -e +set -x + +$DIR/make-parallel sifive-e-test qemu-system-riscv32 -machine sifive_e -kernel build-sifive-e-test/lk.elf -nographic $@ diff --git a/scripts/do-qemux86 b/scripts/do-qemux86 index 0b85fbee..5b3f8e80 100755 --- a/scripts/do-qemux86 +++ b/scripts/do-qemux86 @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function HELP { echo "help:" @@ -79,7 +81,7 @@ if (( $DO_KVM )); then ARGS+=" -enable-kvm -cpu host" fi -make $MAKE_VARS $PROJECT -j4 && +$DIR/make-parallel $MAKE_VARS $PROJECT && echo $SUDO $QEMU $ARGS $@ && $SUDO $QEMU $ARGS $@ diff --git a/scripts/do-sifive-e b/scripts/do-sifive-e index d4b6110c..6b4df718 100755 --- a/scripts/do-sifive-e +++ b/scripts/do-sifive-e @@ -1,13 +1,14 @@ #!/usr/bin/env bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + set -x set -e - export PROJECT=sifive-e-test TARGET=`pwd`/build-${PROJECT}/lk.elf -make -j4 +$DIR/make-parallel SDK_DIR=${HOME}/src/freedom-e-sdk OPENOCD_DIR=${SDK_DIR}/riscv-openocd-0.10.0-2018.12.0-x86_64-linux-ubuntu14/bin diff --git a/scripts/do-stellaris-launchpad-test b/scripts/do-stellaris-launchpad-test index 5230ad5d..26619ba3 100755 --- a/scripts/do-stellaris-launchpad-test +++ b/scripts/do-stellaris-launchpad-test @@ -1,6 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export PROJECT=stellaris-launchpad-test -make -j8 && +$DIR/make-parallel && lm4flash -v build-$PROJECT/lk.bin diff --git a/scripts/do-stm32f7-disco-test b/scripts/do-stm32f7-disco-test index b947e54a..a43cb0a9 100755 --- a/scripts/do-stm32f7-disco-test +++ b/scripts/do-stm32f7-disco-test @@ -1,7 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export PROJECT=stm32f746g-disco-test -make -j8 && +$DIR/make-parallel && openocd -f interface/stlink-v2-1.cfg -f board/stm32756g_eval.cfg \ -c "program build-$PROJECT/lk.bin reset exit 0x08000000" diff --git a/scripts/do-uzed-xmd b/scripts/do-uzed-xmd index e94f1adb..cd50de75 100755 --- a/scripts/do-uzed-xmd +++ b/scripts/do-uzed-xmd @@ -1,6 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" PROJECT=uzed-test -make $PROJECT -j && +$DIR/make-parallel $PROJECT && xmd -tcl scripts/xmd.tcl $PROJECT diff --git a/scripts/do-zybo-xmd b/scripts/do-zybo-xmd index 2481eb51..6f93a047 100755 --- a/scripts/do-zybo-xmd +++ b/scripts/do-zybo-xmd @@ -1,6 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" PROJECT=zybo-test -make $PROJECT -j && +$DIR/make-parallel $PROJECT -j && xmd -tcl scripts/xmd.tcl $PROJECT diff --git a/scripts/make-parallel b/scripts/make-parallel new file mode 100755 index 00000000..9740150f --- /dev/null +++ b/scripts/make-parallel @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Copyright 2016 The Fuchsia Authors +# +# Use of this source code is governed by a MIT-style +# license that can be found in the LICENSE file or at +# https://opensource.org/licenses/MIT +MAKE=make +case `uname` in +Linux) + N=`cat /proc/cpuinfo | grep processor | wc -l` + PARALLEL=-j`expr $N + $N` + ;; +Darwin) + PARALLEL=-j`sysctl -n hw.ncpu` + ;; +FreeBSD) + PARALLEL=-j`sysctl -n hw.ncpu` + MAKE=gmake + ;; +*) + PARALLEL=-j8 + ;; +esac +exec $MAKE $PARALLEL "$@" diff --git a/scripts/toolpaths.default b/scripts/toolpaths.default index ad9570ce..5a66667c 100644 --- a/scripts/toolpaths.default +++ b/scripts/toolpaths.default @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" LOCAL_TOOLPATH="$DIR/toolpaths.local"