xmake.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("marisa")
  2. set_homepage("https://github.com/s-yata/marisa-trie")
  3. set_description("Matching Algorithm with Recursively Implemented StorAge.")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/s-yata/marisa-trie/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/s-yata/marisa-trie.git")
  7. add_versions("v0.3.1", "986ed5e2967435e3a3932a8c95980993ae5a196111e377721f0849cad4e807f3")
  8. add_versions("v0.2.6", "1063a27c789e75afa2ee6f1716cc6a5486631dcfcb7f4d56d6485d2462e566de")
  9. add_versions("v0.3.0", "a3057d0c2da0a9a57f43eb8e07b73715bc5ff053467ee8349844d01da91b5efb")
  10. add_patches("v0.3.0", "patches/v0.3.0/support-debug-install.diff", "a3d02bf6881d233bf8cfadded33edfcde167bee719d47538b869e0e90d8bf7ce")
  11. add_patches("v0.3.0", "https://github.com/s-yata/marisa-trie/pull/119.diff", "f02211699465b55cd2ab93ef20bafcd69aa573da1fd796cb9366697075074093")
  12. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  13. add_deps("cmake")
  14. on_install(function (package)
  15. if package:version() and package:version():lt("v0.3.0") then
  16. os.cp(path.join(package:scriptdir(), "port", "CMakeLists.txt"), "CMakeLists.txt")
  17. end
  18. -- fix install for debug build type
  19. io.replace("CMakeLists.txt", "CONFIGURATIONS Release", "", {plain = true})
  20. local configs = {
  21. "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
  22. "-DENABLE_TESTS=OFF",
  23. "-DBUILD_TESTING=OFF",
  24. }
  25. if package:config("shared") and package:is_plat("windows") then
  26. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  27. end
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. table.insert(configs, "-DENABLE_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  31. table.insert(configs, "-DENABLE_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  32. import("package.tools.cmake").install(package, configs)
  33. if package:version() and package:version():lt("v0.3.0") then
  34. os.tryrm(package:installdir("lib/pkgconfig/marisa.pc"))
  35. end
  36. end)
  37. on_test(function (package)
  38. assert(package:check_cxxsnippets({test = [[
  39. #include <marisa.h>
  40. void test() {
  41. int x = 1, y = 2;
  42. marisa::swap(x, y);
  43. }
  44. ]]}, {configs = {languages = "c++17"}}))
  45. end)