Permalink
Browse files

CMake: Add date of commit to logfile

But only if the build is from a clean index. Otherwise, the logfile will
contain the date of build.
  • Loading branch information...
isilkor committed Apr 12, 2017
1 parent 9460817 commit bc5df7f35bf2f9e160a4739fbd96da584893cb55
Showing with 23 additions and 2 deletions.
  1. +1 −0 .git_archival
  2. +14 −1 cmake/GitGetChangesetID.cmake
  3. +7 −0 src/C4Version.h.in
  4. +1 −1 src/game/C4Application.cpp
View
@@ -1 +1,2 @@
node: $Format:%H$
date: $Format:%ci$
@@ -37,6 +37,11 @@ function(git_get_changeset_id VAR)
APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${GIT_INDEX}"
)
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "${GIT_EXECUTABLE}" "show" "--format=%ci" "-s" "HEAD"
OUTPUT_VARIABLE GIT_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
if (NOT C4REVISION)
@@ -53,9 +58,17 @@ function(git_get_changeset_id VAR)
string(SUBSTRING "${C4REVISION}" 6 12 C4REVISION)
endif()
unset(revlength)
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.git_archival" C4REVISION_TS
LIMIT_COUNT 1
REGEX "date: .+"
)
string(SUBSTRING "${C4REVISION_TS}" 6 -1 GIT_TIMESTAMP)
endif()
if(WORKDIR_DIRTY)
set(C4REVISION "${C4REVISION}+")
set(WORKDIR_DIRTY 1)
endif()
set(${VAR} "${C4REVISION}" PARENT_SCOPE)
set(${VAR}_DIRTY ${WORKDIR_DIRTY} PARENT_SCOPE)
set(${VAR}_TS "${GIT_TIMESTAMP}" PARENT_SCOPE)
endfunction()
View
@@ -32,7 +32,14 @@
#define C4XVER1 @C4XVER1@
#define C4XVER2 @C4XVER2@
#cmakedefine01 C4REVISION_DIRTY
#if C4REVISION_DIRTY
#define C4REVISION "@C4REVISION@+"
#define C4REVISION_TS __DATE__ " " __TIME__
#else
#define C4REVISION "@C4REVISION@"
#define C4REVISION_TS "@C4REVISION_TS@"
#endif
// Build Options
#ifdef _DEBUG
@@ -104,7 +104,7 @@ bool C4Application::DoInit(int argc, char * argv[])
// Engine header message
Log(C4ENGINECAPTION);
LogF("Version: %s %s (%s)", C4VERSION, C4_OS, GetRevision());
LogF("Version: %s %s (%s - %s)", C4VERSION, C4_OS, GetRevision(), C4REVISION_TS);
LogF("ExePath: \"%s\"", Config.General.ExePath.getData());
LogF("SystemDataPath: \"%s\"", Config.General.SystemDataPath);
LogF("UserDataPath: \"%s\"", Config.General.UserDataPath);

0 comments on commit bc5df7f

Please sign in to comment.