forked from Mirrors/openclonk
Prepare build for Git repository
This includes fetching the build revision from git instead of hg and adding a file to store the revision hash in archives.floating-point
parent
f13df38ec1
commit
94225e8de5
|
@ -0,0 +1 @@
|
|||
node: $Format:%H$
|
|
@ -0,0 +1,3 @@
|
|||
.git_archival export-subst
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
|
@ -1,5 +1,3 @@
|
|||
syntax: glob
|
||||
|
||||
autom4te.cache
|
||||
*~
|
||||
*.bak
|
18
Version.txt
18
Version.txt
|
@ -22,22 +22,10 @@ SET(C4VERSIONBUILDNAME " Beyond the Rocks")
|
|||
SET(C4VERSIONEXTRA " Delta")
|
||||
|
||||
############################################################################
|
||||
# Get revision from Mercurial
|
||||
# Get revision from Git
|
||||
############################################################################
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.hg_archival.txt")
|
||||
# Archives generated by hg archive
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.hg_archival.txt" C4REVISION
|
||||
LIMIT_COUNT 1
|
||||
REGEX "node: [0-9a-f]+"
|
||||
)
|
||||
string(SUBSTRING "${C4REVISION}" 6 12 C4REVISION)
|
||||
else()
|
||||
# Working copies
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND "hg" "id" "--id"
|
||||
OUTPUT_VARIABLE C4REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
include(GitGetChangesetID)
|
||||
git_get_changeset_id(C4REVISION)
|
||||
|
||||
############################################################################
|
||||
# Get year
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
function(git_get_changeset_id VAR)
|
||||
find_package(Git QUIET)
|
||||
if (GIT_FOUND)
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND "${GIT_EXECUTABLE}" "rev-parse" "HEAD"
|
||||
RESULT_VARIABLE GIT_RESULT
|
||||
OUTPUT_VARIABLE C4REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET)
|
||||
|
||||
if(GIT_RESULT EQUAL 0)
|
||||
string(SUBSTRING "${C4REVISION}" 0 12 C4REVISION)
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND "${GIT_EXECUTABLE}" "status" "--porcelain"
|
||||
OUTPUT_VARIABLE GIT_STATUS
|
||||
)
|
||||
string(REGEX MATCH "^[MADRC ][MD ]" WORKDIR_DIRTY "${GIT_STATUS}")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT C4REVISION)
|
||||
# Git not found or not a git workdir
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.git_archival" C4REVISION
|
||||
LIMIT_COUNT 1
|
||||
REGEX "node: [0-9a-f]+"
|
||||
)
|
||||
string(SUBSTRING "${C4REVISION}" 6 12 C4REVISION)
|
||||
endif()
|
||||
if(WORKDIR_DIRTY)
|
||||
set(C4REVISION "${C4REVISION}+")
|
||||
endif()
|
||||
set(${VAR} "${C4REVISION}" PARENT_SCOPE)
|
||||
endfunction()
|
Loading…
Reference in New Issue