xmake.lua 3.3 KB

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