Update git-version generation

This commit is contained in:
Ani 2019-09-17 16:37:14 +01:00
commit 6a0ce010eb

View file

@ -10,13 +10,19 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
OUTPUT_VARIABLE RPCS3_GIT_VERSION) OUTPUT_VARIABLE RPCS3_GIT_VERSION)
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-list failed, unable to include version.") message(WARNING "git rev-list failed, unable to include version.")
else()
string(STRIP ${RPCS3_GIT_VERSION} RPCS3_GIT_VERSION)
endif() endif()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE exit_code RESULT_VARIABLE exit_code2
OUTPUT_VARIABLE GIT_VERSION_) OUTPUT_VARIABLE GIT_VERSION_)
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code2} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include version.") message(WARNING "git rev-parse failed, unable to include version.")
string(STRIP ${GIT_VERSION_} GIT_VERSION_)
if(${exit_code} EQUAL 0)
string(STRIP ${RPCS3_GIT_VERSION}-${GIT_VERSION_} RPCS3_GIT_VERSION)
endif()
endif() endif()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@ -24,6 +30,8 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
OUTPUT_VARIABLE RPCS3_GIT_BRANCH) OUTPUT_VARIABLE RPCS3_GIT_BRANCH)
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include git branch.") message(WARNING "git rev-parse failed, unable to include git branch.")
else()
string(STRIP ${RPCS3_GIT_BRANCH} RPCS3_GIT_BRANCH)
endif() endif()
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@ -31,14 +39,11 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
OUTPUT_VARIABLE RPCS3_GIT_TAG) OUTPUT_VARIABLE RPCS3_GIT_TAG)
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git describe failed, unable to include git tag.") message(WARNING "git describe failed, unable to include git tag.")
endif() else()
string(STRIP ${RPCS3_GIT_TAG} RPCS3_GIT_TAG)
string(STRIP ${RPCS3_GIT_VERSION} RPCS3_GIT_VERSION) string(REPLACE "v" "" RPCS3_GIT_TAG ${RPCS3_GIT_TAG})
string(STRIP ${GIT_VERSION_} GIT_VERSION_) endif()
string(STRIP ${RPCS3_GIT_VERSION}-${GIT_VERSION_} RPCS3_GIT_VERSION)
string(STRIP ${RPCS3_GIT_BRANCH} RPCS3_GIT_BRANCH)
string(STRIP ${RPCS3_GIT_TAG} RPCS3_GIT_TAG)
string(REPLACE "v" "" RPCS3_GIT_TAG ${RPCS3_GIT_TAG})
else() else()
message(WARNING "git not found, unable to include version.") message(WARNING "git not found, unable to include version.")
endif() endif()
@ -69,7 +74,8 @@ function(gen_git_version rpcs3_src_dir)
set(code_string "// This is a generated file.\n\n" set(code_string "// This is a generated file.\n\n"
"#define RPCS3_GIT_VERSION \"${RPCS3_GIT_VERSION}\"\n" "#define RPCS3_GIT_VERSION \"${RPCS3_GIT_VERSION}\"\n"
"#define RPCS3_GIT_BRANCH \"${RPCS3_GIT_BRANCH}\"\n\n" "#define RPCS3_GIT_BRANCH \"${RPCS3_GIT_BRANCH}\"\n"
"#define RPCS3_GIT_TAG \"${RPCS3_GIT_TAG}\"\n\n"
"// If you don't want this file to update/recompile, change to 1.\n" "// If you don't want this file to update/recompile, change to 1.\n"
"#define RPCS3_GIT_VERSION_NO_UPDATE 0\n") "#define RPCS3_GIT_VERSION_NO_UPDATE 0\n")