-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathabi_check.cmake
114 lines (108 loc) · 4.47 KB
/
abi_check.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright (c) 2009, 2024, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is designed to work with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have either included with
# the program or referenced in the documentation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Headers which need to be checked for abi/api compatibility are in
# API_PREPROCESSOR_HEADER. plugin.h is tested implicitly via
# plugin_audit.h and plugin_ftparser.h.
#
# We use gcc specific preprocessing command and sed/diff, so it will
# only be run on Unix and only if gcc is used. On some Unixes,
# (Solaris) sed or diff might act differently from GNU, so we run only
# on systems we can trust.
# On Windows we use the Windows subsystem for Linux and gcc and sed
# installed in it, if available.
SET(RUN_ABI_CHECK 0)
IF(LINUX AND MY_COMPILER_IS_GNU)
SET(RUN_ABI_CHECK 1)
ELSEIF(WIN32)
FIND_PROGRAM(WSL_EXECUTABLE wsl HINTS C:/Windows/Sysnative)
IF (WSL_EXECUTABLE)
SET (COMPILER "gcc")
# Check that the compiler is available under WSL.
EXECUTE_PROCESS(
COMMAND ${WSL_EXECUTABLE} which ${COMPILER}
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE COMPILER_LOCATION)
IF (COMPILER_LOCATION STREQUAL "/usr/bin/gcc")
SET(RUN_ABI_CHECK 1)
MESSAGE(STATUS "Will do ABI check using ${WSL_EXECUTABLE} (gcc/sed)")
ENDIF()
ENDIF()
ENDIF()
SET(API_PREPROCESSOR_HEADER
${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h
${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h
${CMAKE_SOURCE_DIR}/include/mysql.h
${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
${CMAKE_SOURCE_DIR}/include/mysql/plugin_keyring.h
)
IF(NOT WITHOUT_SERVER)
LIST(APPEND API_PREPROCESSOR_HEADER
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_thread_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mutex_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_rwlock_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_cond_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_file_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_socket_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_table_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mdl_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_idle_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_stage_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_statement_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_transaction_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_memory_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_error_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_system_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_metric_v1.h
${CMAKE_SOURCE_DIR}/include/mysql/services.h
)
ENDIF()
IF(MY_COMPILER_IS_GNU)
IF(CMAKE_C_COMPILER MATCHES "ccache$")
SET(COMPILER ${CMAKE_C_COMPILER_ARG1})
STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER})
ELSE()
SET(COMPILER ${CMAKE_C_COMPILER})
ENDIF()
ENDIF()
IF(RUN_ABI_CHECK)
UNSET(API_PP_FILES)
FOREACH(file ${API_PREPROCESSOR_HEADER})
LIST(APPEND API_PP_FILES ${file}.pp)
ENDFOREACH()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/abi_check.out
COMMAND ${CMAKE_COMMAND}
-DCOMPILER=${COMPILER}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DBINARY_DIR=${CMAKE_BINARY_DIR}
-DWSL_EXECUTABLE=${WSL_EXECUTABLE}
"-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
-P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
DEPENDS ${API_PREPROCESSOR_HEADER} ${API_PP_FILES}
VERBATIM
)
ADD_CUSTOM_TARGET(abi_check ALL
DEPENDS ${CMAKE_BINARY_DIR}/abi_check.out
)
ENDIF()