Skip to content

Commit f3f6b05

Browse files
author
Tor Didriksen
committed
Bug#35805629 Bundle boost headers [cmake]
Bundle necessary boost sources, and remove support for download or external sources. Create a cmake INTERFACE library extra::boost, and link with this, rather than using INCLUDE_DIRECTORIES. Remove BOOST from RPM specs. Change-Id: I04f64114392f6f154b226fce35cbbcb327c42e7f
1 parent f67dfeb commit f3f6b05

File tree

8 files changed

+26
-334
lines changed

8 files changed

+26
-334
lines changed

client/dump/CMakeLists.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23-
# Prevent Boost from including external precompiled Boost libraries,
24-
# and turn off unused functionality.
25-
IF(USING_LOCAL_BOOST)
26-
ADD_DEFINITIONS(
27-
-DBOOST_ALL_NO_LIB
28-
-DBOOST_SYSTEM_NO_DEPRECATED)
29-
ENDIF()
30-
31-
INCLUDE_DIRECTORIES(SYSTEM ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
32-
3323
SET(MYSQLPUMP_LIB_SOURCES
3424
abstract_chain_element.cc
3525
abstract_connection_provider.cc
@@ -108,7 +98,7 @@ ENDIF()
10898
ADD_STATIC_LIBRARY(mysqlpump_lib
10999
${MYSQLPUMP_LIB_SOURCES}
110100
LINK_LIBRARIES
111-
client_base ext::lz4 ext::zlib
101+
client_base ext::lz4 ext::zlib extra::boost
112102
)
113103

114104
MYSQL_ADD_EXECUTABLE(mysqlpump program.cc)

cmake/boost.cmake

Lines changed: 15 additions & 299 deletions
Original file line numberDiff line numberDiff line change
@@ -20,314 +20,29 @@
2020
# along with this program; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

23-
# We want boost 1.77.0 in order to build our boost/geometry code.
24-
# The boost tarball is fairly big, and takes several minutes
25-
# to download. So we recommend downloading/unpacking it
26-
# only once, in a place visible from any git sandbox.
27-
# We use only header files, so there should be no binary dependencies.
28-
29-
# Downloading the tarball takes about 5 minutes here at the office.
30-
# Here are some size/time data for unpacking the tarball on my desktop:
31-
# size tarball-name
32-
# 67M boost_1_55_0.tar.gz unzipping headers ~2 seconds 117M
33-
# unzipping everything ~3 seconds 485M
34-
# 8,8M boost_headers.tar.gz unzipping everything <1 second
35-
36-
# Invoke with -DWITH_BOOST=<directory> or set WITH_BOOST in environment.
37-
# If WITH_BOOST is *not* set, or is set to the special value "system",
38-
# we assume that the correct version (see below)
39-
# is installed on the compile host in the standard location.
40-
4123
SET(BOOST_PACKAGE_NAME "boost_1_77_0")
42-
SET(BOOST_TARBALL "${BOOST_PACKAGE_NAME}.tar.bz2")
43-
SET(BOOST_DOWNLOAD_URL
44-
"https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/${BOOST_TARBALL}"
45-
)
46-
47-
SET(OLD_PACKAGE_NAMES
48-
"boost_1_55_0"
49-
"boost_1_56_0"
50-
"boost_1_57_0"
51-
"boost_1_58_0"
52-
"boost_1_59_0"
53-
"boost_1_60_0"
54-
"boost_1_61_0"
55-
"boost_1_62_0"
56-
"boost_1_63_0"
57-
"boost_1_64_0"
58-
"boost_1_65_0"
59-
"boost_1_66_0"
60-
"boost_1_67_0"
61-
"boost_1_68_0"
62-
"boost_1_69_0"
63-
"boost_1_70_0"
64-
"boost_1_71_0"
65-
"boost_1_72_0"
66-
"boost_1_73_0"
67-
)
68-
69-
MACRO(RESET_BOOST_VARIABLES)
70-
UNSET(BOOST_INCLUDE_DIR)
71-
UNSET(BOOST_INCLUDE_DIR CACHE)
72-
UNSET(LOCAL_BOOST_DIR)
73-
UNSET(LOCAL_BOOST_DIR CACHE)
74-
UNSET(LOCAL_BOOST_ZIP)
75-
UNSET(LOCAL_BOOST_ZIP CACHE)
76-
ENDMACRO()
77-
78-
MACRO(ECHO_BOOST_VARIABLES)
79-
MESSAGE(STATUS "BOOST_INCLUDE_DIR ${BOOST_INCLUDE_DIR}")
80-
MESSAGE(STATUS "LOCAL_BOOST_DIR ${LOCAL_BOOST_DIR}")
81-
MESSAGE(STATUS "LOCAL_BOOST_ZIP ${LOCAL_BOOST_ZIP}")
82-
ENDMACRO()
83-
84-
MACRO(LOOKUP_OLD_PACKAGE_NAMES)
85-
FOREACH(pkg ${OLD_PACKAGE_NAMES})
86-
FIND_FILE(OLD_BOOST_DIR
87-
NAMES "${pkg}"
88-
PATHS ${WITH_BOOST}
89-
NO_DEFAULT_PATH
90-
)
91-
IF(OLD_BOOST_DIR)
92-
MESSAGE(STATUS "")
93-
MESSAGE(STATUS "Found old boost installation at ${OLD_BOOST_DIR}")
94-
MESSAGE(STATUS "You must upgrade to ${BOOST_PACKAGE_NAME}")
95-
MESSAGE(STATUS "")
96-
ENDIF()
97-
UNSET(OLD_BOOST_DIR)
98-
UNSET(OLD_BOOST_DIR CACHE)
99-
ENDFOREACH()
100-
ENDMACRO()
101-
102-
MACRO(COULD_NOT_FIND_BOOST)
103-
LOOKUP_OLD_PACKAGE_NAMES()
104-
ECHO_BOOST_VARIABLES()
105-
RESET_BOOST_VARIABLES()
106-
MESSAGE(STATUS "Could not find (the correct version of) boost.")
107-
MESSAGE(STATUS "MySQL currently requires ${BOOST_PACKAGE_NAME}\n")
108-
MESSAGE(FATAL_ERROR
109-
"You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>\n"
110-
"This CMake script will look for boost in <directory>. "
111-
"If it is not there, it will download and unpack it "
112-
"(in that directory) for you.\n"
113-
"You can also download boost manually, from ${BOOST_DOWNLOAD_URL}\n"
114-
"If you are inside a firewall, you may need to use an https proxy:\n"
115-
"export https_proxy=http://example.com:80\n"
116-
)
117-
ENDMACRO()
118-
119-
# Pick value from environment if not set on command line.
120-
IF(DEFINED ENV{WITH_BOOST} AND NOT DEFINED WITH_BOOST)
121-
SET(WITH_BOOST "$ENV{WITH_BOOST}")
122-
ENDIF()
123-
124-
# Pick value from environment if not set on command line.
125-
IF(DEFINED ENV{BOOST_ROOT} AND NOT DEFINED WITH_BOOST)
126-
SET(WITH_BOOST "$ENV{BOOST_ROOT}")
127-
ENDIF()
128-
129-
IF(WITH_BOOST AND WITH_BOOST STREQUAL "system")
130-
UNSET(WITH_BOOST)
131-
UNSET(WITH_BOOST CACHE)
132-
ENDIF()
133-
134-
# Update the cache, to make it visible in cmake-gui.
135-
SET(WITH_BOOST ${WITH_BOOST} CACHE PATH
136-
"Path to boost sources: a directory, or a tarball to be unzipped.")
137-
138-
# If the value of WITH_BOOST changes, we must unset all dependent variables:
139-
IF(OLD_WITH_BOOST)
140-
IF(NOT "${OLD_WITH_BOOST}" STREQUAL "${WITH_BOOST}")
141-
RESET_BOOST_VARIABLES()
142-
ENDIF()
143-
ENDIF()
144-
145-
SET(OLD_WITH_BOOST ${WITH_BOOST} CACHE INTERNAL
146-
"Previous version of WITH_BOOST" FORCE)
14724

148-
IF (WITH_BOOST)
149-
## Did we get a full path name, including file name?
150-
IF (${WITH_BOOST} MATCHES ".*\\.tar.bz2" OR ${WITH_BOOST} MATCHES ".*\\.zip")
151-
GET_FILENAME_COMPONENT(BOOST_DIR ${WITH_BOOST} PATH)
152-
GET_FILENAME_COMPONENT(BOOST_ZIP ${WITH_BOOST} NAME)
153-
FIND_FILE(LOCAL_BOOST_ZIP
154-
NAMES ${BOOST_ZIP}
155-
PATHS ${BOOST_DIR}
156-
NO_DEFAULT_PATH
157-
)
158-
ENDIF()
159-
## Did we get a path name to the directory of the .tar.bz2 or .zip file?
160-
FIND_FILE(LOCAL_BOOST_ZIP
161-
NAMES "${BOOST_PACKAGE_NAME}.tar.bz2" "${BOOST_PACKAGE_NAME}.zip"
162-
PATHS ${WITH_BOOST}
163-
NO_DEFAULT_PATH
164-
)
165-
## Did we get a path name to the directory of an unzipped version?
166-
FIND_FILE(LOCAL_BOOST_DIR
167-
NAMES "${BOOST_PACKAGE_NAME}"
168-
PATHS ${WITH_BOOST}
169-
NO_DEFAULT_PATH
170-
)
171-
## Did we get a path name to an unzippped version?
172-
FIND_PATH(LOCAL_BOOST_DIR
173-
NAMES "boost/version.hpp"
174-
PATHS ${WITH_BOOST}
175-
NO_DEFAULT_PATH
176-
)
177-
IF(LOCAL_BOOST_DIR)
178-
MESSAGE(STATUS "Local boost dir ${LOCAL_BOOST_DIR}")
179-
ENDIF()
180-
IF(LOCAL_BOOST_ZIP)
181-
MESSAGE(STATUS "Local boost zip ${LOCAL_BOOST_ZIP}")
182-
GET_FILE_SIZE(${LOCAL_BOOST_ZIP} LOCAL_BOOST_ZIP_SIZE)
183-
IF(LOCAL_BOOST_ZIP_SIZE EQUAL 0)
184-
# A previous failed download has left an empty file, most likely the
185-
# user pressed Ctrl-C to kill a hanging connection due to missing vpn
186-
# proxy. Remove it!
187-
MESSAGE("${LOCAL_BOOST_ZIP} is zero length. Deleting it.")
188-
FILE(REMOVE ${WITH_BOOST}/${BOOST_TARBALL})
189-
UNSET(LOCAL_BOOST_ZIP)
190-
UNSET(LOCAL_BOOST_ZIP CACHE)
191-
ENDIF()
192-
UNSET(LOCAL_BOOST_ZIP_ZERO_LENGTH)
193-
ENDIF()
194-
ENDIF()
195-
196-
# There is a similar option in unittest/gunit.
197-
# But the boost tarball is much bigger, so we have a separate option.
198-
OPTION(DOWNLOAD_BOOST "Download boost from sourceforge." OFF)
199-
SET(DOWNLOAD_BOOST_TIMEOUT 600 CACHE STRING
200-
"Timeout in seconds when downloading boost.")
201-
202-
# If we could not find it, then maybe download it.
203-
IF(WITH_BOOST AND NOT LOCAL_BOOST_ZIP AND NOT LOCAL_BOOST_DIR)
204-
IF(NOT DOWNLOAD_BOOST)
205-
MESSAGE(STATUS "WITH_BOOST=${WITH_BOOST}")
206-
COULD_NOT_FIND_BOOST()
207-
ENDIF()
208-
# Download the tarball
209-
MESSAGE(STATUS "Downloading ${BOOST_TARBALL} to ${WITH_BOOST}")
210-
FILE(DOWNLOAD ${BOOST_DOWNLOAD_URL}
211-
${WITH_BOOST}/${BOOST_TARBALL}
212-
TIMEOUT ${DOWNLOAD_BOOST_TIMEOUT}
213-
STATUS ERR
214-
SHOW_PROGRESS
215-
)
216-
IF(ERR EQUAL 0)
217-
SET(LOCAL_BOOST_ZIP "${WITH_BOOST}/${BOOST_TARBALL}")
218-
SET(LOCAL_BOOST_ZIP "${WITH_BOOST}/${BOOST_TARBALL}" CACHE INTERNAL "")
219-
ELSE()
220-
MESSAGE(STATUS "Download failed, error: ${ERR}")
221-
# A failed DOWNLOAD leaves an empty file, remove it
222-
FILE(REMOVE ${WITH_BOOST}/${BOOST_TARBALL})
223-
# STATUS returns a list of length 2
224-
LIST(GET ERR 0 NUMERIC_RETURN)
225-
IF(NUMERIC_RETURN EQUAL 28)
226-
MESSAGE(FATAL_ERROR
227-
"You can try downloading ${BOOST_DOWNLOAD_URL} manually"
228-
" using curl/wget or a similar tool,"
229-
" or increase the value of DOWNLOAD_BOOST_TIMEOUT"
230-
" (which is now ${DOWNLOAD_BOOST_TIMEOUT} seconds)"
231-
)
232-
ENDIF()
233-
MESSAGE(FATAL_ERROR
234-
"You can try downloading ${BOOST_DOWNLOAD_URL} manually"
235-
" using curl/wget or a similar tool"
236-
)
237-
ENDIF()
238-
ENDIF()
239-
240-
IF(LOCAL_BOOST_ZIP AND NOT LOCAL_BOOST_DIR)
241-
GET_FILENAME_COMPONENT(LOCAL_BOOST_DIR ${LOCAL_BOOST_ZIP} PATH)
242-
IF(NOT EXISTS "${LOCAL_BOOST_DIR}/${BOOST_PACKAGE_NAME}")
243-
MESSAGE(STATUS "cd ${LOCAL_BOOST_DIR}; tar xfj ${LOCAL_BOOST_ZIP}")
244-
EXECUTE_PROCESS(
245-
COMMAND ${CMAKE_COMMAND} -E tar xfj "${LOCAL_BOOST_ZIP}"
246-
WORKING_DIRECTORY "${LOCAL_BOOST_DIR}"
247-
RESULT_VARIABLE tar_result
248-
)
249-
IF (tar_result MATCHES 0)
250-
SET(BOOST_FOUND 1 CACHE INTERNAL "")
251-
ELSE()
252-
MESSAGE(STATUS "WITH_BOOST ${WITH_BOOST}.")
253-
MESSAGE(STATUS "Failed to extract files.\n"
254-
" Please try downloading and extracting yourself.\n"
255-
" The url is: ${BOOST_DOWNLOAD_URL}")
256-
MESSAGE(FATAL_ERROR "Giving up.")
257-
ENDIF()
258-
ENDIF()
259-
ENDIF()
260-
261-
# Search for the version file, first in LOCAL_BOOST_DIR or WITH_BOOST
262-
FIND_PATH(BOOST_INCLUDE_DIR
263-
NAMES boost/version.hpp
264-
NO_DEFAULT_PATH
265-
PATHS ${LOCAL_BOOST_DIR}
266-
${LOCAL_BOOST_DIR}/${BOOST_PACKAGE_NAME}
267-
${WITH_BOOST}
268-
)
269-
# Then search in standard places (if not found above).
270-
FIND_PATH(BOOST_INCLUDE_DIR
271-
NAMES boost/version.hpp
272-
)
25+
# Always use the bundled version.
26+
SET(BOOST_SOURCE_DIR ${CMAKE_SOURCE_DIR}/extra/boost)
27327

274-
IF(NOT BOOST_INCLUDE_DIR)
275-
MESSAGE(STATUS
276-
"Looked for boost/version.hpp in ${LOCAL_BOOST_DIR} and ${WITH_BOOST}")
277-
COULD_NOT_FIND_BOOST()
278-
ELSE()
279-
MESSAGE(STATUS "Found ${BOOST_INCLUDE_DIR}/boost/version.hpp ")
280-
ENDIF()
28+
# Contains all header files we need.
29+
# (All the directories that contain at least one needed file).
30+
SET(BOOST_INCLUDE_DIR ${BOOST_SOURCE_DIR}/${BOOST_PACKAGE_NAME})
28131

282-
# Verify version number. Version information looks like:
283-
# // BOOST_VERSION % 100 is the patch level
284-
# // BOOST_VERSION / 100 % 1000 is the minor version
285-
# // BOOST_VERSION / 100000 is the major version
286-
# #define BOOST_VERSION 107700
287-
FILE(STRINGS "${BOOST_INCLUDE_DIR}/boost/version.hpp"
288-
BOOST_VERSION_NUMBER
289-
REGEX "^#define[\t ]+BOOST_VERSION[\t ][0-9]+.*"
290-
)
291-
STRING(REGEX REPLACE
292-
"^.*BOOST_VERSION[\t ]([0-9][0-9])([0-9][0-9])([0-9][0-9]).*$" "\\1"
293-
BOOST_MAJOR_VERSION "${BOOST_VERSION_NUMBER}")
294-
STRING(REGEX REPLACE
295-
"^.*BOOST_VERSION[\t ]([0-9][0-9])([0-9][0-9])([0-9][0-9]).*$" "\\2"
296-
BOOST_MINOR_VERSION "${BOOST_VERSION_NUMBER}")
297-
298-
MESSAGE(STATUS "BOOST_VERSION_NUMBER is ${BOOST_VERSION_NUMBER}")
32+
# We have a limited set of patches/bugfixes here:
33+
SET(BOOST_PATCHES_DIR
34+
"${CMAKE_SOURCE_DIR}/include/${BOOST_PACKAGE_NAME}/patches")
29935

300-
IF(NOT BOOST_MAJOR_VERSION EQUAL 10)
301-
COULD_NOT_FIND_BOOST()
302-
ENDIF()
36+
ADD_LIBRARY(boost INTERFACE)
37+
ADD_LIBRARY(extra::boost ALIAS boost)
30338

304-
IF(NOT BOOST_MINOR_VERSION EQUAL 77)
305-
MESSAGE(WARNING "Boost minor version found is ${BOOST_MINOR_VERSION} "
306-
"we need 77"
307-
)
308-
COULD_NOT_FIND_BOOST()
309-
ENDIF()
39+
TARGET_INCLUDE_DIRECTORIES(boost SYSTEM BEFORE INTERFACE
40+
${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
31041

42+
MESSAGE(STATUS "BOOST_PATCHES_DIR ${BOOST_PATCHES_DIR}")
31143
MESSAGE(STATUS "BOOST_INCLUDE_DIR ${BOOST_INCLUDE_DIR}")
31244

313-
# We have a limited set of patches/bugfixes here:
314-
SET(BOOST_PATCHES_DIR "${CMAKE_SOURCE_DIR}/include/boost_1_77_0/patches")
315-
316-
# Boost gets confused about language support with Clang 7 + MSVC 15.9
317-
IF(WIN32_CLANG)
318-
ADD_DEFINITIONS(-DBOOST_NO_CXX17_HDR_STRING_VIEW)
319-
ENDIF()
320-
321-
IF(LOCAL_BOOST_DIR OR LOCAL_BOOST_ZIP)
322-
SET(USING_LOCAL_BOOST 1)
323-
ELSE()
324-
SET(USING_SYSTEM_BOOST 1)
325-
ENDIF()
326-
32745
IF(NOT WIN32)
328-
# Needed to use Boost header container_hash/hash.hpp in C++17
329-
ADD_DEFINITIONS(-DBOOST_NO_CXX98_FUNCTION_BASE)
330-
33146
FILE(GLOB_RECURSE BOOST_PATCHES_LIST
33247
RELATIVE ${BOOST_PATCHES_DIR}
33348
${BOOST_PATCHES_DIR}/*.hpp
@@ -337,7 +52,8 @@ IF(NOT WIN32)
33752
FOREACH(PATCHED_FILE ${BOOST_PATCHES_LIST})
33853
SET(ORIGINAL_FILE_PATH "${BOOST_INCLUDE_DIR}/${PATCHED_FILE}")
33954
SET(PATCHED_FILE_PATH "${BOOST_PATCHES_DIR}/${PATCHED_FILE}")
340-
LIST(APPEND DIFF_COMMAND_LIST "diff -u ${ORIGINAL_FILE_PATH} ${PATCHED_FILE_PATH}")
55+
LIST(APPEND DIFF_COMMAND_LIST
56+
"diff -u ${ORIGINAL_FILE_PATH} ${PATCHED_FILE_PATH}")
34157
ENDFOREACH()
34258
# Add true, to get zero exit status.
34359
LIST(APPEND DIFF_COMMAND_LIST "true")

packaging/rpm-docker/mysql.spec.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ URL: http://www.mysql.com/
7272
Packager: MySQL Release Engineering <[email protected]>
7373
Vendor: %{mysql_vendor}
7474
Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz
75-
Source1: @BOOST_DOWNLOAD_URL@
7675
%if 0%{?rhel} >= 8
7776
BuildRequires: cmake >= 3.6.1
7877
BuildRequires: libtirpc-devel
@@ -175,7 +174,7 @@ and the manual for more information.
175174
This package includes the MySQL server binary as well as related utilities
176175
to run and administer a MySQL server.
177176
%prep
178-
%setup -q -T -a 0 -a 1 -c -n %{src_dir}
177+
%setup -q -T -a 0 -c -n %{src_dir}
179178

180179
%build
181180
# Fail quickly and obviously if user tries to build as root
@@ -197,7 +196,6 @@ mkdir release
197196
-DREPRODUCIBLE_BUILD=OFF \
198197
-DINSTALL_LAYOUT=RPM \
199198
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
200-
-DWITH_BOOST=.. \
201199
-DCMAKE_C_FLAGS="%{optflags}" \
202200
-DCMAKE_CXX_FLAGS="%{optflags}" \
203201
-DWITH_INNODB_MEMCACHED=1 \

0 commit comments

Comments
 (0)