Skip to content

Commit 8c47781

Browse files
author
Bogdan Degtyariov
committed
Added INFO_BIN and INFO_SRC metadata
1 parent 13ae8a0 commit 8c47781

File tree

8 files changed

+204
-112
lines changed

8 files changed

+204
-112
lines changed

BUILDINFO.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,13 +837,13 @@ add_test(NAME Link_test
837837
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
838838
)
839839

840-
841840
#
842-
# Create the BUILDINFO file
841+
# Create the INFO_SRC and INFO_BIN files
843842
# =========================
844843
#
845844
include(buildinfo.cmake)
846845

846+
847847
#
848848
# Packaging specifications
849849
# ========================

INFO_BIN.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MySQL Connector/C++ Build Information
2+
3+
build-date : @INFO_DATE@
4+
os-info : @CMAKE_SYSTEM_NAME@-@CMAKE_SYSTEM_VERSION@
5+
compiler : @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@
6+
protobuf-version : 2.6.1
7+
@INFO_BUILD_TYPE@@INFO_SSL@@INFO_MACOS_VERSION@@INFO_MACOS_BUILD@@INFO_MACOS_TARGET@@INFO_MYSQL_VERSION@@INFO_BOOST@

INFO_SRC.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MySQL Connector/C++ Sources Information
2+
3+
version : @INFO_VERSION@
4+
@INFO_DATE@@INFO_BRANCH@@INFO_COMMIT@@INFO_SHORT@

buildinfo.cmake

Lines changed: 162 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,69 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0, as
5+
# published by the Free Software Foundation.
26
#
3-
# This program is free software; you can redistribute it and/or modify
4-
# it under the terms of the GNU General Public License, version 2.0, as
5-
# published by the Free Software Foundation.
6-
#
7-
# This program is also distributed with certain software (including
8-
# but not limited to OpenSSL) that is licensed under separate terms,
9-
# as designated in a particular file or component or in included license
10-
# documentation. The authors of MySQL hereby grant you an
11-
# additional permission to link the program and your derivative works
12-
# with the separately licensed software that they have included with
13-
# MySQL.
14-
#
15-
# Without limiting anything contained in the foregoing, this file,
16-
# which is part of MySQL Connector/C++, is also subject to the
17-
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18-
# http://oss.oracle.com/licenses/universal-foss-exception.
19-
#
20-
# This program is distributed in the hope that it will be useful, but
21-
# WITHOUT ANY WARRANTY; without even the implied warranty of
22-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23-
# See the GNU General Public License, version 2.0, for more details.
24-
#
25-
# You should have received a copy of the GNU General Public License
26-
# along with this program; if not, write to the Free Software Foundation, Inc.,
27-
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28-
29-
# Try find out information about the build environment that
30-
# might be useful to the user of the C/C++ libraries
31-
32-
33-
set(buildinfo_in "${PROJECT_SOURCE_DIR}/BUILDINFO.in")
34-
set(buildinfo_out "${PROJECT_BINARY_DIR}/BUILDINFO.txt")
35-
36-
configure_file(
37-
"${PROJECT_SOURCE_DIR}/BUILDINFO.in"
38-
"${PROJECT_BINARY_DIR}/BUILDINFO.txt"
39-
@ONLY
40-
)
41-
42-
# TODO: OpenSSL information
43-
44-
if(WIN32)
45-
46-
if(STATIC_MSVCRT)
47-
file(APPEND ${buildinfo_out}
48-
"MSVC runtime : linked statically (/MT)\n"
49-
)
50-
else()
51-
file(APPEND ${buildinfo_out}
52-
"MSVC runtime : linked dynamically (/MD)\n"
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an
11+
# additional permission to link the program and your derivative works
12+
# with the separately licensed software that they have included with
13+
# MySQL.
14+
#
15+
# Without limiting anything contained in the foregoing, this file,
16+
# which is part of MySQL Connector/ODBC, is also subject to the
17+
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18+
# http://oss.oracle.com/licenses/universal-foss-exception.
19+
#
20+
# This program is distributed in the hope that it will be useful, but
21+
# WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the GNU General Public License, version 2.0, for more details.
24+
#
25+
# You should have received a copy of the GNU General Public License
26+
# along with this program; if not, write to the Free Software Foundation, Inc.,
27+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
29+
##########################################################################
30+
31+
FUNCTION(GENERATE_INFO_BIN)
32+
33+
IF(DEFINED ENV{PRODUCT_ID} AND $ENV{PRODUCT_ID} MATCHES "source-dist")
34+
MESSAGE("Generating INFO_BIN is skipped for the source package")
35+
RETURN()
36+
ENDIF()
37+
38+
MESSAGE("Generating INFO_BIN")
39+
string(TIMESTAMP INFO_DATE "%Y-%m-%d")
40+
41+
IF (CMAKE_BUILD_TYPE)
42+
SET(INFO_BUILD_TYPE "build-type : ${CMAKE_BUILD_TYPE}\n")
43+
ENDIF()
44+
45+
IF(OPENSSL_VERSION_GLOBAL)
46+
SET(INFO_SSL "ssl-library : OpenSSL ${OPENSSL_VERSION_GLOBAL}\n")
47+
ELSE()
48+
SET(INFO_SSL "ssl-library : WolfSSL ${WOLFSSL_VERSION_GLOBAL}\n")
49+
ENDIF()
50+
51+
IF(CMAKE_OSX_DEPLOYMENT_TARGET)
52+
SET(INFO_MACOS_TARGET "macos-target : ${CMAKE_OSX_DEPLOYMENT_TARGET}\n")
53+
ENDIF()
54+
55+
IF(APPLE)
56+
execute_process(
57+
COMMAND sw_vers -productVersion
58+
ERROR_QUIET
59+
OUTPUT_VARIABLE _prod_version
60+
RESULT_VARIABLE _result_code1
61+
OUTPUT_STRIP_TRAILING_WHITESPACE
5362
)
54-
endif()
5563

56-
elseif(APPLE)
57-
58-
set(_macos_ver "MacOS version :")
59-
60-
execute_process(
61-
COMMAND sw_vers -productVersion
62-
ERROR_QUIET
63-
OUTPUT_VARIABLE _prod_version
64-
RESULT_VARIABLE _result_code1
65-
OUTPUT_STRIP_TRAILING_WHITESPACE
66-
)
67-
68-
if(NOT _result_code1)
69-
70-
set(_macos_ver "${_macos_ver} ${_prod_version}")
64+
IF(_prod_version)
65+
SET(INFO_MACOS_VERSION "macos-version : ${_prod_version}\n")
66+
ENDIF()
7167

7268
execute_process(
7369
COMMAND sw_vers -buildVersion
@@ -77,39 +73,102 @@ elseif(APPLE)
7773
OUTPUT_STRIP_TRAILING_WHITESPACE
7874
)
7975

80-
if(NOT _result_code2)
81-
set(_macos_ver "${_macos_ver} (${_build_version})")
82-
endif()
83-
84-
file(APPEND ${buildinfo_out} "${_macos_ver}\n")
85-
86-
endif()
87-
88-
else()
89-
90-
execute_process(
91-
COMMAND ldd --version
92-
COMMAND head -1
93-
ERROR_QUIET
94-
OUTPUT_VARIABLE _glibc_version
95-
RESULT_VARIABLE _result_code
96-
)
97-
98-
if (_result_code STREQUAL "0")
99-
string(REGEX REPLACE "ldd *" "" _glibc_version "${_glibc_version}")
100-
file(APPEND ${buildinfo_out}
101-
"GLIBC version : ${_glibc_version}\n"
102-
)
103-
endif()
104-
105-
endif()
106-
107-
if(WITH_JDBC)
108-
file(APPEND ${buildinfo_out} "\nLegacy connector information:\n\n"
109-
"MySQL version : ${MYSQL_VERSION}\n"
110-
)
111-
# TODO: Boost version
112-
endif()
113-
114-
115-
install(FILES "${PROJECT_BINARY_DIR}/BUILDINFO.txt" DESTINATION . COMPONENT Readme)
76+
IF(_build_version)
77+
SET(INFO_MACOS_BUILD "macos-build : ${_build_version}\n")
78+
ENDIF()
79+
ENDIF()
80+
81+
IF(WITH_JDBC)
82+
IF(Boost_VERSION)
83+
SET(INFO_BOOST "boost-version : ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\n")
84+
ENDIF()
85+
86+
SET(INFO_MACOS_BUILD "mysql-version : ${MYSQL_VERSION}\n")
87+
ENDIF()
88+
89+
CONFIGURE_FILE(INFO_BIN.in "${CMAKE_SOURCE_DIR}/INFO_BIN")
90+
install(FILES "${CMAKE_SOURCE_DIR}/INFO_BIN" DESTINATION . COMPONENT Readme)
91+
ENDFUNCTION()
92+
93+
include(version.cmake)
94+
95+
FUNCTION(GENERATE_INFO_SRC)
96+
MESSAGE("Generating INFO_SRC")
97+
98+
IF (NOT EXISTS INFO_SRC)
99+
SET(INFO_VERSION "${CONCPP_PACKAGE_VERSION}")
100+
101+
find_program(GIT_FOUND NAMES git)
102+
103+
IF(GIT_FOUND AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
104+
execute_process(
105+
COMMAND git symbolic-ref --short HEAD
106+
ERROR_QUIET
107+
OUTPUT_VARIABLE GIT_BRANCH_NAME
108+
RESULT_VARIABLE _result_code3
109+
OUTPUT_STRIP_TRAILING_WHITESPACE
110+
)
111+
112+
IF (GIT_BRANCH_NAME)
113+
execute_process(
114+
COMMAND git log -1 --format=%cd --date=short
115+
ERROR_QUIET
116+
OUTPUT_VARIABLE GIT_DATE
117+
RESULT_VARIABLE _result_code4
118+
OUTPUT_STRIP_TRAILING_WHITESPACE
119+
)
120+
121+
IF(GIT_DATE)
122+
SET(INFO_DATE "date : ${GIT_DATE}\n")
123+
ENDIF()
124+
125+
IF(GIT_BRANCH_NAME)
126+
SET(INFO_BRANCH "branch : ${GIT_BRANCH_NAME}\n")
127+
ENDIF()
128+
129+
130+
execute_process(
131+
COMMAND git rev-parse HEAD
132+
ERROR_QUIET
133+
OUTPUT_VARIABLE GIT_COMMIT
134+
RESULT_VARIABLE _result_code5
135+
OUTPUT_STRIP_TRAILING_WHITESPACE
136+
)
137+
138+
IF(GIT_COMMIT)
139+
SET(INFO_COMMIT "commit : ${GIT_COMMIT}\n")
140+
ENDIF()
141+
142+
execute_process(
143+
COMMAND git rev-parse --short HEAD
144+
ERROR_QUIET
145+
OUTPUT_VARIABLE GIT_SHORT
146+
RESULT_VARIABLE _result_code6
147+
OUTPUT_STRIP_TRAILING_WHITESPACE
148+
)
149+
150+
IF(GIT_SHORT)
151+
SET(INFO_SHORT "short : ${GIT_SHORT}\n")
152+
ENDIF()
153+
ENDIF()
154+
ELSE()
155+
# git local repository does not exist, but the env variables might be set
156+
IF(DEFINED ENV{PUSH_REVISION})
157+
SET(INFO_COMMIT "commit : $ENV{PUSH_REVISION}\n")
158+
STRING(SUBSTRING $ENV{PUSH_REVISION} 0 8 GIT_SHORT)
159+
SET(INFO_SHORT "short : ${GIT_SHORT}\n")
160+
ENDIF()
161+
162+
IF(DEFINED ENV{BRANCH_SOURCE})
163+
STRING(REGEX MATCH " [^ ]+" GIT_BRANCH_NAME $ENV{BRANCH_SOURCE})
164+
SET(INFO_BRANCH "branch : ${GIT_BRANCH_NAME}\n")
165+
ENDIF()
166+
ENDIF()
167+
168+
CONFIGURE_FILE(INFO_SRC.in "${CMAKE_SOURCE_DIR}/INFO_SRC")
169+
ENDIF()
170+
install(FILES "${CMAKE_SOURCE_DIR}/INFO_SRC" DESTINATION . COMPONENT Readme)
171+
ENDFUNCTION()
172+
173+
GENERATE_INFO_SRC()
174+
GENERATE_INFO_BIN()

cdk/cmake/ssl.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ function(MYSQL_CHECK_SSL)
359359

360360
ENDIF()
361361

362+
IF(OPENSSL_VERSION)
363+
SET(OPENSSL_VERSION_GLOBAL ${OPENSSL_VERSION} CACHE INTERNAL "OpenSSL Version")
364+
UNSET(WOLFSSL_VERSION_GLOBAL CACHE)
365+
ENDIF()
366+
362367
endfunction()
363368

364369

cdk/extra/wolfssl/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,25 @@ SET(WOLFCRYPT_SOURCES ${WOLFCRYPT_SOURCE_DIR}/src/aes.c
148148
# misc.c is not compiled in since using INLINE
149149

150150
ADD_LIBRARY(wolfcrypt ${WOLFCRYPT_SOURCES})
151+
152+
set(GETWOLFSSLVERSION_SOURCEFILE "${CMAKE_CURRENT_BINARY_DIR}/getwolfsslversion.c")
153+
file(WRITE "${GETWOLFSSLVERSION_SOURCEFILE}"
154+
"#include <stdio.h>\n"
155+
"#include <ssl.h>\n"
156+
"int main() {\n"
157+
" printf(\"%s\", LIBWOLFSSL_VERSION_STRING);\n"
158+
"}\n"
159+
)
160+
161+
# Compile and run the created executable, store output in MYSQL_VERSION
162+
try_run(_run_result _compile_result
163+
"${CMAKE_BINARY_DIR}"
164+
"${GETWOLFSSLVERSION_SOURCEFILE}"
165+
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${SSL_INCLUDES}"
166+
RUN_OUTPUT_VARIABLE _WOLFSSL_VERSION
167+
)
168+
169+
IF (_WOLFSSL_VERSION)
170+
SET(WOLFSSL_VERSION_GLOBAL ${_WOLFSSL_VERSION} CACHE INTERNAL "WolfSSL Version")
171+
UNSET(OPENSSL_VERSION_GLOBAL CACHE)
172+
ENDIF()

doc/usage.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ option).
7272
Due to ABI incompatiblities between different compiler versions, the code
7373
that uses Connector/C++ libraries should be built with the same compiler
7474
version as the connector itself. The information about compiler version used
75-
to build connector libraries can be found inside `BUILDINFO.txt` file
75+
to build connector libraries can be found inside `INFO_BIN` file
7676
distributed with the connector. In principle a different version of the
7777
compiler can be used provided that it is ABI compatible, but it is difficult to
7878
determine which versions of the compiler are ABI compatible with each other.
@@ -302,7 +302,7 @@ and the application are the same.
302302

303303
The binary distribution of Connector/C++ 8.0 ships libraries built in the
304304
release mode using dynamic runtime (`/MD`). The libraries are built with
305-
MSVC 2015 (the exact compiler version can be found in `BUILDINFO.txt` file
305+
MSVC 2015 (the exact compiler version can be found in `INFO_BIN` file
306306
included in the package). Consequently the code that uses these libraries must
307307
be built with the same version of MSVC and in the '/MD' mode. To build your
308308
code in different mode you must build the connector library in the same mode

0 commit comments

Comments
 (0)