xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package("re2")
  2. set_homepage("https://github.com/google/re2")
  3. set_description("RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/google/re2/archive/$(version).tar.gz", {version = function (version) return version:gsub("%.", "-") end})
  6. add_versions("2020.11.01", "8903cc66c9d34c72e2bc91722288ebc7e3ec37787ecfef44d204b2d6281954d7")
  7. add_versions("2021.06.01", "26155e050b10b5969e986dab35654247a3b1b295e0532880b5a9c13c0a700ceb")
  8. add_versions("2021.08.01", "cd8c950b528f413e02c12970dce62a7b6f37733d7f68807e73a2d9bc9db79bc8")
  9. add_versions("2021.11.01", "8c45f7fba029ab41f2a7e6545058d9eec94eef97ce70df58e92d85cfc08b4669")
  10. add_versions("2022.02.01", "9c1e6acfd0fed71f40b025a7a1dabaf3ee2ebb74d64ced1f9ee1b0b01d22fd27")
  11. add_versions("2023.11.01", "4e6593ac3c71de1c0f322735bc8b0492a72f66ffccfad76e259fa21c41d27d8a")
  12. add_deps("cmake")
  13. if is_plat("linux") then
  14. add_syslinks("pthread")
  15. end
  16. on_load(function (package)
  17. if package:version():eq("2023.11.01") then
  18. if not package:is_plat("macosx", "linux", "windows", "mingw", "cross") then
  19. raise("re2 2023.11.01 only support macosx linux windows mingw cross")
  20. end
  21. package:add("deps", "abseil")
  22. end
  23. end)
  24. on_install(function (package)
  25. local configs = {"-DRE2_BUILD_TESTING=OFF"}
  26. if package:version():eq("2023.11.01") then
  27. table.insert(configs, "-DCMAKE_CXX_STANDARD=17")
  28. end
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. if package:version():eq("2023.11.01") then
  35. assert(package:check_cxxsnippets({test = [[
  36. #include <string>
  37. #include <cassert>
  38. void test() {
  39. int i;
  40. std::string s;
  41. assert(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i));
  42. assert(s == "ruby");
  43. assert(i == 1234);
  44. }
  45. ]]}, {configs = {languages = "c++17"}, includes = "re2/re2.h"}))
  46. else
  47. assert(package:check_cxxsnippets({test = [[
  48. #include <string>
  49. #include <cassert>
  50. void test() {
  51. int i;
  52. std::string s;
  53. assert(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i));
  54. assert(s == "ruby");
  55. assert(i == 1234);
  56. }
  57. ]]}, {configs = {languages = "c++11"}, includes = "re2/re2.h"}))
  58. end
  59. end)