Commit 22d684dc authored by Tor Didriksen's avatar Tor Didriksen

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
parent dd4f8529
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
# If further variables are used in this file, add them to this list. # If further variables are used in this file, add them to this list.
SET(VERSION "@VERSION@") 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_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@") SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@")
SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@") SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@")
SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@") SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@")
SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@") SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@")
...@@ -45,34 +47,41 @@ SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@") ...@@ -45,34 +47,41 @@ SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@")
MACRO(CREATE_INFO_SRC target_dir) MACRO(CREATE_INFO_SRC target_dir)
SET(INFO_SRC "${target_dir}/INFO_SRC") 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) IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
# Sources are in a GIT repository: Always update. # Sources are in a GIT repository: Always update.
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} log -1 COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_INFO OUTPUT_VARIABLE bname
RESULT_VARIABLE RESULT
) )
FILE(WRITE ${INFO_SRC} "git log -1: ${VERSION_INFO}\n")
EXECUTE_PROCESS( 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} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_INFO 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") FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n")
# to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n") # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n")
# For better readability ... # 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}) ELSEIF(EXISTS ${INFO_SRC})
# Outside a BZR tree, there is no need to change an existing "INFO_SRC", # Outside a BZR tree, there is no need to change an existing "INFO_SRC",
# it cannot be improved. # it cannot be improved.
......
...@@ -47,7 +47,7 @@ $found_revision = "No line 'revision-id: .....'"; ...@@ -47,7 +47,7 @@ $found_revision = "No line 'revision-id: .....'";
open(I_SRC,"<","$dir_docs/INFO_SRC") or print "Cannot open 'INFO_SRC' in '$dir_docs' (starting from bindir '$dir_bin')\n"; open(I_SRC,"<","$dir_docs/INFO_SRC") or print "Cannot open 'INFO_SRC' in '$dir_docs' (starting from bindir '$dir_bin')\n";
while(defined ($line = <I_SRC>)) { while(defined ($line = <I_SRC>)) {
if ($line =~ m|^MySQL source \d\.\d\.\d+|) {$found_version = "Found MySQL version number";} if ($line =~ m|^MySQL source \d\.\d\.\d+|) {$found_version = "Found MySQL version number";}
if ($line =~ m|^git log -1: commit \w{40}$|) {$found_revision = "Found GIT revision id";} if ($line =~ m|^commit: \w{40}$|) {$found_revision = "Found GIT revision id";}
} }
close I_SRC; close I_SRC;
print "INFO_SRC: $found_version / $found_revision\n"; print "INFO_SRC: $found_version / $found_revision\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment