summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2017-09-20 23:58:26 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2017-09-20 23:58:26 +0000
commit5caeb957c90d0988a6f2f49000eb78ae00367b93 (patch)
tree5ae9f7577928a308e62c3f4469be2d900fae92ec
parentb1f563def7a2f48b48f78002cdb0545d486528ea (diff)
downloadmariadb-git-bb-10.2-ext-wlad.tar.gz
MDEV-12583 : Bake the git hash into the binaries.bb-10.2-ext-wlad
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.
-rw-r--r--CMakeLists.txt17
-rw-r--r--client/mysql.cc6
-rw-r--r--cmake/make_dist.cmake.in3
-rw-r--r--include/source_revision.h.in1
-rw-r--r--sql/sys_vars.cc8
5 files changed, 32 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c638cb2d41..a0b498b27e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/client/mysql.cc b/client/mysql.cc
index fb9ffbef669..acfc805c26a 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -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)
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in
index b93036ab934..b93a6c08567 100644
--- a/cmake/make_dist.cmake.in
+++ b/cmake/make_dist.cmake.in
@@ -60,6 +60,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")
diff --git a/include/source_revision.h.in b/include/source_revision.h.in
new file mode 100644
index 00000000000..5b657d0940e
--- /dev/null
+++ b/include/source_revision.h.in
@@ -0,0 +1 @@
+#cmakedefine SOURCE_REVISION "@SOURCE_REVISION@"
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 8a800017c1e..c123d60ccb3 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -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)