diff options
author | Tor Didriksen <tor.didriksen@oracle.com> | 2014-11-17 15:26:33 +0100 |
---|---|---|
committer | Tor Didriksen <tor.didriksen@oracle.com> | 2014-11-17 15:26:33 +0100 |
commit | 22d684dcc33c33873c7521c4b132c57b5080d9d4 (patch) | |
tree | 14a49b0c80124fc5b999d6dc716e3f2721052003 /cmake/info_macros.cmake.in | |
parent | dd4f852953afbe0fd9167028e34ae20ae22411ab (diff) | |
download | mariadb-git-22d684dcc33c33873c7521c4b132c57b5080d9d4.tar.gz |
Bug#20043556 ALWAYS USE SAME FORMAT FOR INFO_SRC FILE
Change the format of 'git log' to produce INFO_SRC:
commit: <commit hash>
date: 2014-11-12 11:11:10 +0100
build-date: 2014-11-17 15:24:16 +0100
short: <abbreviated commit hash>
branch: mysql-5.5
Diffstat (limited to 'cmake/info_macros.cmake.in')
-rw-r--r-- | cmake/info_macros.cmake.in | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/cmake/info_macros.cmake.in b/cmake/info_macros.cmake.in index 32cb77f4b18..7b080241c74 100644 --- a/cmake/info_macros.cmake.in +++ b/cmake/info_macros.cmake.in @@ -23,11 +23,13 @@ # If further variables are used in this file, add them to this list. SET(VERSION "@VERSION@") +SET(MAJOR_VERSION "@MAJOR_VERSION@") +SET(MINOR_VERSION "@MINOR_VERSION@") +SET(PATCH_VERSION "@PATCH_VERSION@") SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@") -SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@") SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@") SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@") SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@") @@ -45,34 +47,41 @@ SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@") MACRO(CREATE_INFO_SRC target_dir) SET(INFO_SRC "${target_dir}/INFO_SRC") + SET(PERLSCRIPT + "use warnings; use POSIX qw(strftime); " + "print strftime \"%F %T %z\", localtime;") + EXECUTE_PROCESS( + COMMAND perl -e "${PERLSCRIPT}" + RESULT_VARIABLE result + OUTPUT_VARIABLE bdate + ERROR_VARIABLE error + ) + IF(error) + MESSAGE(STATUS "Could not determine build-date: <${error}>") + ENDIF() + IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/.git) # Sources are in a GIT repository: Always update. EXECUTE_PROCESS( - COMMAND ${GIT_EXECUTABLE} log -1 + COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_INFO - RESULT_VARIABLE RESULT + OUTPUT_VARIABLE bname ) - FILE(WRITE ${INFO_SRC} "git log -1: ${VERSION_INFO}\n") + EXECUTE_PROCESS( - COMMAND ${GIT_EXECUTABLE} branch + COMMAND ${GIT_EXECUTABLE} log -1 + --pretty="commit: %H%ndate: %ci%nbuild-date: ${bdate} %nshort: %h%nbranch: ${bname}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_INFO - RESULT_VARIABLE RESULT - ) - FILE(APPEND ${INFO_SRC} "${VERSION_INFO}\n") - FILE(APPEND ${INFO_SRC} "\nMySQL source ${VERSION}\n") - ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/.bzr) - # Sources are in a BZR repository: Always update. - EXECUTE_PROCESS( - COMMAND ${BZR_EXECUTABLE} version-info ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_INFO - RESULT_VARIABLE RESULT ) + + ## Output from git is quoted with "", remove them. + STRING(REPLACE "\"" "" VERSION_INFO "${VERSION_INFO}") FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n") # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n") # For better readability ... - FILE(APPEND ${INFO_SRC} "\nMySQL source ${VERSION}\n") + FILE(APPEND ${INFO_SRC} + "MySQL source ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}\n") ELSEIF(EXISTS ${INFO_SRC}) # Outside a BZR tree, there is no need to change an existing "INFO_SRC", # it cannot be improved. |