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

Added support for reflect-cpp v0.14.0; added CBOR and TOML #24819

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions recipes/reflect-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"0.14.0":
url: "https://github.com/getml/reflect-cpp/archive/refs/tags/v0.14.0.tar.gz"
sha256: "ea92a2460a71184b7d4fa4e9baad9910efad092df78b114459a7d6b0ee558d3c"
"0.11.1":
url: "https://github.com/getml/reflect-cpp/archive/v0.11.1.tar.gz"
sha256: "e45f112fb3f14507a4aa53b99ae2d4ab6a4e7b2d5f04dd06fec00bf7faa7bbdc"
Expand Down
123 changes: 85 additions & 38 deletions recipes/reflect-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration

Check warning on line 2 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused ConanInvalidConfiguration imported from conan.errors
from conan.tools.files import get, copy
from conan.tools.build import check_min_cppstd

Check warning on line 4 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused check_min_cppstd imported from conan.tools.build
from conan.tools.scm import Version

Check warning on line 5 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused Version imported from conan.tools.scm
from conan.tools.layout import basic_layout
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
import os

required_conan_version = ">=1.51.1"


class ReflectCppConan(ConanFile):
name = "reflect-cpp"
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", "json", "xml", "flatbuffers", "yaml", "toml", "msgpack", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
version = "0.14.0"

Check failure on line 18 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Recipe should not contain version attribute
topics = (
"reflection",
"serialization",
"memory",
"cbor",
"flatbuffers",
"json",
"msgpack",
"toml",
"xml",
"yaml",
)
package_type = "library"
settings = "os", "compiler", "build_type", "arch"
options = {
"with_json" : [True, False],
"with_xml" : [True, False],
"with_flatbuffers" : [True, False],
"with_yaml": [True, False],
"shared": [True, False],
"fPIC": [True, False],
"with_cbor": [True, False],
"with_flatbuffers": [True, False],
"with_json": [True, False],
"with_msgpack": [True, False],
"with_toml": [True, False],
"with_xml": [True, False],
"with_yaml": [True, False],
}
default_options = {
"with_json" : False,
"with_xml" : False,
"with_flatbuffers" : False,
"with_yaml" : False,
"with_msgpack": False,
"shared": False,
"fPIC": True,
"with_cbor": False,
"with_flatbuffers": False,
"with_json": False,
"with_msgpack": False,
"with_toml": False,
"with_xml": False,
"with_yaml": False,
}

@property
Expand All @@ -46,50 +67,76 @@
"apple-clang": "15",
}

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 layout(self):
basic_layout(self, src_folder="src")
cmake_layout(self)

Check failure on line 79 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

layout is missing `src_folder` argument which should be to `src`

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

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

def package(self):
cmake = CMake(self)
cmake.install()

def requirements(self):
if self.options.with_cbor:
self.requires("tinycbor/0.6.0", transitive_headers=True)
if self.options.with_flatbuffers:
self.requires("flatbuffers/23.5.26", transitive_headers=True)
if self.options.with_json:
self.requires("yyjson/0.8.0", 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_xml:
self.requires("pugixml/1.14", transitive_headers=True)
if self.options.with_flatbuffers:
self.requires("flatbuffers/23.5.26", transitive_headers=True)
if self.options.with_yaml:
self.requires("yaml-cpp/0.8.0", transitive_headers=True)
if self.options.with_msgpack:
self.requires("msgpack-c/6.0.0", transitive_headers=True)

if Version(self.version) >= "0.11.1":
self.requires("ctre/3.9.0", transitive_headers=True)

def package_id(self):
self.info.clear()

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 source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def package(self):

Check failure on line 115 in recipes/reflect-cpp/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

method already defined line 92
copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(
self,
pattern="LICENSE*",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
copy(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for? Why is the CMakeLists needed when consuming this package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, how are supposed to build the package without the CMakeLists.txt?

self,
pattern="CMakeLists.txt",
dst=self.package_folder,
src=self.source_folder,
)
copy(
self,
pattern="*.hpp",
dst=os.path.join(self.package_folder, "include"),
src=os.path.join(self.source_folder, "include"),
)
copy(
self,
pattern="reflectcpp.cpp",
dst=os.path.join(self.package_folder, "src"),
src=os.path.join(self.source_folder, "src"),
)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
if Version(self.version) >= "0.11.1":
self.cpp_info.defines.append("REFLECTCPP_NO_BUNDLED_DEPENDENCIES")
self.cpp_info.libs = ["reflect-cpp"]
12 changes: 0 additions & 12 deletions recipes/reflect-cpp/all/test_package/CMakeLists.txt

This file was deleted.

32 changes: 0 additions & 32 deletions recipes/reflect-cpp/all/test_package/conanfile.py

This file was deleted.

29 changes: 0 additions & 29 deletions recipes/reflect-cpp/all/test_package/test_package.cpp

This file was deleted.

2 changes: 2 additions & 0 deletions recipes/reflect-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.14.0":
folder: all
"0.11.1":
folder: all
"0.11.0":
Expand Down
Loading