Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capnproto support and fix msgpack compilation for reflect-cpp v0.17.0 #6294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/r/reflect-cpp/patches/0.17.0/cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d0904f..751e762 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,8 +172,8 @@ if (REFLECTCPP_MSGPACK)
find_package(msgpack-c CONFIG REQUIRED)
endif()
else()
- if (NOT TARGET msgpack)
- find_package(msgpack CONFIG REQUIRED)
+ if (NOT TARGET msgpack-c)
+ find_package(msgpack-c CONFIG REQUIRED)
endif()
endif()
target_link_libraries(reflectcpp PUBLIC msgpack-c)
40 changes: 36 additions & 4 deletions packages/r/reflect-cpp/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ package("reflect-cpp")
add_versions("v0.11.1", "e45f112fb3f14507a4aa53b99ae2d4ab6a4e7b2d5f04dd06fec00bf7faa7bbdc")
add_versions("v0.10.0", "d2c8876d993ddc8c57c5804e767786bdb46a2bdf1a6cd81f4b14f57b1552dfd7")

add_patches("0.17.0", "patches/0.17.0/cmake.patch", "b5956162feb37a369b80329ee4e56408f9b241001d3d8b8e89e2a4b352579c53")
add_patches("0.16.0", "patches/0.16.0/cmake.patch", "1b2a6e0ed81dd0bd373bd1daaf52010de965f3829e5e19406c53e8ebf0a5b9fc")
add_patches("0.11.1", "patches/0.11.1/cmake.patch", "a43ae2c6de455054ab860adfb309da7bd376c31c493c8bab0ebe07aae0805205")
add_patches("0.10.0", "patches/0.10.0/cmake.patch", "b8929c0a13bd4045cbdeea0127e08a784e2dc8c43209ca9f056fff4a3ab5c4d3")

add_configs("bson", {description = "Enable Bson Support.", default = false, type = "boolean", readonly = true})
add_configs("yyjson", {description = "Enable yyjson Support.", default = true, type = "boolean"})
add_configs("cbor", {description = "Enable Cbor Support.", default = false, type = "boolean"})
add_configs("capnproto", {description = "Enable Capnproto Support.", default = false, type = "boolean"})
add_configs("flatbuffers", {description = "Enable Flexbuffers Support.", default = false, type = "boolean"})
add_configs("msgpack", {description = "Enable Msgpack Support.", default = false, type = "boolean"})
add_configs("xml", {description = "Enable Xml Support.", default = false, type = "boolean"})
Expand All @@ -48,6 +50,9 @@ package("reflect-cpp")
}
]]}, {configs = {languages = "c++20"}}), "package(reflect-cpp) Require at least C++20.")
end
if package:config("capnproto") and package:version() <= "0.16.0" then
raise("package(reflect-cpp): capnproto is not supported for version 0.16.0 and below.")
end
end)

on_load(function (package)
Expand All @@ -59,6 +64,10 @@ package("reflect-cpp")
package:add("deps", "tinycbor")
end

if package:config("capnproto") then
package:add("deps", "capnproto")
end

if package:config("flatbuffers") then
package:add("deps", "flatbuffers")
end
Expand All @@ -83,6 +92,8 @@ package("reflect-cpp")
package:add("deps", "jsoncons")
end



local version = package:version()
if version then
if version:lt("0.13.0") then
Expand Down Expand Up @@ -113,22 +124,25 @@ package("reflect-cpp")
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_BSON=" .. (package:config("bson") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_CBOR=" .. (package:config("cbor") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_CAPNPROTO=" .. (package:config("capnproto") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_FLEXBUFFERS=" .. (package:config("flatbuffers") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_MSGPACK=" .. (package:config("msgpack") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_XML=" .. (package:config("xml") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_TOML=" .. (package:config("toml") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_UBJSON=" .. (package:config("ubjson") and "ON" or "OFF"))
table.insert(configs, "-DREFLECTCPP_YAML=" .. (package:config("yaml") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
else
os.rm("include/thirdparty")
os.cp("include", package:installdir())
end
os.rm("include/thirdparty")
os.cp("include", package:installdir())
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <rfl/json.hpp>
#include <rfl.hpp>
#include <rfl/DefaultIfMissing.hpp>
struct Person {
std::string first_name;
std::string last_name;
Expand All @@ -139,8 +153,8 @@ package("reflect-cpp")
.age = 45};
void test() {
const std::string json_string = rfl::json::write(homer);
auto homer2 = rfl::json::read<Person>(json_string).value();
}
auto homer2 = rfl::json::read<Person, rfl::DefaultIfMissing>(json_string).value();
}
]]}, {configs = {languages = "c++20"}}))
if package:config("msgpack") then
assert(package:check_cxxsnippets({test = [[
Expand All @@ -160,4 +174,22 @@ package("reflect-cpp")
}
]]}, {configs = {languages = "c++20"}}))
end
if package:config("capnproto") then
assert(package:check_cxxsnippets({test = [[
#include <rfl/capnproto.hpp>
#include <rfl.hpp>
struct Person {
std::string first_name;
std::string last_name;
int age;
};
const auto homer = Person{.first_name = "Homer",
.last_name = "Simpson",
.age = 45};
void test() {
std::vector<char> capnproto_str_vec = rfl::capnproto::write(homer);
auto homer2 = rfl::capnproto::read<Person>(capnproto_str_vec).value();
}
]]}, {configs = {languages = "c++20"}}))
end
end)
Loading