From c947399ee87183eef4cee4e118f21fa10247042f Mon Sep 17 00:00:00 2001 From: fantasy-peak <82742316+fantasy-peak@users.noreply.github.com> Date: Sat, 22 Apr 2023 13:59:22 +0800 Subject: [PATCH] add yaml_cpp_struct (#2014) --- packages/v/visit_struct/xmake.lua | 33 ++++++++++++++++++++++++++++ packages/y/yaml_cpp_struct/xmake.lua | 27 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 packages/v/visit_struct/xmake.lua create mode 100644 packages/y/yaml_cpp_struct/xmake.lua diff --git a/packages/v/visit_struct/xmake.lua b/packages/v/visit_struct/xmake.lua new file mode 100644 index 000000000..ca4a0a933 --- /dev/null +++ b/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 + 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) diff --git a/packages/y/yaml_cpp_struct/xmake.lua b/packages/y/yaml_cpp_struct/xmake.lua new file mode 100644 index 000000000..33f2dcbca --- /dev/null +++ b/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("a.txt"); + } + ]]}, {configs = {languages = "c++17"}, includes = {"yaml_cpp_struct.hpp"}})) + end)