From c912b7319fb204e95e6d97c2c9c182bcaca8f93e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 13 Mar 2018 08:32:48 -0700 Subject: 4219 - add an even simpler build script --- build2 | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'build2') diff --git a/build2 b/build2 index 8cddd67f..881f2702 100755 --- a/build2 +++ b/build2 @@ -1,12 +1,15 @@ #!/bin/sh -# Alternative to build1 that can stop after any step. For example: -# $ ./build2 mu.cc +# Alternative to build1 that tries to avoid redoing redundant work. +# Also splits compilation into multiple .cc files (see 'cleave' below). +# Faster than build1 for recompiling after small changes. +# +# For details on the basic form of this script, see https://notabug.org/akkartik/basic-build. set -e # stop immediately on error # Some environment variables that can be passed in. For example, to turn off # optimization: -# $ CFLAGS=-g ./build0 +# $ CFLAGS=-g ./build2 test "$CXX" || export CXX=c++ test "$CC" || export CC=cc test "$CFLAGS" || export CFLAGS="-g -O3" @@ -17,29 +20,9 @@ export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing" # (layers) | | | | # tangle cleave $CXX $CXX -## arg parsing - -# can be called with a target to stop after a partial build -# $ ./build2 mu.cc # can also be called with a layer to only build until # $ ./build2 --until 050 -# scenarios: -# ./build2 => TARGET= UNTIL_LAYER=zzz -# ./build2 x => TARGET=x UNTIL_LAYER=zzz -# ./build2 --until => TARGET= UNTIL_LAYER=zzz -# ./build2 --until 050 => TARGET= UNTIL_LAYER=050 -TARGET= -UNTIL_LAYER=zzz -if [ $# -ge 1 ] && [ $1 != "--until" ] -then - TARGET=$1 -fi -if [ $# -ge 2 ] && [ $1 = "--until" ] -then - UNTIL_LAYER=$2 -fi - -## +UNTIL_LAYER=${2:-zzz} # there's two mechanisms for fast builds here: # - if a command is quick to run, always run it but update the result only on any change @@ -50,12 +33,9 @@ fi # risk: a file may unnecessarily update without changes, causing unnecessary work downstream # return 1 if $1 is older than _any_ of the remaining args -# also exit the entire script if previous invocation was to update $TARGET older_than() { - test $TARGET && test "$last_target" = "$TARGET" && exit 0 local target=$1 shift - last_target=$target if [ ! -e $target ] then #? echo "$target doesn't exist" @@ -75,7 +55,6 @@ older_than() { } # redirect to $1, unless it's already identical -# no point checking for an early exit, because this usually runs in a pipeline/subshell update() { if [ ! -e $1 ] then @@ -86,11 +65,7 @@ update() { fi } -# cp file $1 to directory $2, unless it's already identical -# also exit the entire script if previous invocation was to update $TARGET update_cp() { - test $TARGET && test "$last_target" = "$TARGET" && exit 0 - last_target=$2/$1 if [ ! -e $2/$1 ] then cp $1 $2 -- cgit 1.4.1-2-gfad0