mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
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
This commit is contained in:
parent
dd4f852953
commit
22d684dcc3
2 changed files with 29 additions and 20 deletions
|
@ -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} rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE bname
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
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(WRITE ${INFO_SRC} "git log -1: ${VERSION_INFO}\n")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${GIT_EXECUTABLE} branch
|
||||
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.
|
||||
|
|
|
@ -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";
|
||||
while(defined ($line = <I_SRC>)) {
|
||||
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;
|
||||
print "INFO_SRC: $found_version / $found_revision\n";
|
||||
|
|
Loading…
Reference in a new issue