mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
BuildSystem: Add another revision.h setup "test-clause" (in case someone doesn't have a .hg dir or .hg_archival.txt)
- Set revision-ID to 0, and revision-hash to "Unknown archive", if an id/hash can not be properly detected. This should never happen unless the user has -deliberately deleted- the .hg directory and/or the .hg_archival.txt, or does not have the hg command in their command-path --HG-- branch : trunk
This commit is contained in:
@@ -58,7 +58,6 @@ if( UNIX )
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt)
|
||||
set(hg_rev_id_str "Archive")
|
||||
file(READ
|
||||
${CMAKE_SOURCE_DIR}/.hg_archival.txt hg_rev_hash_str
|
||||
LIMIT 10
|
||||
@@ -67,9 +66,9 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt)
|
||||
)
|
||||
string(STRIP ${hg_rev_id_str} hg_rev_id_str)
|
||||
string(STRIP ${hg_rev_hash_str} hg_rev_hash_str)
|
||||
set(hg_rev_id_str "Archive")
|
||||
set(hg_rev_id "0")
|
||||
set(hg_rev_hash ${hg_rev_hash_str})
|
||||
|
||||
else()
|
||||
# Find revision ID and hash of the sourcetree
|
||||
execute_process(
|
||||
@@ -77,20 +76,32 @@ else()
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE hg_rev_id_str
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
execute_process(
|
||||
COMMAND hg id -i
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE hg_rev_hash_str
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
# Strip off excess strings (shows when the source is actually modified)
|
||||
string(REPLACE "+" "" hg_rev_id ${hg_rev_id_str})
|
||||
string(REPLACE "+" "" hg_rev_hash ${hg_rev_hash_str})
|
||||
endif()
|
||||
|
||||
# Last minute check - ensure that we have a proper revision
|
||||
# If everything above fails (means the user has erased the mercurial revisional control directory, or runs archive and erased their .hg_archival.txt)
|
||||
if(NOT hg_rev_id_str)
|
||||
message("")
|
||||
message(STATUS "WARNING - No revision-information found - have you been tampering with the sources?")
|
||||
|
||||
# Ok, since we have no valid ways of finding/setting the revision, let's force some defaults
|
||||
set(hg_rev_id_str "0")
|
||||
set(hg_rev_id "0")
|
||||
set(hg_rev_hash_str "Unknown archive")
|
||||
set(hg_rev_hash "0")
|
||||
endif()
|
||||
|
||||
# Strip off excess strings (shows when the source is actually modified)
|
||||
string(REPLACE "+" "" hg_rev_id ${hg_rev_id_str})
|
||||
string(REPLACE "+" "" hg_rev_hash ${hg_rev_hash_str})
|
||||
|
||||
# Create the actual revision.h file from the above params
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/revision.h.in.cmake"
|
||||
|
||||
Reference in New Issue
Block a user