xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("pcre")
  2. set_homepage("https://www.pcre.org/")
  3. set_description("A Perl Compatible Regular Expressions Library")
  4. set_urls("https://github.com/xmake-mirror/pcre/releases/download/$(version)/pcre-$(version).tar.bz2")
  5. add_versions("8.45", "4dae6fdcd2bb0bb6c37b5f97c33c2be954da743985369cddac3546e3218bffb8")
  6. if is_plat("windows") then
  7. add_deps("cmake")
  8. end
  9. add_deps("zlib")
  10. add_configs("jit", {description = "Enable jit.", default = true, type = "boolean"})
  11. add_configs("bitwidth", {description = "Set the code unit width.", default = "8", values = {"8", "16", "32"}})
  12. on_load("windows", "mingw", function (package)
  13. if not package:config("shared") then
  14. package:add("defines", "PCRE_STATIC")
  15. end
  16. end)
  17. on_install("windows", function (package)
  18. local configs = {"-DPCRE_BUILD_TESTS=OFF"}
  19. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  20. table.insert(configs, "-DPCRE_SUPPORT_JIT=" .. (package:config("jit") and "ON" or "OFF"))
  21. local bitwidth = package:config("bitwidth") or "8"
  22. if bitwidth ~= "8" then
  23. table.insert(configs, "-DPCRE_BUILD_PCRE8=OFF")
  24. table.insert(configs, "-DPCRE_BUILD_PCRE" .. bitwidth .. "=ON")
  25. end
  26. if package:debug() then
  27. table.insert(configs, "-DPCRE_DEBUG=ON")
  28. end
  29. import("package.tools.cmake").install(package, configs)
  30. end)
  31. on_install("macosx", "linux", "mingw", function (package)
  32. local configs = {}
  33. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  34. if package:config("jit") then
  35. table.insert(configs, "--enable-jit")
  36. end
  37. local bitwidth = package:config("bitwidth") or "8"
  38. if bitwidth ~= "8" then
  39. table.insert(configs, "--disable-pcre8")
  40. table.insert(configs, "--enable-pcre" .. bitwidth)
  41. end
  42. if package:debug() then
  43. table.insert(configs, "--enable-debug")
  44. end
  45. if package:is_plat("linux") and package:config("pic") ~= false then
  46. table.insert(configs, "--with-pic")
  47. end
  48. import("package.tools.autoconf").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. local bitwidth = package:config("bitwidth") or "8"
  52. local testfunc = string.format("pcre%s_compile", bitwidth ~= "8" and bitwidth or "")
  53. assert(package:has_cfuncs(testfunc, {includes = "pcre.h"}))
  54. end)