xmake.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package("mysql-build-tools")
  2. set_kind("binary")
  3. set_homepage("http://www.mysql.com")
  4. set_description("This package help for mysql corss compilation")
  5. set_license("GPL-2.0")
  6. add_urls("https://github.com/mysql/mysql-server/archive/refs/tags/mysql-$(version).tar.gz")
  7. add_versions("8.0.39", "3a72e6af758236374764b7a1d682f7ab94c70ed0d00bf0cb0f7dd728352b6d96")
  8. add_configs("server", {description = "Build server", default = false, type = "boolean"})
  9. add_configs("debug", {description = "Enable debug symbols.", default = false, readonly = true})
  10. add_deps("cmake")
  11. add_deps("zlib", "zstd", "lz4", "openssl", "rapidjson", {host = true, private = true})
  12. if is_plat("linux") then
  13. add_deps("patchelf")
  14. add_deps("libedit", {host = true, private = true, configs = {terminal_db = "ncurses"}})
  15. end
  16. local tool_list = {
  17. "uca9dump",
  18. "comp_sql",
  19. "comp_err",
  20. "comp_client_err",
  21. "libmysql_api_test",
  22. }
  23. on_load(function(package)
  24. if package:config("server") then
  25. table.join2(tool_list, {
  26. "json_schema_embedder",
  27. "gen_lex_token",
  28. "gen_lex_hash",
  29. "gen_keyword_list"
  30. })
  31. end
  32. local version = package:version()
  33. if version:lt("9.0.0") then
  34. package:add("deps", "boost", "libevent", {host = true, private = true})
  35. end
  36. end)
  37. on_install("windows", "macosx", "linux", function (package)
  38. local mysql_script_dir = path.join(path.directory(package:scriptdir()), "mysql")
  39. import("patch", {rootdir = mysql_script_dir})
  40. import("configs", {rootdir = mysql_script_dir})
  41. import("package.tools.cmake")
  42. import("core.base.hashset")
  43. local opt = {}
  44. if cmake.configure then -- xmake 2.9.5
  45. opt.target = tool_list
  46. end
  47. patch.cmake(package)
  48. cmake.build(package, configs.get(package, true), opt)
  49. local hash = hashset.from(tool_list)
  50. local tools_dir = path.join(package:buildir(), "runtime_output_directory/**")
  51. for _, file in ipairs(os.files(tools_dir)) do
  52. if hash:has(path.basename(file)) then
  53. os.vcp(file, package:installdir("bin"))
  54. end
  55. end
  56. end)
  57. on_test(function (package)
  58. for _, name in ipairs(tool_list) do
  59. if is_host("windows") then
  60. name = name .. ".exe"
  61. end
  62. local exec = path.join(package:installdir("bin", name))
  63. assert(os.isexec(exec), name .. " not found!")
  64. end
  65. end)