2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 01:47:45 +01:00

Query git and set XASH_BUILD_COMMIT and XASH_BUILD_BRANCH macros

This commit is contained in:
Alibek Omarov 2024-04-02 19:45:17 +03:00 committed by Andrey Akhmichin
parent 3341bfc1b9
commit f2a49073bb
2 changed files with 23 additions and 1 deletions

View File

@ -88,6 +88,24 @@ endif()
# MAIN BUILD CODE \ # MAIN BUILD CODE \
###################\ ###################\
execute_process(COMMAND "git" "describe" "--dirty" "--always"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GIT_VERSION)
add_definitions(-DXASH_BUILD_COMMIT="${GIT_VERSION}")
endif()
if(GIT_BRANCH)
add_definitions(-DXASH_BUILD_BRANCH="${GIT_BRANCH}")
endif()
file(STRINGS "mod_options.txt" MOD_OPTIONS_STRINGS REGEX "^([A-Za-z0-9_-]+)=([A-Za-z0-9_-]+)\ \#\ (.*)$") file(STRINGS "mod_options.txt" MOD_OPTIONS_STRINGS REGEX "^([A-Za-z0-9_-]+)=([A-Za-z0-9_-]+)\ \#\ (.*)$")
foreach(LINE IN LISTS MOD_OPTIONS_STRINGS) foreach(LINE IN LISTS MOD_OPTIONS_STRINGS)
# file() itself doesn't populate CMAKE_MATCH_<n>, so # file() itself doesn't populate CMAKE_MATCH_<n>, so

View File

@ -55,7 +55,11 @@ def configure(conf):
if conf.env.COMPILER_CC == 'msvc': if conf.env.COMPILER_CC == 'msvc':
conf.load('msvc_pdb') conf.load('msvc_pdb')
conf.load('msvs msdev subproject clang_compilation_database strip_on_install enforce_pic') conf.load('msvs msdev subproject clang_compilation_database strip_on_install enforce_pic gitversion')
if conf.env.GIT_VERSION:
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION)
if conf.env.GIT_BRANCH:
conf.define('XASH_BUILD_BRANCH', conf.env.GIT_BRANCH)
enforce_pic = True # modern defaults enforce_pic = True # modern defaults
conf.check_pic(enforce_pic) conf.check_pic(enforce_pic)