xmake.lua 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package("pyincpp")
  2. set_homepage("https://github.com/chen-qingyu/pyincpp")
  3. set_description("A C++ type library that is as easy to use as Python built-in types.")
  4. set_kind("library", {headeronly = true})
  5. set_license("MIT")
  6. add_urls("https://github.com/chen-qingyu/pyincpp/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/chen-qingyu/pyincpp.git")
  8. add_versions("v2.6.0", "70d0dba92c51baf3591104e191a899f4f701b1450aa3bc4f9bcfffc532c68c97")
  9. add_versions("v2.5.2", "f99df02c2a2121e2658e770113a8c9ebec5643b81daf82786039653966999f2d")
  10. add_versions("v2.5.1", "305bdf437146e7230c1fc7a1e59009e765468b24133b6def4e17bb01d80f54ad")
  11. add_versions("v2.4.1", "766fc1dec895cf54803bf8ea7f9e86f9aa8e001b38c1f14a88907849e81f634b")
  12. add_versions("v2.4.0", "ae48bc62e9ed8f89e31235ee79385e59b0be6fd6720e8ebe0aa3d10ec7c9fee2")
  13. add_versions("v2.3.0", "e10640c03a6ae9365a299f57a68a5f2a873146b07f92fd33bc4f673e21d68072")
  14. add_versions("v1.6.1", "6a49657cb1f36f4fa400706a631c300771972015b4181f8cc352aa3de7e1a2a3")
  15. add_versions("v1.6.0", "1e8e4bfde447c439974180e206087b309f50ac0e24aeddf39d21d73fd7067368")
  16. add_versions("v1.4.1", "f3de3b5044a5c640811e87782264acbaf14697cd8c35bb21ddcd4de5664a60d0")
  17. add_versions("v1.3.3", "2689349de9faa35d8bbefddcc7d29d49308a2badd58961cc2b1a8f80c96d0823")
  18. add_versions("v1.3.2", "687148704f278c292962cffe1f440e5a4cc33f2a82f5e5a17b23aab88a282951")
  19. -- Some old platforms don't support the C++20 standard well.
  20. if on_check then
  21. on_check(function (package)
  22. if package:version():ge("2.0.0") then
  23. assert(package:check_cxxsnippets({test = [[
  24. #include <iterator>
  25. template <std::input_iterator InputIt>
  26. void test_concept(InputIt) {}
  27. #include <set>
  28. #include <string>
  29. struct TestCmp {
  30. std::string str_;
  31. auto operator<=>(const TestCmp&) const = default;
  32. };
  33. std::set<TestCmp> s = {TestCmp(), TestCmp()};
  34. ]]}, {configs = {languages = "c++20"}}), "Require supports C++20 standard.")
  35. end
  36. end)
  37. end
  38. on_install(function (package)
  39. if package:version():ge("2.0.0") then
  40. os.cp("sources/*.hpp", package:installdir("include/"))
  41. else
  42. os.cp("sources/*.hpp", package:installdir("include/pyincpp/"))
  43. end
  44. end)
  45. on_test(function (package)
  46. if package:version():ge("2.0.0") then
  47. assert(package:check_cxxsnippets({test = [[
  48. #include <cassert>
  49. using namespace pyincpp;
  50. void test() {
  51. Dict<Str, List<Int>> dict = {{"first", {"123", "456"}}, {"second", {"789"}}, {"third", {"12345678987654321", "5"}}};
  52. assert(dict.keys() == Set<Str>({"first", "second", "third"}));
  53. assert(dict["third"][-1].factorial() == 120);
  54. }
  55. ]]}, {configs = {languages = "c++20"}, includes = "pyincpp.hpp"}))
  56. else
  57. assert(package:check_cxxsnippets({test = [[
  58. #include <cassert>
  59. using namespace pyincpp;
  60. void test() {
  61. Map<String, List<Integer>> map = {{"first", {"123", "456"}}, {"second", {"789"}}, {"third", {"12345678987654321", "5"}}};
  62. assert(map.keys() == Set<String>({"first", "second", "third"}));
  63. assert(map["third"][-1].factorial() == 120);
  64. }
  65. ]]}, {configs = {languages = "c++17"}, includes = "pyincpp/pyincpp.hpp"}))
  66. end
  67. end)