-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
ea12e0f
commit f5f4c6f
Showing
6 changed files
with
508 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.