From 38e2411f04e3ade11c207f0a9868cad9008ea052 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 5 Sep 2023 04:47:23 +0200 Subject: Update build script --- build_and_test.sh | 75 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 16 deletions(-) (limited to 'build_and_test.sh') diff --git a/build_and_test.sh b/build_and_test.sh index 95efbe7..70960ae 100644 --- a/build_and_test.sh +++ b/build_and_test.sh @@ -2,17 +2,60 @@ if [ ! -d "build" ]; then mkdir build fi -gcc -c -o "build/kit.o" "source/kit/_static.c" -ar rcs "build/libkit.a" "build/kit.o" +COMPILE=gcc +COMPILEPP=g++ +OBJ_POSTFIX=.o +EXE_POSTFIX= -gcc -c -o "build/kit_test.o" "source/kit_test/_static.c" -ar rcs "build/libkit_test.a" "build/kit_test.o" +if command -v gcc >/dev/null 2>&1; then + echo "C compiler found - GCC" +elif command -v cl.exe >/dev/null 2>&1; then + echo "C compiler found - MSVC" + COMPILE=cl.exe + COMPILEPP=cl.exe + OBJ_POSTFIX=.obj + EXE_POSTFIX=.exe +elif command -v clang >/dev/null 2>&1; then + echo "C compiler found - Clang" + COMPILE=clang + COMPILEPP=clang +else + echo "C compiler not found" + exit +fi + +echo "" + +$COMPILE -c -o "build/kit${OBJ_POSTFIX}" "source/kit/_static.c" +$COMPILE -c -o "build/kit_test${OBJ_POSTFIX}" "source/kit_test/_static.c" + +$COMPILE -o "build/kit_test_suite${EXE_POSTFIX}" \ + "build/kit${OBJ_POSTFIX}" \ + "build/kit_test${OBJ_POSTFIX}" \ + "source/tests/_static.c" + +$COMPILE -o "build/test_too_many_assertions${EXE_POSTFIX}" \ + "build/kit${OBJ_POSTFIX}" \ + "build/kit_test${OBJ_POSTFIX}" \ + "source/tests/test_too_many_assertions.c" + +$COMPILE -o "build/test_too_many_tests${EXE_POSTFIX}" \ + "build/kit${OBJ_POSTFIX}" \ + "build/kit_test${OBJ_POSTFIX}" \ + "source/tests/test_too_many_tests.c" + +$COMPILEPP -o "build/test_cpp${EXE_POSTFIX}" \ + "build/kit${OBJ_POSTFIX}" \ + "build/kit_test${OBJ_POSTFIX}" \ + "source/tests/test_cpp.cpp" + +$COMPILEPP -o "build/test_signals${EXE_POSTFIX}" \ + "build/kit${OBJ_POSTFIX}" \ + "build/kit_test${OBJ_POSTFIX}" \ + "source/tests/test_signals.cpp" -gcc -o "build/kit_test_suite" "source/tests/_static.c" -Lbuild -lkit -lkit_test -gcc -o "build/test_too_many_assertions" "source/tests/test_too_many_assertions.c" -Lbuild -lkit -lkit_test -gcc -o "build/test_too_many_tests" "source/tests/test_too_many_tests.c" -Lbuild -lkit -lkit_test -g++ -o "build/test_cpp" "source/tests/test_cpp.cpp" -Lbuild -lkit -lkit_test -g++ -o "build/test_signals" "source/tests/test_signals.cpp" -Lbuild -lkit -lkit_test +echo "Run tests" +echo "" ./build/kit_test_suite @@ -20,27 +63,27 @@ g++ -o "build/test_signals" "source/tests/test_signals.cpp" -Lbuild -lkit -lkit_ if [ $? -eq 0 ]; then echo "too many assertions - OK" else - echo "too many assertions - FAIL" + echo "too many assertions - FAILED (code $?)" fi ./build/test_too_many_tests --quiet if [ $? -eq 0 ]; then - echo "too many tests - OK" + echo "too many tests - OK" else - echo "too many tests - FAIL" + echo "too many tests - FAILED (code $?)" fi ./build/test_cpp --quiet if [ $? -eq 0 ]; then - echo "cpp - OK" + echo "cpp - OK" else - echo "cpp - FAIL" + echo "cpp - FAILED (code $?)" fi ./build/test_signals --quiet if [ $? -eq 0 ]; then - echo "signals - OK" + echo "signals - OK" else - echo "signals - FAIL" + echo "signals - FAILED (code $?)" fi -- cgit v1.2.3