summaryrefslogtreecommitdiff
path: root/build_and_test.sh
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-09-05 06:07:45 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-09-05 06:07:45 +0200
commit6f01f3eb2c5bc6b34d2a33bb4d4eb42704d22db6 (patch)
tree8a04a07c82c7fa2d7974f8c984ab5105cd6cc977 /build_and_test.sh
parentc7934218d7bfcba408b725c41fab1f3d5d890162 (diff)
downloadkit-6f01f3eb2c5bc6b34d2a33bb4d4eb42704d22db6.zip
test
Diffstat (limited to 'build_and_test.sh')
-rw-r--r--build_and_test.sh53
1 files changed, 44 insertions, 9 deletions
diff --git a/build_and_test.sh b/build_and_test.sh
index 5416fa3..f434244 100644
--- a/build_and_test.sh
+++ b/build_and_test.sh
@@ -6,13 +6,14 @@ COMPILE=gcc
COMPILEPP=g++
OBJ_POSTFIX=.o
EXE_POSTFIX=
+FLAGS=
case $(uname | tr '[:upper:]' '[:lower:]') in
*darwin*)
if command -v clang >/dev/null 2>&1; then
echo "C compiler found - Clang"
COMPILE=clang
- COMPILEPP=clang
+ COMPILEPP=clang++
elif command -v gcc >/dev/null 2>&1; then
echo "C compiler found - GCC"
else
@@ -21,11 +22,22 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
fi
;;
*msys*|*cygwin*|*mingw*|*nt*|*win*)
- echo "C compiler found - MSVC"
- COMPILE=cl.exe
- COMPILEPP=cl.exe
- OBJ_POSTFIX=.obj
- EXE_POSTFIX=.exe
+ if 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 gcc >/dev/null 2>&1; then
+ echo "C compiler found - GCC"
+ 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 1
+ fi
;;
*)
if command -v gcc >/dev/null 2>&1; then
@@ -33,7 +45,7 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
elif command -v clang >/dev/null 2>&1; then
echo "C compiler found - Clang"
COMPILE=clang
- COMPILEPP=clang
+ COMPILEPP=clang++
else
echo "C compiler not found"
exit 1
@@ -43,17 +55,36 @@ esac
echo ""
-$COMPILE -c -o "build/kit${OBJ_POSTFIX}" "source/kit/_static.c"
+if [ "$COMPILE" = "gcc" ] || [ "$COMPILE" = "clang" ]; then
+ if [ "$1" = "release" ]; then
+ FLAGS="-O3"
+ else
+ FLAGS="-O0 -fsanitize=undefined,address,leak"
+ fi
+else
+ if [ "$1" = "release" ]; then
+ FLAGS="\O2"
+ else
+ FLAGS="\Od"
+ fi
+fi
+
+$COMPILE -c -o "build/kit${OBJ_POSTFIX}" \
+ ${FLAGS} \
+ "source/kit/_static.c"
if [ ! $? -eq 0 ]; then
exit 1
fi
-$COMPILE -c -o "build/kit_test${OBJ_POSTFIX}" "source/kit_test/_static.c"
+$COMPILE -c -o "build/kit_test${OBJ_POSTFIX}" \
+ ${FLAGS} \
+ "source/kit_test/_static.c"
if [ ! $? -eq 0 ]; then
exit 1
fi
$COMPILE -o "build/kit_test_suite${EXE_POSTFIX}" \
+ ${FLAGS} \
"build/kit${OBJ_POSTFIX}" \
"build/kit_test${OBJ_POSTFIX}" \
"source/tests/_static.c"
@@ -62,6 +93,7 @@ if [ ! $? -eq 0 ]; then
fi
$COMPILE -o "build/test_too_many_assertions${EXE_POSTFIX}" \
+ ${FLAGS} \
"build/kit${OBJ_POSTFIX}" \
"build/kit_test${OBJ_POSTFIX}" \
"source/tests/test_too_many_assertions.c"
@@ -70,6 +102,7 @@ if [ ! $? -eq 0 ]; then
fi
$COMPILE -o "build/test_too_many_tests${EXE_POSTFIX}" \
+ ${FLAGS} \
"build/kit${OBJ_POSTFIX}" \
"build/kit_test${OBJ_POSTFIX}" \
"source/tests/test_too_many_tests.c"
@@ -78,6 +111,7 @@ if [ ! $? -eq 0 ]; then
fi
$COMPILEPP -o "build/test_cpp${EXE_POSTFIX}" \
+ ${FLAGS} \
"build/kit${OBJ_POSTFIX}" \
"build/kit_test${OBJ_POSTFIX}" \
"source/tests/test_cpp.cpp"
@@ -86,6 +120,7 @@ if [ ! $? -eq 0 ]; then
fi
$COMPILEPP -o "build/test_signals${EXE_POSTFIX}" \
+ ${FLAGS} \
"build/kit${OBJ_POSTFIX}" \
"build/kit_test${OBJ_POSTFIX}" \
"source/tests/test_signals.cpp"