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

New recipe: reflectcpp; intended to replace recipe reflect-cpp, which is named incorrectly #24857

Merged
merged 50 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0fe5add
Added a recipe for reflectcpp
liuzicheng1987 Aug 6, 2024
5b594c2
Reduced minimum version required for CMake in the test pipeline
liuzicheng1987 Aug 6, 2024
d8d561a
Even simpler test
liuzicheng1987 Aug 6, 2024
e0ae8fb
Set minimum C++ standard and compiler versions
liuzicheng1987 Aug 6, 2024
f82bb82
Restricted the settings to C++20
liuzicheng1987 Aug 6, 2024
c9ee4a4
Adapted the conanfile in the test package as well
liuzicheng1987 Aug 6, 2024
b67c805
Removed duplicate entries
liuzicheng1987 Aug 6, 2024
d48062d
Use original test package; removed settings
liuzicheng1987 Aug 7, 2024
7a1df97
Added validate
liuzicheng1987 Aug 7, 2024
6f2246d
Added missing imports
liuzicheng1987 Aug 7, 2024
9b72620
PR review
uilianries Aug 7, 2024
6a2baf3
fix old recipe
uilianries Aug 7, 2024
8469e1d
Merge branch 'reflectcpp-0.14.0' into reflectcpp-0.14.0
liuzicheng1987 Aug 7, 2024
2007cf3
Merge pull request #1 from uilianries/reflectcpp-0.14.0
liuzicheng1987 Aug 7, 2024
b47a296
Removed duplicate definition of validate
liuzicheng1987 Aug 7, 2024
207568b
Retrigger the pipeline
liuzicheng1987 Aug 8, 2024
322bd49
Link yyjson in the test environment
liuzicheng1987 Aug 13, 2024
b926c03
Use yyjson 0.8.0
liuzicheng1987 Aug 13, 2024
ac6a679
Link to YYJSON in the test package
liuzicheng1987 Aug 13, 2024
a3dd409
Removed yyjson again
liuzicheng1987 Aug 15, 2024
127b389
Make sure that shared=True compiles as well
liuzicheng1987 Aug 15, 2024
17d98e8
Added upstream fix to make MSVC work
liuzicheng1987 Aug 15, 2024
79e37b7
Format the testfile; retrigger pipeline
liuzicheng1987 Aug 15, 2024
0f59369
Fixed the msvc version
liuzicheng1987 Aug 15, 2024
1c8d106
Always use external dependencies
liuzicheng1987 Sep 23, 2024
dbfe7ac
Link to YYJSON
liuzicheng1987 Sep 23, 2024
d1e1031
Revert "Link to YYJSON"
liuzicheng1987 Sep 23, 2024
e1fa846
Revert "Always use external dependencies"
liuzicheng1987 Sep 23, 2024
5a16fbf
Tried using BUILD_SHARED_LIBS
liuzicheng1987 Nov 9, 2024
98fd462
Go back to old solution, once again
liuzicheng1987 Nov 9, 2024
77626dc
Added version 0.15.0
liuzicheng1987 Nov 9, 2024
c222ca4
Updated config.yml as well
liuzicheng1987 Nov 9, 2024
96f530e
Update recipes/reflectcpp/all/conanfile.py
liuzicheng1987 Nov 18, 2024
629c90d
Always link to ctre and yyjson
liuzicheng1987 Nov 23, 2024
f114de5
Try using the 0.16.0 release candidate
liuzicheng1987 Nov 23, 2024
f4d94c5
Fixed syntax error
liuzicheng1987 Nov 23, 2024
b757c28
Explicitly add yyjson
liuzicheng1987 Nov 23, 2024
6e4b548
Try yyjson 0.10.0
liuzicheng1987 Nov 23, 2024
e5c9555
Added some linker flags to the tests
liuzicheng1987 Nov 23, 2024
1d16667
Added UBJSON support
liuzicheng1987 Nov 23, 2024
8c75f55
Use REFLECTCPP_BUILD_SHARED
liuzicheng1987 Nov 23, 2024
8eb5961
Use the final 0.16.0 release version
liuzicheng1987 Nov 23, 2024
e87ab36
Removed linker flag
liuzicheng1987 Nov 26, 2024
c4503be
Update recipes/reflectcpp/all/conanfile.py
liuzicheng1987 Nov 26, 2024
7f85707
Update recipes/reflectcpp/all/conanfile.py
liuzicheng1987 Nov 26, 2024
22888d9
Added missing import
liuzicheng1987 Nov 26, 2024
ef12bee
Update recipes/reflectcpp/all/conanfile.py
liuzicheng1987 Nov 26, 2024
ebafb6d
Rename to reflect-cpp and use Conan 2.x
uilianries Nov 26, 2024
b735132
Check compiler version
uilianries Nov 26, 2024
20042e3
Require MSVC 194 for now
uilianries Nov 26, 2024
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
4 changes: 4 additions & 0 deletions recipes/reflectcpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.16.0":
url: "https://github.com/getml/reflect-cpp/archive/refs/tags/v0.16.0.tar.gz"
sha256: "a84d94dbd353d788926d6e54507b44c046863f7bc4ecb35afe0338374a68a77d"
148 changes: 148 additions & 0 deletions recipes/reflectcpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
from conan import ConanFile
from conan.tools.files import get, copy, rmdir
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.env import VirtualBuildEnv
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration

import os

required_conan_version = ">=1.54"


class ReflectCppConan(ConanFile):
name = "reflectcpp"
description = "C++-20 library for fast serialization, deserialization and validation using reflection"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/getml/reflect-cpp"
topics = (
"reflection",
"serialization",
"memory",
"cbor",
"flatbuffers",
"json",
"msgpack",
"toml",
"xml",
"yaml",
)
package_type = "library"
settings = "os", "arch", "compiler", "build_type"

options = {
"shared": [True, False],
"fPIC": [True, False],
"with_cbor": [True, False],
"with_flatbuffers": [True, False],
"with_msgpack": [True, False],
"with_toml": [True, False],
"with_ubjson": [True, False],
"with_xml": [True, False],
"with_yaml": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_cbor": False,
"with_flatbuffers": False,
"with_msgpack": False,
"with_toml": False,
"with_ubjson": False,
"with_xml": False,
"with_yaml": False,
}

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def requirements(self):
self.requires("ctre/3.9.0", transitive_headers=True)
self.requires("yyjson/0.10.0", transitive_headers=True)
liuzicheng1987 marked this conversation as resolved.
Show resolved Hide resolved
if self.options.with_cbor:
self.requires("tinycbor/0.6.0", transitive_headers=True)
if self.options.with_flatbuffers:
self.requires("flatbuffers/24.3.25", transitive_headers=True)
if self.options.with_msgpack:
self.requires("msgpack-c/6.0.0", transitive_headers=True)
if self.options.with_toml:
self.requires("tomlplusplus/3.4.0", transitive_headers=True)
if self.options.with_ubjson:
self.requires("jsoncons/0.176.0", transitive_headers=True)
if self.options.with_xml:
self.requires("pugixml/1.14", transitive_headers=True)
if self.options.with_yaml:
self.requires("yaml-cpp/0.8.0", transitive_headers=True)

def build_requirements(self):
self.tool_requires("cmake/[>=3.23 <4]")

def validate(self):
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")

def layout(self):
cmake_layout(self, src_folder="src")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
liuzicheng1987 marked this conversation as resolved.
Show resolved Hide resolved

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
deps = CMakeDeps(self)
liuzicheng1987 marked this conversation as resolved.
Show resolved Hide resolved
deps.generate()
tc = CMakeToolchain(self)
tc.cache_variables["REFLECTCPP_BUILD_SHARED"] = self.options.shared
tc.cache_variables["REFLECTCPP_USE_BUNDLED_DEPENDENCIES"] = False
tc.cache_variables["REFLECTCPP_USE_VCPKG"] = False
tc.cache_variables["REFLECTCPP_CBOR"] = self.options.with_cbor
tc.cache_variables["REFLECTCPP_FLEXBUFFERS"] = self.options.with_flatbuffers
tc.cache_variables["REFLECTCPP_MSGPACK"] = self.options.with_msgpack
tc.cache_variables["REFLECTCPP_TOML"] = self.options.with_toml
tc.cache_variables["REFLECTCPP_XML"] = self.options.with_xml
tc.cache_variables["REFLECTCPP_YAML"] = self.options.with_yaml
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(
self,
pattern="LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs = ["reflectcpp"]

@property
def _min_cppstd(self):
return 20

@property
def _compilers_minimum_version(self):
return {
"Visual Studio": "17",
"msvc": "1938",
"gcc": "11",
"clang": "13",
"apple-clang": "15",
}
9 changes: 9 additions & 0 deletions recipes/reflectcpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(reflectcpp REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} reflectcpp::reflectcpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)

30 changes: 30 additions & 0 deletions recipes/reflectcpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
15 changes: 15 additions & 0 deletions recipes/reflectcpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <cstdlib>
#include <iostream>
#include <string>

#include "rfl.hpp"
#include "rfl/Generic.hpp"
#include "rfl/json.hpp"

int main(void) {
auto person = rfl::Generic::Object();
person["first_name"] = "John";
person["last_name"] = "Doe";
rfl::json::write(person, std::cout) << std::endl;
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/reflectcpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.16.0":
folder: all