mysql: rework (#4982)

* mysql: rework

* fix ncurses

* fix readline

* fix readline again

* fix windows arm

* add deps editline

* editline: add apt sources

* hack editline

* use editline & ncurses

* use 8.0.39

* use bundle editline

* fix ncurses

* support cross compilation

* fix find ncurses

* remove 9.0.1 version

* fix editline

* mysql-build-tools: fix linux dpes

* revert libedit & ncurses code

* refractor configs

* fix editline

* mysql-build-tools: make deps host & improve build time

* improve xmake.lua
pull/5095/head
star9029 3 months ago committed by GitHub
parent ea12e0f1c9
commit f5f4c6f213
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 77
      packages/m/mysql-build-tools/xmake.lua
  2. 70
      packages/m/mysql/configs.lua
  3. 53
      packages/m/mysql/patch.lua
  4. 229
      packages/m/mysql/patches/8.0.39/cmake-cross-compilation.patch
  5. 179
      packages/m/mysql/xmake.lua
  6. 4
      packages/n/ncurses/xmake.lua

@ -0,0 +1,77 @@
package("mysql-build-tools")
set_kind("binary")
set_homepage("http://www.mysql.com")
set_description("This package help for mysql corss compilation")
set_license("GPL-2.0")
add_urls("https://github.com/mysql/mysql-server/archive/refs/tags/mysql-$(version).tar.gz")
add_versions("8.0.39", "3a72e6af758236374764b7a1d682f7ab94c70ed0d00bf0cb0f7dd728352b6d96")
add_configs("server", {description = "Build server", default = false, type = "boolean"})
add_configs("debug", {description = "Enable debug symbols.", default = false, readonly = true})
add_deps("cmake")
add_deps("zlib", "zstd", "lz4", "openssl", "rapidjson", {host = true, private = true})
if is_plat("linux") then
add_deps("patchelf")
add_deps("libedit", {host = true, private = true, configs = {terminal_db = "ncurses"}})
end
local tool_list = {
"uca9dump",
"comp_sql",
"comp_err",
"comp_client_err",
"libmysql_api_test",
}
on_load(function(package)
if package:config("server") then
table.join2(tool_list, {
"json_schema_embedder",
"gen_lex_token",
"gen_lex_hash",
"gen_keyword_list"
})
end
local version = package:version()
if version:lt("9.0.0") then
package:add("deps", "boost", "libevent", {host = true, private = true})
end
end)
on_install("windows", "macosx", "linux", function (package)
local mysql_script_dir = path.join(path.directory(package:scriptdir()), "mysql")
import("patch", {rootdir = mysql_script_dir})
import("configs", {rootdir = mysql_script_dir})
import("package.tools.cmake")
import("core.base.hashset")
local opt = {}
if cmake.configure then -- xmake 2.9.5
opt.target = tool_list
end
patch.cmake(package)
cmake.build(package, configs.get(package, true), opt)
local hash = hashset.from(tool_list)
local tools_dir = path.join(package:buildir(), "runtime_output_directory/**")
for _, file in ipairs(os.files(tools_dir)) do
if hash:has(path.basename(file)) then
os.vcp(file, package:installdir("bin"))
end
end
end)
on_test(function (package)
for _, name in ipairs(tool_list) do
if is_host("windows") then
name = name .. ".exe"
end
local exec = path.join(package:installdir("bin", name))
assert(os.isexec(exec), name .. " not found!")
end
end)

@ -0,0 +1,70 @@
function _host_tool_configs(package)
return {
"-DCMAKE_BUILD_TYPE=Release",
"-DWITH_CURL=none",
"-DWITH_KERBEROS=none",
"-DWITH_FIDO=none",
}
end
function _target_configs(package)
local configs = {}
table.insert(configs, "-DWITH_CURL=" .. (package:config("curl") and "system" or "none"))
table.insert(configs, "-DWITH_KERBEROS=" .. (package:config("kerberos") and "system" or "none"))
table.insert(configs, "-DWITH_FIDO=" .. (package:config("fido") and "system" or "none"))
return configs
end
function get(package, build_host_tool)
local configs = {
"-DWITH_BUILD_ID=OFF",
"-DWITH_UNIT_TESTS=OFF",
"-DENABLED_PROFILING=OFF",
"-DWIX_DIR=OFF",
"-DWITH_TEST_TRACE_PLUGIN=OFF",
"-DMYSQL_MAINTAINER_MODE=OFF",
"-DBUNDLE_RUNTIME_LIBRARIES=OFF",
"-DDOWNLOAD_BOOST=OFF",
"-DWITH_BOOST=system",
"-DWITH_LIBEVENT=system",
"-DWITH_ZLIB=system",
"-DWITH_ZSTD=system",
"-DWITH_SSL=system",
"-DWITH_LZ4=system",
"-DWITH_RAPIDJSON=system",
}
if package:is_cross() then
table.insert(configs, "-DCMAKE_CROSSCOMPILING=ON")
end
if package:is_plat("linux") then
local widec = package:dep("ncurses"):config("widec")
-- From FindCurses.cmake
table.insert(configs, "-DCURSES_NEED_WIDE=" .. (widec and "ON" or "OFF"))
table.insert(configs, "-DWITH_EDITLINE=system")
end
if package:config("server") then
-- TODO: server deps
table.insert(configs, "-DWITH_ICU=system")
table.insert(configs, "-DWITH_PROTOBUF=system")
end
if package:config("x") then
table.join2(configs, {"-DWITH_MYSQLX=ON", "-DWITH_MYSQLX_USE_PROTOBUF_FULL=ON"})
else
table.insert(configs, "-DWITH_MYSQLX=OFF")
end
if package:config("cluster") then
table.join2(configs, {"-DWITH_NDB=ON", "-DWITH_NDBCLUSTER=ON"})
else
table.join2(configs, {"-DWITH_NDB=OFF", "-DWITH_NDBCLUSTER=OFF"})
end
table.insert(configs, "-DWITHOUT_SERVER=" .. (package:config("server") and "OFF" or "ON"))
table.join2(configs, (build_host_tool and _host_tool_configs(package) or _target_configs(package)))
return configs
end

@ -0,0 +1,53 @@
function _patch_editline(package)
if not package:is_plat("linux") then
return
end
-- cmake/readline.cmake always consider editline is shared library
-- If we use static library, CHECK_CXX_SOURCE_COMPILES will fail because missing ncurses
local editline = package:dep("libedit")
if not editline:config("shared") then
local strings = "\nFIND_PACKAGE(Curses)\nlist(APPEND EDITLINE_LIBRARY ${CURSES_LIBRARIES})\n"
io.replace("cmake/readline.cmake",
"MARK_AS_ADVANCED(EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)",
"MARK_AS_ADVANCED(EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)" .. strings,
{plain = true})
end
end
function cmake(package)
local version = package:version()
if version:eq("8.0.39") then
io.replace("cmake/ssl.cmake", "IF(NOT OPENSSL_APPLINK_C)", "IF(FALSE)", {plain = true})
io.replace("cmake/boost.cmake", "IF(NOT BOOST_MINOR_VERSION EQUAL 77)", "IF(FALSE)", {plain = true})
if package:is_cross() then
local libevent_version = package:dep("libevent"):version()
if not libevent_version then
version = "2.1.12"
end
-- skip try_run
io.replace("cmake/libevent.cmake",
[[SET(LIBEVENT_VERSION_STRING "${RUN_OUTPUT}")]],
format([[SET(LIBEVENT_VERSION_STRING "%s")]], libevent_version), {plain = true})
end
elseif version:eq("9.0.1") then
io.replace("cmake/ssl.cmake", "FIND_CUSTOM_OPENSSL()", "FIND_SYSTEM_OPENSSL()", {plain = true})
end
if package:is_plat("windows") then
-- fix pdb install
io.replace("cmake/install_macros.cmake",
[[NOT type MATCHES "STATIC_LIBRARY"]],
[[NOT type MATCHES "STATIC_LIBRARY" AND CMAKE_BUILD_TYPE STREQUAL "DEBUG"]], {plain = true})
if package:is_cross() then
-- skip try_run
io.replace("cmake/rapidjson.cmake", "IF (NOT HAVE_RAPIDJSON_WITH_STD_REGEX)", "if(FALSE)", {plain = true})
end
end
if not package:config("cluster") then
io.replace("CMakeLists.txt", "ADD_SUBDIRECTORY(storage/ndb)", "", {plain = true})
end
_patch_editline(package)
end

@ -0,0 +1,229 @@
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index f3669e2a26..43176da5a5 100644
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -403,20 +403,20 @@ ENDFOREACH()
# Generate api_test.c source, substituting @CLIENT_API_FUNCTION_LIST@
# with the list of API functions.
#
-CONFIGURE_FILE(api_test.c.in ${CMAKE_CURRENT_BINARY_DIR}/api_test.c)
+# CONFIGURE_FILE(api_test.c.in ${CMAKE_CURRENT_BINARY_DIR}/api_test.c)
#
# Note: Compiling this test application will fail if not all symbols
# from @CLIENT_API_FUNCTIONS@ are declared by <mysql.h>. It will fail
# to run if not all of these symbols are exported by the library.
#
-MYSQL_ADD_EXECUTABLE(libmysql_api_test
- ${CMAKE_CURRENT_BINARY_DIR}/api_test.c
- LINK_LIBRARIES libmysql ${LIBRT}
- SKIP_INSTALL
- )
+# MYSQL_ADD_EXECUTABLE(libmysql_api_test
+# ${CMAKE_CURRENT_BINARY_DIR}/api_test.c
+# LINK_LIBRARIES libmysql ${LIBRT}
+# SKIP_INSTALL
+# )
# Clang/UBSAN needs this on some platforms.
-SET_TARGET_PROPERTIES(libmysql_api_test PROPERTIES LINKER_LANGUAGE CXX)
+# SET_TARGET_PROPERTIES(libmysql_api_test PROPERTIES LINKER_LANGUAGE CXX)
IF(MY_COMPILER_IS_GNU)
ADD_COMPILE_FLAGS(
@@ -434,12 +434,12 @@ IF(HAS_WARN_FLAG)
ENDIF()
# Verify that libmysql_api_test runs OK
-ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
- DEPENDS libmysql_api_test
- COMMAND libmysql_api_test
- > ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
- )
-MY_ADD_CUSTOM_TARGET(run_libmysql_api_test ALL
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
- )
+# ADD_CUSTOM_COMMAND(
+# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
+# DEPENDS libmysql_api_test
+# COMMAND libmysql_api_test
+# > ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
+# )
+# MY_ADD_CUSTOM_TARGET(run_libmysql_api_test ALL
+# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
+# )
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 818b214ce9..6c96ba9a02 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -25,7 +25,7 @@ DISABLE_MISSING_PROFILE_WARNING()
ADD_SUBDIRECTORY(sys_schema)
-MYSQL_ADD_EXECUTABLE(comp_sql comp_sql.cc SKIP_INSTALL)
+# MYSQL_ADD_EXECUTABLE(comp_sql comp_sql.cc SKIP_INSTALL)
# Add compiler information, for easier debugging of output from mysql_config.
SET(COMPILER_ID_AND_VERSION
@@ -63,7 +63,7 @@ ADD_CUSTOM_COMMAND(
mysql_fix_privilege_tables.sql
mysql_fix_privilege_tables_sql.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_fix.sql
)
@@ -81,7 +81,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/mysql_sys_schema.sql
sql_commands_sys_schema.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_sys_schema.sql
)
@@ -92,7 +92,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
sql_commands_system_data.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
)
@@ -103,7 +103,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data_fix.sql
sql_commands_system_tables_data_fix.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data_fix.sql
)
@@ -114,7 +114,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
sql_commands_system_tables.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
)
@@ -125,7 +125,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_users.sql
sql_commands_system_users.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_users.sql
)
@@ -136,7 +136,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
sql_commands_help_data.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
)
@@ -147,7 +147,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_SOURCE_DIR}/firewall_stored_procedures.sql
sql_firewall_stored_procedures.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql
+ DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/firewall_stored_procedures.sql
)
diff --git a/scripts/sys_schema/CMakeLists.txt b/scripts/sys_schema/CMakeLists.txt
index 1d3295e8d4..c862909257 100644
--- a/scripts/sys_schema/CMakeLists.txt
+++ b/scripts/sys_schema/CMakeLists.txt
@@ -213,7 +213,7 @@ ADD_CUSTOM_COMMAND(
${CMAKE_CURRENT_BINARY_DIR}/ALL_SYS_SCHEMA.sql
sql_commands.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql all_sys_schema
+ DEPENDS all_sys_schema
${CMAKE_CURRENT_BINARY_DIR}/ALL_SYS_SCHEMA.sql
VERBATIM
)
@@ -223,7 +223,7 @@ MY_ADD_CUSTOM_TARGET(sql_commands
MY_ADD_CUSTOM_TARGET(GenSysSchemaC
ALL
- DEPENDS comp_sql sql_commands
+ DEPENDS sql_commands
COMMENT "Generating Sys Schema C code"
)
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index f4cd85e786..99dbd5f811 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -59,7 +59,7 @@ SET(STRINGS_SOURCES
xml.cc
)
-MYSQL_ADD_EXECUTABLE(uca9dump uca9-dump.cc SKIP_INSTALL)
+# MYSQL_ADD_EXECUTABLE(uca9dump uca9-dump.cc SKIP_INSTALL)
MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_MISSING_PROFILE)
IF(HAS_MISSING_PROFILE)
@@ -78,7 +78,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${ZH_HANS_DST_FILE}
COMMAND uca9dump ja
--in_file=${JA_HANS_SRC_FILE}
--out_file=${JA_HANS_DST_FILE}
- DEPENDS uca9dump ${ZH_HANS_SRC_FILE} ${JA_HANS_SRC_FILE}
+ DEPENDS ${ZH_HANS_SRC_FILE} ${JA_HANS_SRC_FILE}
)
SET_SOURCE_FILES_PROPERTIES(
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index 621a8e140d..d5aefda309 100644
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -26,19 +26,19 @@ DISABLE_MISSING_PROFILE_WARNING()
MSVC_CPPCHECK_DISABLE()
IF(NOT CMAKE_CROSSCOMPILING)
- MYSQL_ADD_EXECUTABLE(comp_err
- comp_err.cc
- COMPONENT Test
- LINK_LIBRARIES mysys
- )
+ # MYSQL_ADD_EXECUTABLE(comp_err
+ # comp_err.cc
+ # COMPONENT Test
+ # LINK_LIBRARIES mysys
+ # )
ENDIF()
-MYSQL_ADD_EXECUTABLE(comp_client_err
- comp_client_err.cc
- ${CMAKE_SOURCE_DIR}/libmysql/errmsg.cc
- LINK_LIBRARIES mysys
- SKIP_INSTALL
- )
+# MYSQL_ADD_EXECUTABLE(comp_client_err
+# comp_client_err.cc
+# ${CMAKE_SOURCE_DIR}/libmysql/errmsg.cc
+# LINK_LIBRARIES mysys
+# SKIP_INSTALL
+# )
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h
COMMAND comp_client_err
@@ -104,8 +104,8 @@ ADD_DEFINITIONS(-DMUTEX_EVENT)
# The copied shared libraries must be available at build time.
IF(TARGET copy_openssl_dlls)
ADD_DEPENDENCIES(GenError copy_openssl_dlls)
- ADD_DEPENDENCIES(comp_client_err copy_openssl_dlls)
- ADD_DEPENDENCIES(comp_err copy_openssl_dlls)
+ # ADD_DEPENDENCIES(comp_client_err copy_openssl_dlls)
+ # ADD_DEPENDENCIES(comp_err copy_openssl_dlls)
ENDIF()
MYSQL_ADD_EXECUTABLE(static_thread_local_test

@ -1,142 +1,103 @@
package("mysql")
set_homepage("http://www.mysql.com")
set_description("A real-time, open source transactional database.")
set_license("GPL-2.0")
set_homepage("https://dev.mysql.com/doc")
set_description("Open source relational database management system.")
add_urls("https://github.com/mysql/mysql-server/archive/refs/tags/mysql-$(version).tar.gz")
if is_plat("macosx", "linux") then
set_urls("https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-$(version).tar.gz",
"https://github.com/xmake-mirror/mysql-boost/releases/download/$(version)/mysql-boost-$(version).tar.gz")
add_versions("5.7.29", "00f514124de2bad1ba7b380cbbd46e316cae7fc7bc3a5621456cabf352f27978")
add_versions("8.0.39", "3a72e6af758236374764b7a1d682f7ab94c70ed0d00bf0cb0f7dd728352b6d96")
add_configs("server", {description = "Build server", default = false, type = "boolean"})
add_configs("curl", {description = "Build with curl", default = false, type = "boolean"})
add_configs("kerberos", {description = "Build with kerberos", default = false, type = "boolean"})
add_configs("fido", {description = "Build FIDO based authentication plugins", default = false, type = "boolean"})
add_configs("x", {description = "Build MySQL X plugin", default = false, type = "boolean"})
if is_plat("windows") then
add_configs("debug", {description = "Enable debug symbols.", default = false, readonly = true})
end
if is_plat("windows", "macosx", "linux") then
set_urls("https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-$(version).tar.gz")
add_versions("8.0.31", "67bb8cba75b28e95c7f7948563f01fb84528fcbb1a35dba839d4ce44fe019baa")
add_includedirs("include", "include/mysql")
add_deps("cmake")
add_deps("zlib", "zstd", "lz4", "openssl", "rapidjson")
if is_plat("linux") then
add_deps("patchelf")
add_deps("libedit", {configs = {terminal_db = "ncurses"}})
end
if is_plat("mingw") then
add_configs("shared", {description = "Download shared binaries.", default = true, type = "boolean", readonly = true})
if is_arch("i386") then
set_urls("https://github.com/xmake-mirror/mysql/releases/download/$(version)/mysql_$(version)_x86.zip")
add_versions("8.0.31", "fd626cae72b1f697b941cd3a2ea9d93507e689adabb1c2c11d465f01f4b07cb9")
else
set_urls("https://github.com/xmake-mirror/mysql/releases/download/$(version)/mysql_$(version)_x64.zip")
add_versions("8.0.31", "26312cfa871c101b7a55cea96278f9d14d469455091c4fd3ffaaa67a2d1aeea5")
if on_check then
on_check(function (package)
local version = package:version()
if version:ge("9.0.0") then
assert(package:is_arch(".*64"), "package(mysql) supports only 64-bit platforms.")
assert(not package:is_plat("macosx"), "package(mysql >=9.0.0) need c++20 compiler")
end
end)
end
add_includedirs("include", "include/mysql")
add_deps("cmake")
on_load(function(package)
local version = package:version()
if version:lt("9.0.0") then
package:add("deps", "boost", "libevent")
end
on_load("windows", "mingw", "linux", "macosx", function(package)
if package:version():ge("8.0.0") then
package:add("deps", "boost")
package:add("deps", "openssl")
package:add("deps", "zlib")
package:add("deps", "zstd")
package:add("deps", "lz4")
else
package:add("deps", "openssl")
if package:is_plat("linux") then
package:add("deps", "ncurses")
if package:config("server") then
package:add("deps", "icu4c", "protobuf-cpp")
end
if package:config("fido") then
-- TODO: patch cmakelists to find our fido or let it use system libfido2
package:add("deps", "libfido2")
end
end)
on_install("mingw", function (package)
os.cp("lib", package:installdir())
os.cp("include", package:installdir())
os.cp("lib/libmysql.dll", package:installdir("bin"))
end)
if package:config("curl") then
package:add("deps", "libcurl")
end
on_install("windows|x86", "windows|x64", "linux", "macosx", function (package)
if package:version():ge("8.0.0") then
io.gsub("CMakeLists.txt", "ADD_SUBDIRECTORY%(storage/ndb%)", "")
local configs = {"-DCOMPILATION_COMMENT=XMake",
"-DDEFAULT_CHARSET=utf8",
"-DDEFAULT_COLLATION=utf8_general_ci",
"-DINSTALL_DOCDIR=share/doc/#{name}",
"-DINSTALL_INCLUDEDIR=include/mysql",
"-DINSTALL_INFODIR=share/info",
"-DINSTALL_MANDIR=share/man",
"-DINSTALL_MYSQLSHAREDIR=share/mysql",
"-DWITH_EDITLINE=bundled",
"-DWITH_UNIT_TESTS=OFF",
"-DDISABLE_SHARED=" .. (package:config("shared") and "OFF" or "ON"),
"-DWITH_LZ4='system'",
"-DWITH_ZSTD='system'",
"-DWITH_ZLIB='system'",
"-DWINDOWS_RUNTIME_MD=" .. (is_plat("windows") and package:config("vs_runtime"):startswith("MD") and "ON" or "OFF"),
"-DWITHOUT_SERVER=ON"}
io.replace("cmake/ssl.cmake","IF(NOT OPENSSL_APPLINK_C)","IF(FALSE AND NOT OPENSSL_APPLINK_C)", {plain = true})
for _, removelib in ipairs({"icu", "libevent", "re2", "rapidjson", "protobuf", "libedit"}) do
io.replace("CMakeLists.txt", "MYSQL_CHECK_" .. string.upper(removelib) .. "()\n", "", {plain = true})
io.replace("CMakeLists.txt", "INCLUDE(" .. removelib .. ")\n", "", {plain = true})
io.replace("CMakeLists.txt", "WARN_MISSING_SYSTEM_" .. string.upper(removelib) .. "(" .. string.upper(removelib) .. "_WARN_GIVEN)", "# WARN_MISSING_SYSTEM_" .. string.upper(removelib) .. "(" .. string.upper(removelib) .. "_WARN_GIVEN)", {plain = true})
io.replace("CMakeLists.txt", "SET(" .. string.upper(removelib) .. "_WARN_GIVEN)", "# SET(" .. string.upper(removelib) .. "_WARN_GIVEN)", {plain = true})
if package:config("kerberos") then
package:add("deps", "krb5")
end
os.rmdir("extra")
for _, folder in ipairs({"client", "man", "mysql-test", "libbinlogstandalone"}) do
os.rmdir(folder)
io.replace("CMakeLists.txt", "ADD_SUBDIRECTORY(" .. folder .. ")\n", "", {plain = true})
if package:is_cross() then
package:add("deps", "mysql-build-tools")
package:add("patches", "8.0.39", "patches/8.0.39/cmake-cross-compilation.patch", "0f951afce6bcbc5b053d4e7e4aef57f602ff89960d230354f36385ca31c1c7a5")
end
os.rmdir("storage/ndb")
for _, line in ipairs({"INCLUDE(cmake/boost.cmake)\n", "MYSQL_CHECK_EDITLINE()\n"}) do
io.replace("CMakeLists.txt", line, "", {plain = true})
end)
on_install("windows", "macosx", "linux", function (package)
import("patch").cmake(package)
local configs = import("configs").get(package, false)
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DINSTALL_STATIC_LIBRARIES=" .. (package:config("shared") and "OFF" or "ON"))
table.insert(configs, "-DWITH_LTO=" .. (package:config("lto") and "ON" or "OFF"))
table.insert(configs, "-DWITH_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
table.insert(configs, "-DWITH_LSAN=" .. (package:config("lsan") and "ON" or "OFF"))
table.insert(configs, "-DWITH_MSAN=" .. (package:config("msan") and "ON" or "OFF"))
table.insert(configs, "-DWITH_UBSAN=" .. (package:config("ubsan") and "ON" or "OFF"))
if package:is_plat("windows") then
table.insert(configs, "-DLINK_STATIC_RUNTIME_LIBRARIES=" .. (package:has_runtime("MT", "MTd") and "ON" or "OFF"))
end
io.replace("libbinlogevents/CMakeLists.txt", "INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libbinlogevents/include)", "MY_INCLUDE_SYSTEM_DIRECTORIES(LZ4)\nINCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libbinlogevents/include)", {plain = true})
io.replace("cmake/install_macros.cmake", " INSTALL_DEBUG_SYMBOLS("," # INSTALL_DEBUG_SYMBOLS(", {plain = true})
import("package.tools.cmake").install(package, configs)
if package:is_plat("windows") then
if package:config("shared") then
os.rm(package:installdir(path.join("lib", "mysqlclient.lib")))
os.cp(package:installdir(path.join("lib", "libmysql.dll")), package:installdir("bin"))
os.tryrm(package:installdir("lib/mysqlclient.lib"))
os.trymv(package:installdir("lib/libmysql.dll"), package:installdir("bin"))
else
os.rm(package:installdir(path.join("lib", "libmysql.lib")))
os.rm(package:installdir(path.join("lib", "libmysql.dll")))
os.tryrm(package:installdir("lib/libmysql.lib"))
os.tryrm(package:installdir("lib/libmysql.dll"))
end
else
if package:config("shared") then
os.rm(package:installdir(path.join("lib", "*.a")))
os.cp(package:installdir(path.join("lib", "*.so.*")), package:installdir("bin"))
else
os.rm(package:installdir(path.join("lib", "*.so.*")))
end
end
os.tryrm(package:installdir("lib/*.a"))
else
io.gsub("CMakeLists.txt", "ADD_SUBDIRECTORY%(storage/ndb%)", "")
local configs = {"-DCOMPILATION_COMMENT=XMake",
"-DDEFAULT_CHARSET=utf8",
"-DDEFAULT_COLLATION=utf8_general_ci",
"-DINSTALL_DOCDIR=share/doc/#{name}",
"-DINSTALL_INCLUDEDIR=include/mysql",
"-DINSTALL_INFODIR=share/info",
"-DINSTALL_MANDIR=share/man",
"-DINSTALL_MYSQLSHAREDIR=share/mysql",
"-DWITH_BOOST=../boost",
"-DWITH_EDITLINE=" .. (is_plat("macosx") and "system" or "bundled"),
"-DWITH_SSL=yes",
"-DWITH_UNIT_TESTS=OFF",
"-DWITHOUT_SERVER=ON"}
if package:is_plat("linux") then
local curses = package:dep("ncurses"):fetch()
if curses then
local includedirs = table.wrap(curses.sysincludedirs or curses.includedirs)
local libfiles = table.wrap(curses.libfiles)
table.insert(configs, "-DCURSES_INCLUDE_PATH=" .. table.concat(includedirs, ";"))
table.insert(configs, "-DCURSES_LIBRARY=" .. table.concat(libfiles, ";"))
end
os.tryrm(package:installdir("lib/*.so*"))
end
import("package.tools.cmake").install(package, configs)
end
end)
on_test(function (package)
assert(package:has_cfuncs("mysql_init", {includes = "mysql.h"}))
assert(package:check_cxxsnippets({test = [[
#include <mysql.h>
void test() {
MYSQL s;
}
]]}))
end)

@ -51,7 +51,3 @@ package("ncurses")
on_test(function (package)
assert(package:has_cfuncs("initscr", {includes = "curses.h"}))
end)
on_test(function (package)
assert(package:has_cfuncs("initscr", {includes = "curses.h"}))
end)

Loading…
Cancel
Save