From f8bfe652630d68d2b41f3cbaf605a6db579a0bd0 Mon Sep 17 00:00:00 2001 From: leak Date: Tue, 28 Dec 2010 20:58:26 -0800 Subject: [PATCH] Buildsystem: Restore revision "ID" generation. Note: As git doesn't provide human readable (or better understandable) revision IDs by itself and we also don't intend to manually update the revision.h file or use funky ID generation tools, this workaround will do the trick for now. To find out your repositories revision ID use: git log --pretty=format:"" origin/HEAD | wc -l --- cmake/genrev.cmake | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/cmake/genrev.cmake b/cmake/genrev.cmake index b3fb4aade2a..14a4fa26a50 100644 --- a/cmake/genrev.cmake +++ b/cmake/genrev.cmake @@ -9,7 +9,8 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. execute_process( - COMMAND hg id -n + COMMAND git log --pretty=format:"" origin/HEAD + COMMAND wc -l WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE rev_id_str OUTPUT_STRIP_TRAILING_WHITESPACE @@ -17,28 +18,15 @@ execute_process( ) execute_process( - COMMAND hg id -i + COMMAND git rev-parse --short=12 HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE rev_hash_str OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) -if(EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt) - file(READ - ${CMAKE_SOURCE_DIR}/.hg_archival.txt rev_hash_str - LIMIT 10 - OFFSET 7 - NEWLINE_CONSUME - ) - string(STRIP ${rev_hash_str} rev_hash_str) - set(rev_id_str "Archive") - set(rev_id "0") - set(rev_hash ${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 everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag) if(NOT rev_id_str) message("") message(STATUS "WARNING - No revision-information found - have you been tampering with the sources?") @@ -48,14 +36,13 @@ if(NOT rev_id_str) set(rev_hash "0") set(rev_id_str "0") set(rev_id "0") +else() + string(STRIP ${rev_hash_str} rev_hash_str) + set(rev_hash ${rev_hash_str}) + string(STRIP ${rev_id_str} rev_id_str) + set(rev_id ${rev_id_str}) endif() -# Strip off excess strings (shows when the source is actually modified) -if(NOT rev_id_str MATCHES "Archive") - string(REPLACE "+" "" rev_id ${rev_id_str}) -endif() -string(REPLACE "+" "" rev_hash ${rev_hash_str}) - # Its not set during initial run if(NOT BUILDDIR) set(BUILDDIR ${CMAKE_BINARY_DIR})