From 3dff26ae7b75b650ea5927699a6a254b1b433bb2 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Sat, 23 Jul 2022 15:57:53 -0700 Subject: [PATCH] [make] add BUILDDIR_SUFFIX build variable This allows you to tag your build dirs with an optional string. Update scripts/buildall to also allow building all release (DEBUG=0) builds. Add a few other convenience switches. --- engine.mk | 3 ++- scripts/buildall | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/engine.mk b/engine.mk index f0dbe1a3..ef581f47 100644 --- a/engine.mk +++ b/engine.mk @@ -54,7 +54,8 @@ endif # PROJECT == null DEBUG ?= 2 -BUILDDIR := $(BUILDROOT)/build-$(PROJECT) +BUILDDIR_SUFFIX ?= +BUILDDIR := $(BUILDROOT)/build-$(PROJECT)$(BUILDDIR_SUFFIX) OUTBIN := $(BUILDDIR)/lk.bin OUTELF := $(BUILDDIR)/lk.elf CONFIGHEADER := $(BUILDDIR)/config.h diff --git a/scripts/buildall b/scripts/buildall index 81101eff..963c13da 100755 --- a/scripts/buildall +++ b/scripts/buildall @@ -2,14 +2,63 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +function HELP { + echo "help:" + echo "-e build with WERROR=1" + echo "-r also build DEBUG=0" + echo "-q hide output of build" + echo "-h for help" + exit 1 +} + +RELEASE=0 +WERROR=0 +QUIET=0 + +while getopts ehrq FLAG; do + case $FLAG in + e) WERROR=1;; + h) HELP;; + r) RELEASE=1;; + q) QUIET=1;; + \?) + echo unrecognized option + HELP + esac +done + +shift $((OPTIND-1)) + +echo > buildall.log +function log() +{ + if (( $QUIET )); then + "$@" >> buildall.log 2>&1 + else + "$@" 2>&1 | tee -a buildall.log + fi +} + # build everything in the projects directory PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//') FAILED="" +if (( $WERROR )); then +export WERROR=1 +fi + for p in $PROJECTS; do - PROJECT=$p nice $DIR/make-parallel || FAILED="$FAILED $p" + echo building $p + PROJECT=$p log nice $DIR/make-parallel || FAILED="$FAILED $p" done +if (( $RELEASE )); then +for p in $PROJECTS; do + echo building $p-release + BUILDDIR_SUFFIX=-release DEBUG=0 PROJECT=$p log nice $DIR/make-parallel || FAILED="$FAILED $p-release" +done +fi + if [ "$FAILED" != "" ]; then echo echo some projects have failed to build: