diff --git a/CMakeLists.txt b/CMakeLists.txt index c86283c33..58afb1758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,9 @@ add_subdirectory(assets) ## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") include(GitUtilities) -git_describe(SRB2_COMP_REVISION "${CMAKE_CURRENT_SOURCE_DIR}") +git_describe(SRB2_GIT_DESCRIBE "${CMAKE_SOURCE_DIR}") +git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") +set(SRB2_COMP_REVISION "${SRB2_GIT_DESCRIBE}-<${SRB2_GIT_BRANCH}>") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) ##### PACKAGE CONFIGURATION ##### diff --git a/cmake/Modules/GitUtilities.cmake b/cmake/Modules/GitUtilities.cmake index de4015b0d..683cf9b6b 100644 --- a/cmake/Modules/GitUtilities.cmake +++ b/cmake/Modules/GitUtilities.cmake @@ -14,9 +14,18 @@ function(git_describe variable path) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - #if(NOT result EQUAL 0) - # set(${variable} "GITERROR-${result}-NOTFOUND" CACHE STRING "revision" FORCE) - #endif() set(${variable} "${output}" PARENT_SCOPE) endfunction() + +function(git_current_branch variable path) + execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD" + WORKING_DIRECTORY "${path}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + set(${variable} "${output}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/src/config.h.in b/src/config.h.in index 7c5b299cf..53747266c 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -12,6 +12,8 @@ #define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}" #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" +#define SRB2_GIT_DESCRIBE "${SRB2_GIT_DESCRIBE}" +#define SRB2_GIT_BRANCH "${SRB2_GIT_BRANCH}" #define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets"