Browse Source

add yaml_cpp_struct (#2014)

fantasy-peak 2 years ago
parent
commit
c947399ee8
2 changed files with 60 additions and 0 deletions
  1. 33 0
      packages/v/visit_struct/xmake.lua
  2. 27 0
      packages/y/yaml_cpp_struct/xmake.lua

+ 33 - 0
packages/v/visit_struct/xmake.lua

@@ -0,0 +1,33 @@
+package("visit_struct")
+    set_kind("library", {headeronly = true})
+    set_homepage("https://github.com/cbeck88/visit_struct")
+    set_description("A miniature library for struct-field reflection in C++")
+    set_license("BSL-1.0")
+
+    add_urls("https://github.com/cbeck88/visit_struct/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/garbageslam/visit_struct.git")
+    add_versions('v1.1.0', '73a84f2d8a8844bc03a919163b27ee3b3f85d8c64f6151ce098ca50dbed6be51')
+
+    on_install(function (package)
+        os.cp("include", package:installdir())
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            struct debug_printer {
+                template <typename T>
+                void operator()(const char * name, const T & t) const {
+                  std::cout << "  " << name << ": " << t << std::endl;
+                }
+            };
+            struct test_struct_one {
+                int a;
+                float b;
+            };
+            VISITABLE_STRUCT(test_struct_one, a, b);
+            void test() {
+                test_struct_one my_struct{ 5, 7.5f };
+                visit_struct::for_each(my_struct, debug_printer{});
+            }
+        ]]}, {configs = {languages = "c++11"}, includes = {"visit_struct/visit_struct.hpp", "iostream"}}))
+    end)

+ 27 - 0
packages/y/yaml_cpp_struct/xmake.lua

@@ -0,0 +1,27 @@
+package("yaml_cpp_struct")
+    set_kind("library", {headeronly = true})
+    set_homepage("https://github.com/fantasy-peak/yaml_cpp_struct")
+    set_description("It's easy to mapping yaml to cpp's struct")
+    set_license("MIT")
+
+    add_urls("https://github.com/fantasy-peak/yaml_cpp_struct/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/fantasy-peak/yaml_cpp_struct.git")
+    add_versions('v1.0.2', '7635bb968690f97f9be420e42de2120b1101f0ab20173ddec8d24b5de16f25e5')
+
+    add_deps("magic_enum", "visit_struct", "yaml-cpp")
+
+    on_install("windows", "linux", "macosx", "mingw", function (package)
+        os.cp("include", package:installdir())
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            struct Config {
+                std::string name;
+            };
+            YCS_ADD_STRUCT(Config, name)
+            void test() {
+                auto [cfg, error] = yaml_cpp_struct::from_yaml<Config>("a.txt");
+            }
+        ]]}, {configs = {languages = "c++17"}, includes = {"yaml_cpp_struct.hpp"}}))
+    end)