Skip to content

Commit

Permalink
CONC-282:
Browse files Browse the repository at this point in the history
Connector/C now provides additional information for package version
mariadb_config --cc_version lists the package version
Beside MARIADB_PACKAGE_VERSION numeric representation MARIADB_PACKAGE_VERSION_ID can be used now within preprocessor directives
  • Loading branch information
9EOR9 committed Oct 2, 2017
1 parent b3c8de2 commit 4bbcced
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Expand Up @@ -8,7 +8,9 @@ SET(CPACK_PACKAGE_VERSION_MAJOR 2)
SET(CPACK_PACKAGE_VERSION_MINOR 3)
SET(CPACK_PACKAGE_VERSION_PATCH 4)
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
${CPACK_PACKAGE_VERSION_PATCH}")
#Minimum required version is Cmake 2.8.8, since we need to build object libraries
IF(WIN32)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
Expand Down Expand Up @@ -91,6 +93,7 @@ SET(MYSQL_CLIENT_VERSION "${MYSQL_CLIENT_VERSION_MAJOR}.${MYSQL_CLIENT_VERSION_M
MATH(EXPR MYSQL_VERSION_ID "${MYSQL_CLIENT_VERSION_MAJOR} * 10000 +
${MYSQL_CLIENT_VERSION_MINOR} * 100 +
${MYSQL_CLIENT_VERSION_PATCH}")

IF (NOT MYSQL_PORT)
SET(MYSQL_PORT 3306)
ENDIF ()
Expand Down
1 change: 1 addition & 0 deletions include/mysql_version.h.in
Expand Up @@ -17,6 +17,7 @@
#define MYSQL_CONFIG_NAME "my"

#define MARIADB_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@"
#define MARIADB_PACKAGE_VERSION_ID @MARIADB_PACKAGE_VERSION_ID@
#define MARIADB_SYSTEM_TYPE "@CMAKE_SYSTEM_NAME@"
#define MARIADB_MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"

Expand Down
18 changes: 12 additions & 6 deletions mariadb_config/mariadb_config.c.in
Expand Up @@ -7,6 +7,7 @@
"@extra_dynamic_LDFLAGS@"
#define CFLAGS INCLUDE " @CMAKE_C_FLAGS@"
#define VERSION "@MYSQL_CLIENT_VERSION@"
#define CC_VERSION "@CPACK_PACKAGE_VERSION@"
#define PLUGIN_DIR "@PREFIX_INSTALL_DIR@/@SUFFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
#define SOCKET "@MYSQL_UNIX_ADDR@"
#define PORT "@MYSQL_PORT@"
Expand All @@ -19,9 +20,10 @@ static struct option long_options[]=
{"libs", no_argument, 0, 'd'},
{"libs_r", no_argument, 0, 'e'},
{"version", no_argument, 0, 'f'},
{"socket", no_argument, 0, 'g'},
{"port", no_argument, 0, 'h'},
{"plugindir", no_argument, 0, 'p'},
{"cc_version", no_argument, 0, 'g'},
{"socket", no_argument, 0, 'h'},
{"port", no_argument, 0, 'i'},
{"plugindir", no_argument, 0, 'j'},
{NULL, 0, 0, 0}
};

Expand All @@ -33,6 +35,7 @@ static char *values[]=
LIBS,
LIBS,
VERSION,
CC_VERSION,
SOCKET,
PORT,
PLUGIN_DIR
Expand Down Expand Up @@ -68,7 +71,7 @@ int main(int argc, char **argv)
while(1)
{
int option_index= 0;
c= getopt_long(argc, argv, "abcdef", long_options, &option_index);
c= getopt_long(argc, argv, "abcdefghij", long_options, &option_index);

switch(c) {
case 'a':
Expand All @@ -88,12 +91,15 @@ int main(int argc, char **argv)
puts(VERSION);
break;
case 'g':
puts(SOCKET);
puts(CC_VERSION);
break;
case 'h':
puts(SOCKET);
break;
case 'i':
puts(PORT);
break;
case 'p':
case 'j':
puts(PLUGIN_DIR);
break;
default:
Expand Down

0 comments on commit 4bbcced

Please sign in to comment.