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 --- TODO | 2 ++ build_and_test.sh | 105 +++++++++++++++++++++++++++++++++++------------------- include/kit.inl.h | 6 +++- 3 files changed, 76 insertions(+), 37 deletions(-) diff --git a/TODO b/TODO index 7bd2bde..82e2b3f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ To-Do +- Build with GCC on Windows + - Cryptography - hmac_sha256 https://github.com/h5p9sl/hmac_sha256 - ecdh https://github.com/kokke/tiny-ECDH-c 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 diff --git a/include/kit.inl.h b/include/kit.inl.h index 06eaafd..c1c054c 100644 --- a/include/kit.inl.h +++ b/include/kit.inl.h @@ -339,6 +339,9 @@ uint64_t kit_atomic_fetch_add_explicit_64(uint64_t volatile *var, # define _GNU_SOURCE # endif # include +# ifndef TIME_UTC +# define TIME_UTC 1 +# endif # if !defined(_WIN32) || defined(__CYGWIN__) # include # endif @@ -2797,11 +2800,12 @@ void kit_ib_destroy(kit_ib_handle_t buf) { #include enum { PATH_BUF_SIZE = 4096 }; #if defined(_WIN32) && !defined(__CYGWIN__) +# include # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif -# include # include +# include #else # include # include -- cgit v1.2.3