From 10ae70448fe9e7d86bff850229910287551069d0 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 18 Aug 2018 12:13:36 +1000 Subject: [PATCH] Let build scripts take "example/*" arguments --- build-all.sh | 5 +++++ build-example.sh | 38 +++++++++++++++++++++++++++++--------- build-fuzz.sh | 25 ++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/build-all.sh b/build-all.sh index 1b997e76..4e93a565 100755 --- a/build-all.sh +++ b/build-all.sh @@ -37,6 +37,11 @@ # gcc zcat.c # ./a.out < ../../test/data/romeo.txt.gz +if [ ! -e release/c/wuffs-unsupported-snapshot.h ]; then + echo "$0 should be run from the Wuffs root directory." + exit 1 +fi + go install github.com/google/wuffs/cmd/... go test github.com/google/wuffs/... wuffs gen diff --git a/build-example.sh b/build-example.sh index 02905e89..c998b9b6 100755 --- a/build-example.sh +++ b/build-example.sh @@ -17,21 +17,41 @@ # See build-all.sh for commentary. -for f in example/*; do - echo "Building $f" - if [ "$f" = "example/crc32" ]; then +if [ ! -e release/c/wuffs-unsupported-snapshot.h ]; then + echo "$0 should be run from the Wuffs root directory." + exit 1 +fi + +mkdir -p gen/bin + +sources=$@ +if [ $# -eq 0 ]; then + sources=example/* +fi + +for f in $sources; do + f=${f%/} + f=${f##*/} + if [ -z $f ]; then + continue + fi + + if [ $f = crc32 ]; then + echo "Building gen/bin/example-$f" # example/crc32 is unusual in that it's C++, not C. - g++ -O3 $f/*.cc -o $f/a.out - elif [ "$f" = "example/library" ]; then + g++ -O3 example/$f/*.cc -o gen/bin/example-$f + elif [ $f = library ]; then # example/library is unusual in that it uses separately compiled libraries # (built by "wuffs genlib", e.g. by running build-all.sh) instead of # directly #include'ing Wuffs' .c files. if [ -e gen/lib/c/gcc-static/libwuffs.a ]; then - gcc -O3 -static -I.. $f/*.c gen/lib/c/gcc-static/libwuffs.a -o $f/a.out + echo "Building gen/bin/example-$f" + gcc -O3 -static -I.. example/$f/*.c gen/lib/c/gcc-static/libwuffs.a -o gen/bin/example-$f else - echo " Skipping example/library; run \"wuffs genlib\" first" + echo "Skipping gen/bin/example-$f; run \"wuffs genlib\" first" fi - elif [ -e $f/*.c ]; then - gcc -O3 $f/*.c -o $f/a.out + elif [ -e example/$f/*.c ]; then + echo "Building gen/bin/example-$f" + gcc -O3 example/$f/*.c -o gen/bin/example-$f fi done diff --git a/build-fuzz.sh b/build-fuzz.sh index 33363cd8..950c82d7 100755 --- a/build-fuzz.sh +++ b/build-fuzz.sh @@ -17,7 +17,26 @@ # See build-all.sh for commentary. -for f in fuzz/c/std/*_fuzzer.c; do - echo "Building $f" - gcc -DWUFFS_CONFIG__FUZZLIB_MAIN $f -o ${f%.c}.out +if [ ! -e release/c/wuffs-unsupported-snapshot.h ]; then + echo "$0 should be run from the Wuffs root directory." + exit 1 +fi + +mkdir -p gen/bin + +sources=$@ +if [ $# -eq 0 ]; then + sources=fuzz/c/std/*_fuzzer.c +fi + +for f in $sources; do + f=${f%_fuzzer.c} + f=${f%/} + f=${f##*/} + if [ -z $f ]; then + continue + fi + echo "Building gen/bin/fuzz-$f" + + gcc -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.c -o gen/bin/fuzz-$f done