xmake.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.1.13", "361136e9c365259397190109d50f8b6a65c628177792273b4acdb6978942b5e7")
  7. add_versions("3.3.4", "ea6a23850d6a2f6f2e0d9e9fdb7d94fe905a4317f73842272cf121ed25903e1f")
  8. add_deps("cmake")
  9. add_linkdirs("lib/mariadb")
  10. if is_plat("windows") then
  11. add_configs("iconv", {description = "Enables character set conversion.", default = false, type = "boolean"})
  12. add_configs("msi", {description = "Build MSI installation package.", default = false, type = "boolean"})
  13. add_configs("rtc", {description = "Enables runtime checks for debug builds.", default = false, type = "boolean"})
  14. add_configs("signcode", {description = "Digitally sign files.", default = false, type = "boolean"})
  15. end
  16. if not is_plat("windows") then
  17. add_configs("mysqlcompat", {description = "Creates libmysql* symbolic links.", default = false, type = "boolean"})
  18. end
  19. add_configs("ssl", {description = "Enables use of TLS/SSL library.", default = not is_plat("bsd"), type = "boolean", readonly = is_plat("bsd")})
  20. add_configs("dyncol", {description = "Enables support of dynamic columns.", default = true, type = "boolean"})
  21. add_configs("curl", {description = "Enables use of curl.", default = true, type = "boolean"})
  22. add_configs("external_zlib", {description = "Enables use of external zlib.", default = false, type = "boolean"})
  23. add_configs("unit_tests", {description = "Build test suite.", default = false, type = "boolean"})
  24. on_load(function (package)
  25. if package:config("shared") then
  26. if package:is_plat("windows") then
  27. package:add("links", "libmariadb")
  28. else
  29. package:add("links", "mariadb")
  30. end
  31. else
  32. package:add("links", "mariadbclient")
  33. if package:is_plat("windows") then
  34. package:add("syslinks", "secur32", "shlwapi")
  35. end
  36. end
  37. local configdeps = {external_zlib = "zlib",
  38. ssl = "openssl"}
  39. for name, dep in pairs(configdeps) do
  40. if package:config(name) then
  41. package:add("deps", dep)
  42. end
  43. end
  44. end)
  45. on_install("bsd", "linux", "windows", function(package)
  46. local configs = {}
  47. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  48. for name, enabled in pairs(package:configs()) do
  49. if not package:extraconf("configs", name, "builtin") then
  50. if enabled then
  51. table.insert(configs, "-DWITH_" .. name:upper() .. "=ON")
  52. else
  53. table.insert(configs, "-DWITH_" .. name:upper() .. "=OFF")
  54. end
  55. end
  56. end
  57. import("package.tools.cmake").install(package, configs)
  58. if package:is_plat("windows") then
  59. for _, lib in ipairs(os.files(path.join(package:installdir("lib"), "mariadb", "*.lib"))) do
  60. os.trycp(lib, path.join(package:installdir("lib"), path.filename(lib)))
  61. end
  62. else
  63. for _, lib in ipairs(os.files(path.join(package:installdir("lib"), "mariadb", "*.a"))) do
  64. os.trycp(lib, path.join(package:installdir("lib"), path.filename(lib)))
  65. end
  66. end
  67. if package:config("shared") then
  68. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.dll"), package:installdir("bin"))
  69. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.so"), package:installdir("bin"))
  70. os.cp(path.join(package:installdir("lib"), "mariadb", "plugin"), package:installdir("bin"))
  71. end
  72. end)
  73. on_test(function (package)
  74. assert(package:has_cxxfuncs("mysql_init", {includes = "mariadb/mysql.h"}))
  75. end)