summaryrefslogtreecommitdiff
path: root/build_and_test.sh
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-01-12 19:41:19 +0100
committerMitya Selivanov <automainint@guattari.tech>2024-01-12 19:41:19 +0100
commitfb088bcc96501e3228d3faebdef1d10f119482e2 (patch)
tree55813d2c02029fbc101f3eadf8a9cf8bbcc01fc0 /build_and_test.sh
parent9fe0da76faaecd05d39101adf0e333f5ea1a6729 (diff)
downloadsaw-fb088bcc96501e3228d3faebdef1d10f119482e2.zip
Update build scripts
Diffstat (limited to 'build_and_test.sh')
-rw-r--r--build_and_test.sh50
1 files changed, 26 insertions, 24 deletions
diff --git a/build_and_test.sh b/build_and_test.sh
index ecab8e7..c490be9 100644
--- a/build_and_test.sh
+++ b/build_and_test.sh
@@ -2,10 +2,9 @@
# General build instructions
#
-FOLDER=build_gcc
+FOLDER=out_gcc
OS=Linux
COMPILE=gcc
-COMPILEPP=g++
OBJ_POSTFIX=.o
EXE_POSTFIX=
FLAGS=
@@ -14,24 +13,20 @@ FLAG_EXE="-o "
LINK_FLAGS="-lm -lX11 -lXi -lXcursor -lGL"
if [ "$2" = "gcc" ]; then
- FOLDER=build_gcc
+ FOLDER=out_gcc
COMPILE=gcc
- COMPILEPP=g++
elif [ "$2" = "clang" ]; then
- FOLDER=build_clang
+ FOLDER=out_clang
COMPILE=clang
- COMPILEPP=clang++
elif [ "$2" = "msvc" ]; then
- FOLDER=build_msvc
+ FOLDER=out_msvc
COMPILE=cl.exe
- COMPILEPP=cl.exe
OBJ_POSTFIX=.obj
FLAG_OBJ="-c -Fo"
FLAG_EXE="-Fe"
elif [ "$2" = "emcc" ]; then
- FOLDER=build_emcc
+ FOLDER=out_emcc
COMPILE=emcc
- COMPILEPP=em++
EXE_POSTFIX=.js
LINK_FLAGS="-sFULL_ES3=1"
elif [ "$2" != "" ]; then
@@ -60,7 +55,6 @@ if [ "$COMPILE" != "emcc" ]; then
if command -v clang >/dev/null 2>&1; then
echo "C compiler found - Clang"
COMPILE=clang
- COMPILEPP=clang++
elif command -v gcc >/dev/null 2>&1; then
echo "C compiler found - GCC"
else
@@ -76,7 +70,6 @@ if [ "$COMPILE" != "emcc" ]; then
if command -v cl.exe >/dev/null 2>&1; then
echo "C compiler found - MSVC"
COMPILE=cl.exe
- COMPILEPP=cl.exe
OBJ_POSTFIX=.obj
FLAG_OBJ="-c -Fo"
FLAG_EXE="-Fe"
@@ -85,7 +78,6 @@ if [ "$COMPILE" != "emcc" ]; then
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
@@ -104,7 +96,6 @@ if [ "$COMPILE" != "emcc" ]; then
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
@@ -114,7 +105,7 @@ if [ "$COMPILE" != "emcc" ]; then
esac
fi
-if [ "$COMPILE" = "gcc" ] || [ "$COMPILE" = "clang" ] || [ "$COMPILE" = "emcc" ]; then
+if [ "$COMPILE" = "gcc" ] || [ "$COMPILE" = "emcc" ]; then
if [ "$1" = "release" ]; then
FLAGS="-O3 -DNDEBUG"
elif [ "$COMPILE" = "gcc" ] && [ "$OS" != "Windows" ]; then
@@ -124,6 +115,12 @@ if [ "$COMPILE" = "gcc" ] || [ "$COMPILE" = "clang" ] || [ "$COMPILE" = "emcc" ]
else
FLAGS="-O0"
fi
+elif [ "$COMPILE" = "clang" ]; then
+ if [ "$1" = "release" ]; then
+ FLAGS="-O3 -DNDEBUG"
+ else
+ FLAGS="-O0"
+ fi
else
if [ "$1" = "release" ]; then
FLAGS="-O2 -DNDEBUG"
@@ -137,24 +134,29 @@ if [ ! -d "$FOLDER" ]; then
fi
echo ""
+echo "Compiler options: ${FLAGS}"
+echo "Link options: ${LINK_FLAGS}"
+echo ""
#
# Project-specific instructions
#
-echo "Build saw"
-if [ ! -f "$FOLDER/saw_impl${OBJ_POSTFIX}" ] || \
- [ "source/saw/_impl.c" -nt "$FOLDER/saw_impl${OBJ_POSTFIX}" ]; then
+if [ ! -f "$FOLDER/_dep${OBJ_POSTFIX}" ] || \
+ [ "source/saw/_dep.c" -nt "$FOLDER/_dep${OBJ_POSTFIX}" ]; then
+ echo "Rebuild dependencies"
$COMPILE ${FLAGS} \
- ${FLAG_OBJ}"$FOLDER/saw_impl${OBJ_POSTFIX}" \
- "source/saw/_impl.c"
+ ${FLAG_OBJ}"$FOLDER/_dep${OBJ_POSTFIX}" \
+ "source/saw/_dep.c"
if [ $? -ne 0 ]; then
exit 1
fi
fi
+
+echo "Build saw"
$COMPILE ${FLAGS} \
${FLAG_EXE}"$FOLDER/saw${EXE_POSTFIX}" \
- "$FOLDER/saw_impl${OBJ_POSTFIX}" \
+ "$FOLDER/_dep${OBJ_POSTFIX}" \
"source/saw/_exe.c" \
${LINK_FLAGS}
if [ $? -ne 0 ]; then
@@ -165,9 +167,9 @@ if [ "$COMPILE" = "emcc" ]; then
exit 0
fi
-echo "Build saw_test_suite"
+echo "Build test suite"
$COMPILE ${FLAGS} \
- ${FLAG_EXE}"$FOLDER/saw_test_suite${EXE_POSTFIX}" \
+ ${FLAG_EXE}"$FOLDER/test_suite${EXE_POSTFIX}" \
"source/tests/_exe.c" \
${LINK_FLAGS}
if [ $? -ne 0 ]; then
@@ -179,7 +181,7 @@ echo ""
STATUS=0
-"$FOLDER/saw_test_suite"
+"$FOLDER/test_suite"
if [ $? -ne 0 ]; then
STATUS=1
fi