From 4e3fc354019534f650a929e358e853a7f2055ee5 Mon Sep 17 00:00:00 2001 From: withmorten Date: Wed, 23 Jun 2021 20:50:02 +0200 Subject: [PATCH] add no-git-hash option to premake --- premake5.lua | 23 ++++++++++++++++++++--- src/CMakeLists.txt | 1 + src/core/config.h | 3 ++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/premake5.lua b/premake5.lua index 531f92ea..578f9d89 100644 --- a/premake5.lua +++ b/premake5.lua @@ -27,6 +27,11 @@ newoption { description = "Build with opus" } +newoption { + trigger = "no-git-hash", + description = "Don't print git commit hash into binary" +} + newoption { trigger = "lto", description = "Use link time optimization" @@ -253,7 +258,11 @@ project "reVC" files { addSrcFiles("src/vehicles") } files { addSrcFiles("src/weapons") } files { addSrcFiles("src/extras") } - files { "src/extras/GitSHA1.cpp" } -- this won't be in repo in first build + if(not _OPTIONS["no-git-hash"]) then + files { "src/extras/GitSHA1.cpp" } -- this won't be in repo in first build + else + removefiles { "src/extras/GitSHA1.cpp" } -- but it will be everytime after + end includedirs { "src" } includedirs { "src/animation" } @@ -278,6 +287,10 @@ project "reVC" includedirs { "src/vehicles" } includedirs { "src/weapons" } includedirs { "src/extras" } + + if(not _OPTIONS["no-git-hash"]) then + defines { "USE_OUR_VERSIONING" } + end if _OPTIONS["with-opus"] then includedirs { "vendor/ogg/include" } @@ -318,10 +331,14 @@ project "reVC" -- external librw is dynamic staticruntime "on" end - prebuildcommands { '"%{prj.location}..\\printHash.bat" "%{prj.location}..\\src\\extras\\GitSHA1.cpp"' } + if(not _OPTIONS["no-git-hash"]) then + prebuildcommands { '"%{prj.location}..\\printHash.bat" "%{prj.location}..\\src\\extras\\GitSHA1.cpp"' } + end filter "platforms:not win*" - prebuildcommands { '"%{prj.location}/../printHash.sh" "%{prj.location}/../src/extras/GitSHA1.cpp"' } + if(not _OPTIONS["no-git-hash"]) then + prebuildcommands { '"%{prj.location}/../printHash.sh" "%{prj.location}/../src/extras/GitSHA1.cpp"' } + end filter "platforms:win*glfw*" staticruntime "off" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c8ab281..28090d7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,7 @@ if(LIBRW_PLATFORM_D3D9) endif() target_compile_definitions(${EXECUTABLE} PRIVATE CMAKE_BUILD) +target_compile_definitions(${EXECUTABLE} PRIVATE USE_OUR_VERSIONING) if(${PROJECT}_AUDIO STREQUAL "OAL") find_package(OpenAL REQUIRED) diff --git a/src/core/config.h b/src/core/config.h index 006ebad5..1c1d1985 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -195,7 +195,8 @@ enum Config { #define DRAW_GAME_VERSION_TEXT #ifdef DRAW_GAME_VERSION_TEXT // unlike R* development builds, ours has runtime switch on debug menu & .ini, and disabled as default. - #define USE_OUR_VERSIONING // If you disable this then game will fetch version from peds.col, as R* did while in development + // If you disable this then game will fetch version from peds.col, as R* did while in development. + //#define USE_OUR_VERSIONING // enabled from buildfiles by default #endif // Memory allocation and compression