xmake.lua 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package("mariadb-connector-c")
  2. set_homepage("https://github.com/mariadb-corporation/mariadb-connector-c")
  3. set_description("MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/mariadb-corporation/mariadb-connector-c/archive/refs/tags/v$(version).tar.gz")
  6. add_versions("3.3.9", "062b9ec5c26cbb236a78f0ba26981272053f59bdfc113040bab904a9da36d31f")
  7. add_versions("3.3.4", "ea6a23850d6a2f6f2e0d9e9fdb7d94fe905a4317f73842272cf121ed25903e1f")
  8. add_versions("3.1.13", "361136e9c365259397190109d50f8b6a65c628177792273b4acdb6978942b5e7")
  9. add_deps("cmake")
  10. add_linkdirs("lib/mariadb")
  11. if is_plat("windows") then
  12. add_configs("iconv", {description = "Enables character set conversion.", default = false, type = "boolean"})
  13. add_configs("msi", {description = "Build MSI installation package.", default = false, type = "boolean"})
  14. add_configs("rtc", {description = "Enables runtime checks for debug builds.", default = false, type = "boolean"})
  15. add_configs("signcode", {description = "Digitally sign files.", default = false, type = "boolean"})
  16. end
  17. if not is_plat("windows") then
  18. add_configs("mysqlcompat", {description = "Creates libmysql* symbolic links.", default = false, type = "boolean"})
  19. end
  20. add_configs("ssl", {description = "Enables use of TLS/SSL library.", default = not is_plat("bsd"), type = "boolean", readonly = is_plat("bsd")})
  21. add_configs("dyncol", {description = "Enables support of dynamic columns.", default = true, type = "boolean"})
  22. add_configs("curl", {description = "Enables use of curl.", default = true, type = "boolean"})
  23. add_configs("external_zlib", {description = "Enables use of external zlib.", default = false, type = "boolean"})
  24. add_configs("unit_tests", {description = "Build test suite.", default = false, type = "boolean"})
  25. on_load(function (package)
  26. if package:config("shared") then
  27. if package:is_plat("windows") then
  28. package:add("links", "libmariadb")
  29. else
  30. package:add("links", "mariadb")
  31. end
  32. else
  33. package:add("links", "mariadbclient")
  34. if package:is_plat("windows") then
  35. package:add("syslinks", "secur32", "shlwapi")
  36. end
  37. end
  38. local configdeps = {external_zlib = "zlib",
  39. ssl = "openssl"}
  40. for name, dep in pairs(configdeps) do
  41. if package:config(name) then
  42. package:add("deps", dep)
  43. end
  44. end
  45. end)
  46. on_install("bsd", "linux", "windows", function(package)
  47. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  48. local configs = {}
  49. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  50. for name, enabled in pairs(package:configs()) do
  51. if not package:extraconf("configs", name, "builtin") then
  52. if enabled then
  53. table.insert(configs, "-DWITH_" .. name:upper() .. "=ON")
  54. else
  55. table.insert(configs, "-DWITH_" .. name:upper() .. "=OFF")
  56. end
  57. end
  58. end
  59. import("package.tools.cmake").install(package, configs)
  60. if package:is_plat("windows") then
  61. for _, lib in ipairs(os.files(path.join(package:installdir("lib"), "mariadb", "*.lib"))) do
  62. os.trycp(lib, path.join(package:installdir("lib"), path.filename(lib)))
  63. end
  64. else
  65. for _, lib in ipairs(os.files(path.join(package:installdir("lib"), "mariadb", "*.a"))) do
  66. os.trycp(lib, path.join(package:installdir("lib"), path.filename(lib)))
  67. end
  68. end
  69. if package:config("shared") then
  70. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.dll"), package:installdir("bin"))
  71. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.so"), package:installdir("bin"))
  72. os.cp(path.join(package:installdir("lib"), "mariadb", "plugin"), package:installdir("bin"))
  73. end
  74. end)
  75. on_test(function (package)
  76. assert(package:has_cxxfuncs("mysql_init", {includes = "mariadb/mysql.h"}))
  77. end)