Update compile script to run tests
This commit is contained in:
parent
0b63bc746d
commit
7fb13f2439
33
compile
33
compile
@ -19,11 +19,18 @@ CC=clang
|
||||
CFLAGS="-Wall -Werror -pedantic "
|
||||
LIBFLAGS="-fPIC -shared"
|
||||
INCLUDE="\
|
||||
$(find src -type d | xargs -I{} echo -n "-I{} ") \
|
||||
$(find src -type d | xargs -I{} echo -n "-I{} ") \
|
||||
"
|
||||
TEST_INCLUDE="\
|
||||
$(find tests -type d | xargs -I{} echo -n "-I{} ") \
|
||||
"
|
||||
SRC="\
|
||||
$(find src -type f -name "*.c" | xargs -I{} echo -n "{} ") \
|
||||
$(find src -type f -name "*.c" | xargs -I{} echo -n "{} ") \
|
||||
"
|
||||
TEST_SRC="\
|
||||
$(find tests -type f -name "*.c" | xargs -I{} echo -n "{} ") \
|
||||
"
|
||||
|
||||
if [[ $BUILD_TYPE == "release" ]]; then
|
||||
CFLAGS+="-O3"
|
||||
else
|
||||
@ -31,9 +38,29 @@ else
|
||||
fi
|
||||
|
||||
OUT="libwapp.so"
|
||||
TEST_OUT="./wapptest"
|
||||
|
||||
# Compile tests
|
||||
if [[ $(echo $TEST_SRC | xargs) != "" ]]; then
|
||||
(set -x ; $CC $CFLAGS $INCLUDE $TEST_INCLUDE $SRC $TEST_SRC -o $TEST_OUT)
|
||||
fi
|
||||
|
||||
# Run tests and exit on failure
|
||||
if [[ -f $TEST_OUT ]]; then
|
||||
$TEST_OUT
|
||||
STATUS="$?"
|
||||
|
||||
rm $TEST_OUT
|
||||
|
||||
if [[ $STATUS != "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Compile library
|
||||
(set -x ; $CC $CFLAGS $LIBFLAGS $INCLUDE $SRC -o $OUT)
|
||||
|
||||
# Compile test.c if it exists
|
||||
if [[ -f ./test.c ]]; then
|
||||
(set -x ; $CC $CFLAGS $INCLUDE $SRC ./test.c -o test)
|
||||
(set -x ; $CC $CFLAGS $INCLUDE $SRC ./test.c -o test)
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user