[scripts] add parallel building script and use it in most build scripts

This commit is contained in:
Travis Geiselbrecht
2019-03-30 20:02:18 -07:00
parent 4148863969
commit 41a7937444
17 changed files with 94 additions and 50 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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 $@

View File

@@ -1,6 +0,0 @@
#!/bin/sh
export PROJECT=osk5912-test
make &&
scp build-osk5912-test/lk.bin four:/tftproot

View File

@@ -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 $@

View File

@@ -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 $@

View File

@@ -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 $@

View File

@@ -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 $@

View File

@@ -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 $@

View File

@@ -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 $@

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

24
scripts/make-parallel Executable file
View File

@@ -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 "$@"

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LOCAL_TOOLPATH="$DIR/toolpaths.local"