From b2d598aac5216d715ff8b2b3c82fcefaea2c66d0 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 26 Dec 2018 12:38:15 +1100 Subject: [PATCH] Add $CC and $CXX variables to build-*.sh --- build-all.sh | 13 ++++++++----- build-example.sh | 11 +++++++---- build-fuzz.sh | 5 ++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/build-all.sh b/build-all.sh index af07c7bb..9a8cf390 100755 --- a/build-all.sh +++ b/build-all.sh @@ -33,25 +33,28 @@ # having to separately configure, build or install a library: # # git clone https://github.com/google/wuffs.git -# cd wuffs/example/zcat -# gcc zcat.c -# ./a.out < ../../test/data/romeo.txt.gz +# cd wuffs +# gcc ./example/zcat/zcat.c +# ./a.out < ./test/data/romeo.txt.gz if [ ! -e release/c/wuffs-unsupported-snapshot.c ]; then echo "$0 should be run from the Wuffs root directory." exit 1 fi +CC=${CC:-gcc} +CXX=${CXX:-g++} + go install github.com/google/wuffs/cmd/... go test github.com/google/wuffs/... wuffs gen echo "Checking snapshot compiles cleanly (as C)" -gcc -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c99 \ +$CC -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c99 \ release/c/wuffs-unsupported-snapshot.c -o /dev/null echo "Checking snapshot compiles cleanly (as C++)" -g++ -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c++11 \ +$CXX -c -Wall -Werror -DWUFFS_IMPLEMENTATION -std=c++11 \ release/c/wuffs-unsupported-snapshot.c -o /dev/null wuffs genlib -skipgen diff --git a/build-example.sh b/build-example.sh index 296049e1..052e5f96 100755 --- a/build-example.sh +++ b/build-example.sh @@ -22,6 +22,9 @@ if [ ! -e release/c/wuffs-unsupported-snapshot.c ]; then exit 1 fi +CC=${CC:-gcc} +CXX=${CXX:-g++} + mkdir -p gen/bin sources=$@ @@ -39,19 +42,19 @@ for f in $sources; do if [ $f = crc32 ]; then echo "Building gen/bin/example-$f" # example/crc32 is unusual in that it's C++, not C. - g++ -O3 example/$f/*.cc -o gen/bin/example-$f + $CXX -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 + if [ -e gen/lib/c/$CC-static/libwuffs.a ]; then 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 + $CC -O3 -static -I.. example/$f/*.c gen/lib/c/$CC-static/libwuffs.a -o gen/bin/example-$f else echo "Skipping gen/bin/example-$f; run \"wuffs genlib\" first" fi elif [ -e example/$f/*.c ]; then echo "Building gen/bin/example-$f" - gcc -O3 example/$f/*.c -o gen/bin/example-$f + $CC -O3 example/$f/*.c -o gen/bin/example-$f fi done diff --git a/build-fuzz.sh b/build-fuzz.sh index 48e9ee67..cfddefe5 100755 --- a/build-fuzz.sh +++ b/build-fuzz.sh @@ -22,6 +22,9 @@ if [ ! -e release/c/wuffs-unsupported-snapshot.c ]; then exit 1 fi +CC=${CC:-gcc} +CXX=${CXX:-g++} + mkdir -p gen/bin sources=$@ @@ -38,5 +41,5 @@ for f in $sources; do fi echo "Building gen/bin/fuzz-$f" - gcc -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.c -o gen/bin/fuzz-$f + $CC -DWUFFS_CONFIG__FUZZLIB_MAIN fuzz/c/std/${f}_fuzzer.c -o gen/bin/fuzz-$f done