aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.bat3
-rwxr-xr-xbuild_odin.sh9
2 files changed, 10 insertions, 2 deletions
diff --git a/build.bat b/build.bat
index bcb6d4c1a..99c3ad2ee 100644
--- a/build.bat
+++ b/build.bat
@@ -48,8 +48,11 @@ set odin_version_raw="dev-%curr_year%-%curr_month%"
set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\"
+if not exist .git\ goto skip_git_hash
for /f %%i in ('git rev-parse --short HEAD') do set GIT_SHA=%%i
if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\"
+:skip_git_hash
+
if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY
if %release_mode% EQU 0 ( rem Debug
diff --git a/build_odin.sh b/build_odin.sh
index af1efee59..a1cdbd62f 100755
--- a/build_odin.sh
+++ b/build_odin.sh
@@ -6,13 +6,18 @@ set -eu
: ${CXXFLAGS=}
: ${LDFLAGS=}
: ${ODIN_VERSION=dev-$(date +"%Y-%m")}
+: ${GIT_SHA=}
CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"$ODIN_VERSION\""
CXXFLAGS="$CXXFLAGS -std=c++14"
LDFLAGS="$LDFLAGS -pthread -lm -lstdc++"
-GIT_SHA=$(git rev-parse --short HEAD || :)
-if [ "$GIT_SHA" ]; then CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\""; fi
+if [ -d ".git" ]; then
+ GIT_SHA=$(git rev-parse --short HEAD || :)
+ if [ "$GIT_SHA" ]; then
+ CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\""
+ fi
+fi
DISABLED_WARNINGS="-Wno-switch -Wno-macro-redefined -Wno-unused-value"
OS=$(uname)