Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Buildsystem: Added current branch name to generated revision info

  • Loading branch information...
commit fff23c4f17429d977e6bd38901bc0ae459f3bacd 1 parent 9301e31
@Shauren Shauren authored
Showing with 18 additions and 6 deletions.
  1. +16 −5 cmake/genrev.cmake
  2. +2 −1  revision.h.in.cmake
View
21 cmake/genrev.cmake
@@ -20,7 +20,8 @@ endif()
if(NO_GIT)
set(rev_date "1970-01-01 00:00:00 +0000")
- set(rev_hash "Archived")
+ set(rev_hash "unknown")
+ set(rev_branch "Archived")
else()
if(GIT_EXEC)
# Create a revision-string that we can use
@@ -40,18 +41,27 @@ else()
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
+
+ # Also retrieve branch name
+ execute_process(
+ COMMAND "${GIT_EXEC}" rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE rev_branch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
endif()
# Last minute check - ensure that we have a proper revision
# If everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag)
-
if(NOT rev_info)
# No valid ways available to find/set the revision/hash, so let's force some defaults
message(STATUS "
Could not find a proper repository signature (hash) - you may need to pull tags with git fetch -t
- Continuing anyway - note that the versionstring will be set to 1970-01-01 00:00:00 (Archived)")
+ Continuing anyway - note that the versionstring will be set to \"unknown 1970-01-01 00:00:00 (Archived)"\")
set(rev_date "1970-01-01 00:00:00 +0000")
- set(rev_hash "Archived")
+ set(rev_hash "unknown")
+ set(rev_branch "Archived")
else()
# Extract information required to build a proper versionstring
string(REGEX REPLACE init-|[0-9]+-g "" rev_hash ${rev_info})
@@ -59,11 +69,12 @@ else()
endif()
# Create the actual revision.h file from the above params
-if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}")
+if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}")
configure_file(
"${CMAKE_SOURCE_DIR}/revision.h.in.cmake"
"${BUILDDIR}/revision.h"
@ONLY
)
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
+ set(rev_branch_cached "${rev_branch}" CACHE INTERNAL "Cached branch name")
endif()
View
3  revision.h.in.cmake
@@ -2,10 +2,11 @@
#define __REVISION_H__
#define _HASH "@rev_hash@"
#define _DATE "@rev_date@"
+ #define _BRANCH "@rev_branch@"
#define VER_COMPANYNAME_STR "TrinityCore Developers"
#define VER_LEGALCOPYRIGHT_STR "(c)2008-2013 TrinityCore"
#define VER_FILEVERSION 0,0,0
- #define VER_FILEVERSION_STR "@rev_date@ (@rev_hash@)"
+ #define VER_FILEVERSION_STR "@rev_hash@ @rev_date@ (@rev_branch@ branch)"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
#endif // __REVISION_H__
Please sign in to comment.
Something went wrong with that request. Please try again.