Commit 0f373584 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-12583 : Bake the git hash into the binaries.

Added version_source_revision server "variable", for the git revision.
Also , mysql -V will show git revision.

"make dist" will now pack source_revision.h into the source package.
parent f70865bc
......@@ -432,6 +432,23 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
${CMAKE_BINARY_DIR}/include/mysql_version.h )
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
FIND_PACKAGE(Git)
IF(GIT_EXECUTABLE)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OUT RESULT_VARIABLE RES)
IF(RES EQUAL 0)
STRING(REGEX REPLACE "\n$" "" SOURCE_REVISION "${OUT}")
ENDIF()
ENDIF()
IF(SOURCE_REVISION OR
(NOT EXISTS ${PROJECT_SOURCE_DIR}/include/source_revision.h))
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/include/source_revision.h.in
${PROJECT_BINARY_DIR}/include/source_revision.h )
ENDIF()
CONFIGURE_FILE(
${CMAKE_SOURCE_DIR}/cmake/info_macros.cmake.in
${CMAKE_BINARY_DIR}/info_macros.cmake @ONLY)
......
......@@ -40,7 +40,7 @@
#include "my_readline.h"
#include <signal.h>
#include <violite.h>
#include <source_revision.h>
#if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H)
#include <locale.h>
#endif
......@@ -1721,8 +1721,8 @@ static void usage(int version)
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE,
readline, rl_library_version);
#else
printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER,
MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver %s Distrib %s, for %s (%s), source revision %s\n", my_progname, VER,
MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE,SOURCE_REVISION);
#endif
if (version)
......
......@@ -52,6 +52,9 @@ IF(GIT_EXECUTABLE)
ENDIF()
ENDIF()
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/include/source_revision.h
${PACKAGE_DIR}/include/source_revision.h COPYONLY)
IF(NOT GIT_EXECUTABLE)
MESSAGE(STATUS "git not found or source dir is not a repo, use CPack")
......
#cmakedefine SOURCE_REVISION "@SOURCE_REVISION@"
......@@ -3503,6 +3503,14 @@ static Sys_var_charptr Sys_version_compile_os(
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(SYSTEM_TYPE));
#include <source_revision.h>
static char *server_version_source_revision;
static Sys_var_charptr Sys_version_source_revision(
"version_source_revision", "Revision of the MariaDB source code",
READ_ONLY GLOBAL_VAR(server_version_source_revision),
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(SOURCE_REVISION));
static char *guess_malloc_library()
{
if (strcmp(MALLOC_LIBRARY, "system") == 0)
......
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