Skip to content

Commit

Permalink
(#21876) copypp: new version 0.3.0 (#21875)
Browse files Browse the repository at this point in the history
* copypp: new version 0.3.0 (#21875)

Signed-off-by: i-curve <i-curve@qq.com>

* copypp: limit compiler version

Signed-off-by: i-curve <i-curve@qq.com>

---------

Signed-off-by: i-curve <i-curve@qq.com>
  • Loading branch information
i-curve authored Dec 26, 2023
1 parent 22b4459 commit 6abbea2
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/copypp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.3.0":
url: "https://github.com/i-curve/copypp/archive/v0.3.0.tar.gz"
sha256: "390dc010597f372015a708d7d37e3d06fdf6a4fe90fb1c0077b45b6da5cb38a2"
69 changes: 69 additions & 0 deletions recipes/copypp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os


required_conan_version = ">=1.52.0"


class BasicConanfile(ConanFile):
name = "copypp"
homepage = "https://github.com/i-curve/copypp"
description = "support field copy in different c++ struct."
topics = ("copy", "struct", "header-only")
url = "https://github.com/conan-io/conan-center-index"
license = "MIT"
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _min_cppstd(self):
return 20

@property
def _compilers_minimum_version(self):
return {
"apple-clang": "15",
"clang": "13",
"gcc": "11",
"msvc": "19.3",
"Visual Studio": "17",
}

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

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

def validate(self):
if self.settings.compiler.get_safe("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 build(self):
pass

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*.hh", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
self.cpp_info.set_property("cmake_file_name", "copypp")
self.cpp_info.set_property("cmake_target_name", "icurve::copypp")
self.cpp_info.set_property("pkg_config_name", "copypp")
8 changes: 8 additions & 0 deletions recipes/copypp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(copypp CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE icurve::copypp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
26 changes: 26 additions & 0 deletions recipes/copypp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


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

def layout(self):
cmake_layout(self)

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

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.bindir, "test_package")
self.run(bin_path, env="conanrun")
38 changes: 38 additions & 0 deletions recipes/copypp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <cassert>
#include "icurve/copypp.hh"

class A {
public:
int id;
std::string name;
bool sex;

public:
A() = default;
A(int id, std::string name, bool sex) : id(id), name(name), sex(sex) {}
};

class B {
public:
int id;
std::string name;
bool sex;

public:
B() = default;
B(int id, std::string name, bool sex) : id(id), name(name), sex(sex) {}
};

COPYPP_FIELDS_NON_INTRUSIVE(B, A, id, name, sex)

int main(void) {
A a(1, "curve", true);
B b;
icurve::copy(b, a);
assert(a.id == b.id);
assert(a.name == b.name);
assert(a.sex == b.sex);
std::cout << "copypp ok" << std::endl;
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/copypp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.3.0":
folder: all

0 comments on commit 6abbea2

Please sign in to comment.