forked from Mirrors/openclonk
Add git branch to C4Version.h
The branch information is necessary for upcoming automatically-updating snapshots. For Travis, cmake will also pick up the branch name from the C4REVISION_BRANCH environment variable.master
parent
7616fa81be
commit
55c34ecbd7
|
@ -56,6 +56,7 @@ install:
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export CXX="$CXXCOMPILER" CC="$CCOMPILER"
|
- export CXX="$CXXCOMPILER" CC="$CCOMPILER"
|
||||||
|
- export C4REVISION_BRANCH="$TRAVIS_BRANCH"
|
||||||
- >
|
- >
|
||||||
cmake
|
cmake
|
||||||
-G"${BSYS/\#*/}"
|
-G"${BSYS/\#*/}"
|
||||||
|
|
|
@ -42,6 +42,19 @@ function(git_get_changeset_id VAR)
|
||||||
OUTPUT_VARIABLE GIT_TIMESTAMP
|
OUTPUT_VARIABLE GIT_TIMESTAMP
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
if(DEFINED ENV{C4REVISION_BRANCH})
|
||||||
|
set(GIT_BRANCH "$ENV{C4REVISION_BRANCH}")
|
||||||
|
else()
|
||||||
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" "symbolic-ref" "--short" "HEAD"
|
||||||
|
RESULT_VARIABLE GIT_RESULT
|
||||||
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if(NOT GIT_RESULT EQUAL 0)
|
||||||
|
set(GIT_BRANCH "unknown")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if (NOT C4REVISION)
|
if (NOT C4REVISION)
|
||||||
|
@ -64,6 +77,7 @@ function(git_get_changeset_id VAR)
|
||||||
REGEX "date: .+"
|
REGEX "date: .+"
|
||||||
)
|
)
|
||||||
string(SUBSTRING "${C4REVISION_TS}" 6 -1 GIT_TIMESTAMP)
|
string(SUBSTRING "${C4REVISION_TS}" 6 -1 GIT_TIMESTAMP)
|
||||||
|
set(GIT_BRANCH "unknown")
|
||||||
endif()
|
endif()
|
||||||
if(WORKDIR_DIRTY)
|
if(WORKDIR_DIRTY)
|
||||||
set(WORKDIR_DIRTY 1)
|
set(WORKDIR_DIRTY 1)
|
||||||
|
@ -71,4 +85,5 @@ function(git_get_changeset_id VAR)
|
||||||
set(${VAR} "${C4REVISION}" PARENT_SCOPE)
|
set(${VAR} "${C4REVISION}" PARENT_SCOPE)
|
||||||
set(${VAR}_DIRTY ${WORKDIR_DIRTY} PARENT_SCOPE)
|
set(${VAR}_DIRTY ${WORKDIR_DIRTY} PARENT_SCOPE)
|
||||||
set(${VAR}_TS "${GIT_TIMESTAMP}" PARENT_SCOPE)
|
set(${VAR}_TS "${GIT_TIMESTAMP}" PARENT_SCOPE)
|
||||||
|
set(${VAR}_BRANCH "${GIT_BRANCH}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define C4REVISION "@C4REVISION@"
|
#define C4REVISION "@C4REVISION@"
|
||||||
#define C4REVISION_TS "@C4REVISION_TS@"
|
#define C4REVISION_TS "@C4REVISION_TS@"
|
||||||
#endif
|
#endif
|
||||||
|
#define C4REVISION_BRANCH "@C4REVISION_BRANCH@"
|
||||||
|
|
||||||
// Build Options
|
// Build Options
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
Loading…
Reference in New Issue