Browse Source

update xmake.lua: more stringent checks on C++20 support for pyincpp (#4073)

* more stringent checks on C++20 support

* 1 failing check: network problems, restart the tests

* 1 failing check: network problems, restart the tests again

* Update xmake.lua

* Update xmake.lua

* Add checks for std::input_iterator and default cmp in C++20 for some old platforms

* make vs2019 checks pass and more checks on cmp

* reduce tests and use static_assert

* fix TestCmp

* fix TestCmp...

* include cassert

* move msg to assert, make assert in func

* refine checks

* TestCmp need std::string

---------

Co-authored-by: ruki <[email protected]>
Chobits 1 year ago
parent
commit
251454d599
1 changed files with 16 additions and 8 deletions
  1. 16 8
      packages/p/pyincpp/xmake.lua

+ 16 - 8
packages/p/pyincpp/xmake.lua

@@ -13,15 +13,23 @@ package("pyincpp")
     add_versions("v1.3.3", "2689349de9faa35d8bbefddcc7d29d49308a2badd58961cc2b1a8f80c96d0823")
     add_versions("v1.3.2", "687148704f278c292962cffe1f440e5a4cc33f2a82f5e5a17b23aab88a282951")
 
-    -- Some old platforms cannot support the C++20 standard well
+    -- Some old platforms don't support the C++20 standard well.
     if on_check then
-        on_check("android", "macosx", function (package)
+        on_check(function (package)
             if package:version():ge("2.0.0") then
                 assert(package:check_cxxsnippets({test = [[
-                    #if !((defined(_MSVC_LANG) && _MSVC_LANG > 201703L) || __cplusplus > 201703L)
-                    #error "Require at least C++20."
-                    #endif
-                ]]}, {configs = {languages = "c++20"}}))
+                    #include <iterator>
+                    template <std::input_iterator InputIt>
+                    void test_concept(InputIt) {}
+
+                    #include <set>
+                    #include <string>
+                    struct TestCmp {
+                        std::string str_;
+                        auto operator<=>(const TestCmp&) const = default;
+                    };
+                    std::set<TestCmp> s = {TestCmp(), TestCmp()};
+                ]]}, {configs = {languages = "c++20"}}), "Require supports C++20 standard.")
             end
         end)
     end
@@ -29,7 +37,7 @@ package("pyincpp")
     on_install(function (package)
         if package:version():ge("2.0.0") then
             os.cp("sources/*.hpp", package:installdir("include/"))
-        else -- v1.x.x
+        else
             os.cp("sources/*.hpp", package:installdir("include/pyincpp/"))
         end
     end)
@@ -45,7 +53,7 @@ package("pyincpp")
                     assert(dict["third"][-1].factorial() == 120);
                 }
             ]]}, {configs = {languages = "c++20"}, includes = "pyincpp.hpp"}))
-        else -- v1.x.x
+        else
             assert(package:check_cxxsnippets({test = [[
                 #include <cassert>
                 using namespace pyincpp;