From dea35ce434458925349a30cedb6a4dc3b9064a61 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 5 Sep 2023 11:22:56 +0200 Subject: Update build scirpt --- build_and_test.sh | 105 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 36 deletions(-) (limited to 'build_and_test.sh') diff --git a/build_and_test.sh b/build_and_test.sh index 627e062..873bacf 100644 --- a/build_and_test.sh +++ b/build_and_test.sh @@ -11,50 +11,83 @@ FLAG_OBJ="-c -o " FLAG_EXE="-o " LINK_FLAGS= +if [ "$2" = "gcc" ]; then + COMPILE=gcc + COMPILEPP=g++ +elif [ "$2" = "clang" ]; then + COMPILE=clang + COMPILEPP=clang++ +elif [ "$2" = "msvc" ]; then + COMPILE=cl.exe + COMPILEPP=cl.exe + OBJ_POSTFIX=.obj + FLAG_OBJ="-c -Fo" + FLAG_EXE="-Fe" + LINK_FLAGS="Shlwapi.lib" +elif [ "$2" != "" ]; then + echo "Unknown C compiler" + exit 1 +fi + +if [ "$2" != "" ]; then + if command -v $COMPILE >/dev/null 2>&1; then + echo "C compiler found" + else + echo "C compiler not found" + exit 1 + fi +fi + 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++ - elif command -v gcc >/dev/null 2>&1; then - echo "C compiler found - GCC" - else - echo "C compiler not found" - exit 1 + if [ "$2" = "" ]; 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 + echo "C compiler not found" + exit 1 + fi fi ;; *msys*|*cygwin*|*mingw*|*nt*|*win*) - 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 - FLAG_OBJ="-c -Fo" - FLAG_EXE="-Fe" - LINK_FLAGS="Shlwapi.lib" - 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 + EXE_POSTFIX=.exe + if [ "$2" = "" ]; 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" + LINK_FLAGS="Shlwapi.lib" + 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 fi ;; *) - if 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 + if [ "$2" = "" ]; then + if 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 fi ;; esac -- cgit v1.2.3