Use configure_file to optimize incremental builds for git-describe.h
parent
1226919b16
commit
bc8b8ef256
@ -0,0 +1 @@
|
||||
git-describe.cmake
|
@ -1,37 +0,0 @@
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_COMMIT)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --exact-match
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
RESULT_VARIABLE DFHACK_GIT_TAGGED_RESULT
|
||||
OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
# Check library/xml for matching commits
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD:library/xml
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_XML_EXPECTED_COMMIT)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}/library/xml"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT)
|
||||
|
||||
file(WRITE ${git_describe_tmp_h} "")
|
||||
|
||||
macro(git_describe_definition var)
|
||||
string(STRIP "${${var}}" GIT_DEF_VALUE)
|
||||
file(APPEND ${git_describe_tmp_h} "#define ${var} \"${GIT_DEF_VALUE}\"\n")
|
||||
endmacro()
|
||||
|
||||
git_describe_definition(DFHACK_GIT_DESCRIPTION)
|
||||
git_describe_definition(DFHACK_GIT_COMMIT)
|
||||
git_describe_definition(DFHACK_GIT_XML_EXPECTED_COMMIT)
|
||||
git_describe_definition(DFHACK_GIT_XML_COMMIT)
|
||||
git_describe_definition(DFHACK_BUILD_ID)
|
||||
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
|
||||
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
|
||||
endif()
|
||||
if(${DFHACK_GIT_XML_COMMIT} STREQUAL ${DFHACK_GIT_XML_EXPECTED_COMMIT})
|
||||
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_XML_MATCH\n")
|
||||
endif()
|
@ -0,0 +1,33 @@
|
||||
# Generated from git-describe.cmake.in
|
||||
set(DFHACK_BUILD_ID "@DFHACK_BUILD_ID@")
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --exact-match
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
RESULT_VARIABLE DFHACK_GIT_TAGGED
|
||||
OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
# Check library/xml for matching commits
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD:library/xml
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_XML_EXPECTED_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}/library/xml"
|
||||
OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(${DFHACK_GIT_XML_COMMIT} STREQUAL ${DFHACK_GIT_XML_EXPECTED_COMMIT})
|
||||
set(DFHACK_GIT_XML_MATCH TRUE)
|
||||
else()
|
||||
set(DFHACK_GIT_XML_MATCH FALSE)
|
||||
endif()
|
||||
|
||||
configure_file(${dfhack_SOURCE_DIR}/library/include/git-describe.h.in ${dfhack_SOURCE_DIR}/library/include/git-describe.h)
|
@ -1 +1 @@
|
||||
git-describe.*
|
||||
git-describe.h
|
||||
|
@ -0,0 +1,7 @@
|
||||
#cmakedefine DFHACK_GIT_DESCRIPTION "@DFHACK_GIT_DESCRIPTION@"
|
||||
#cmakedefine DFHACK_GIT_COMMIT "@DFHACK_GIT_COMMIT@"
|
||||
#cmakedefine DFHACK_GIT_XML_EXPECTED_COMMIT "@DFHACK_GIT_XML_EXPECTED_COMMIT@"
|
||||
#cmakedefine DFHACK_GIT_XML_COMMIT "@DFHACK_GIT_XML_COMMIT@"
|
||||
#define DFHACK_BUILD_ID "@DFHACK_BUILD_ID@"
|
||||
#cmakedefine DFHACK_GIT_TAGGED
|
||||
#cmakedefine DFHACK_GIT_XML_MATCH
|
Loading…
Reference in New Issue