Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql: rework #4982

Merged
merged 25 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions packages/m/mysql-build-tools/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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)
import("package.tools.cmake")

local mysql_script_dir = path.join(path.directory(package:scriptdir()), "mysql")
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
import("patch", {rootdir = mysql_script_dir}).cmake(package)

local opt = {}
if cmake.configure then -- xmake 2.9.5
opt.target = tool_list
end

local configs = import("configs", {rootdir = mysql_script_dir}).get(package, true)
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
cmake.build(package, configs, opt)

local hash = import("core.base.hashset").from(tool_list)
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
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!")
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
end
end)
62 changes: 62 additions & 0 deletions packages/m/mysql/configs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 = {}

star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
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

table.insert(configs, "-DWITHOUT_SERVER=" .. (package:config("server") and "OFF" or "ON"))

star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
table.join2(configs, (build_host_tool and _host_tool_configs(package) or _target_configs(package)))

star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
return configs
end
52 changes: 52 additions & 0 deletions packages/m/mysql/patch.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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

star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
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()

star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
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

_patch_editline(package)
end
Loading
Loading