diff --git a/build.bat b/build.bat index b7537fba6..cee679773 100644 --- a/build.bat +++ b/build.bat @@ -51,7 +51,10 @@ 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 +for /f "tokens=1,2" %%i IN ('git show "--pretty=%%cd %%h" "--date=format:%%Y-%%m" --no-patch --no-notes HEAD') do ( + set odin_version_raw=%%i + set GIT_SHA=%%j +) if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\" :skip_git_hash diff --git a/build_odin.sh b/build_odin.sh index 9b90a80e2..31fe4d54c 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -8,17 +8,20 @@ set -eu : ${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++" -if [ -d ".git" ]; then - GIT_SHA=$(git rev-parse --short HEAD || :) - if [ "$GIT_SHA" ]; then +if [ -d ".git" ] && [ $(which git) ]; then + versionTag=( $(git show --pretty='%cd %h' --date=format:%Y-%m --no-patch --no-notes HEAD) ) + if [ $? -eq 0 ]; then + ODIN_VERSION="${versionTag[0]}" + GIT_SHA="${versionTag[1]}" CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\"" fi fi +CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"$ODIN_VERSION\"" + DISABLED_WARNINGS="-Wno-switch -Wno-macro-redefined -Wno-unused-value" OS=$(uname)