From d09a4a88f5febaa0b877b5d681fd47ef8fb6eb6f Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 27 Sep 2022 14:52:12 +0900 Subject: [PATCH 1/6] svector: add recipe --- recipes/svector/all/conandata.yml | 4 ++ recipes/svector/all/conanfile.py | 65 +++++++++++++++++++ .../svector/all/test_package/CMakeLists.txt | 9 +++ recipes/svector/all/test_package/conanfile.py | 27 ++++++++ .../svector/all/test_package/test_package.cpp | 11 ++++ .../all/test_v1_package/CMakeLists.txt | 12 ++++ .../svector/all/test_v1_package/conanfile.py | 18 +++++ recipes/svector/config.yml | 3 + 8 files changed, 149 insertions(+) create mode 100644 recipes/svector/all/conandata.yml create mode 100644 recipes/svector/all/conanfile.py create mode 100644 recipes/svector/all/test_package/CMakeLists.txt create mode 100644 recipes/svector/all/test_package/conanfile.py create mode 100644 recipes/svector/all/test_package/test_package.cpp create mode 100644 recipes/svector/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/svector/all/test_v1_package/conanfile.py create mode 100644 recipes/svector/config.yml diff --git a/recipes/svector/all/conandata.yml b/recipes/svector/all/conandata.yml new file mode 100644 index 0000000000000..876425a447ec4 --- /dev/null +++ b/recipes/svector/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.2": + url: "https://github.com/martinus/svector/archive/refs/tags/v1.0.2.tar.gz" + sha256: "317743113aff89c7c11682ad7ed504a043885be7497f791cb393ba5a7a8d3c41" diff --git a/recipes/svector/all/conanfile.py b/recipes/svector/all/conanfile.py new file mode 100644 index 0000000000000..433683fe46b55 --- /dev/null +++ b/recipes/svector/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.52.0" + + +class PackageConan(ConanFile): + name = "svector" + description = "short description" + license = "Compact SVO optimized vector for C++17 or higher" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/martinus/svector" + topics = ("vector", "container", "small-vector", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15.7", + "msvc": "191", + "gcc": "7", + "clang": "7", + "apple-clang": "10", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/svector/all/test_package/CMakeLists.txt b/recipes/svector/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..38ea734d2c8a7 --- /dev/null +++ b/recipes/svector/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(svector REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE svector::svector) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/svector/all/test_package/conanfile.py b/recipes/svector/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/recipes/svector/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + 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") diff --git a/recipes/svector/all/test_package/test_package.cpp b/recipes/svector/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3e0125d432c37 --- /dev/null +++ b/recipes/svector/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include "ankerl/svector.h" + +int main(void) { + auto vec = ankerl::svector(); + for (int i = 0; i < 100; ++i) { + vec.push_back(i); + } + auto data = vec.data(); + + return 0; +} diff --git a/recipes/svector/all/test_v1_package/CMakeLists.txt b/recipes/svector/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..33ce3d62f2939 --- /dev/null +++ b/recipes/svector/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(svector REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE svector::svector) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/svector/all/test_v1_package/conanfile.py b/recipes/svector/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/svector/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/svector/config.yml b/recipes/svector/config.yml new file mode 100644 index 0000000000000..8457ca9a4a8cd --- /dev/null +++ b/recipes/svector/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.2": + folder: all From 97cd59dfae1ad8ed8b5e29592401203376de787d Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 27 Sep 2022 15:39:27 +0900 Subject: [PATCH 2/6] fix description, license --- recipes/svector/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/svector/all/conanfile.py b/recipes/svector/all/conanfile.py index 433683fe46b55..70de26d7e9023 100644 --- a/recipes/svector/all/conanfile.py +++ b/recipes/svector/all/conanfile.py @@ -12,8 +12,8 @@ class PackageConan(ConanFile): name = "svector" - description = "short description" - license = "Compact SVO optimized vector for C++17 or higher" + description = "Compact SVO optimized vector for C++17 or higher" + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/martinus/svector" topics = ("vector", "container", "small-vector", "header-only") From cc396eaeb8c6403aedbd3ded0f93210f4eab2025 Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 27 Sep 2022 15:45:38 +0900 Subject: [PATCH 3/6] remove unused function --- recipes/svector/all/conanfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/svector/all/conanfile.py b/recipes/svector/all/conanfile.py index 70de26d7e9023..ea656adbb91de 100644 --- a/recipes/svector/all/conanfile.py +++ b/recipes/svector/all/conanfile.py @@ -1,15 +1,14 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.files import get, copy from conan.tools.build import check_min_cppstd from conan.tools.scm import Version from conan.tools.layout import basic_layout -import os +import os required_conan_version = ">=1.52.0" - class PackageConan(ConanFile): name = "svector" description = "Compact SVO optimized vector for C++17 or higher" From f450ce1c92646ed123e4c519eacc596445c78932 Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 27 Sep 2022 23:48:36 +0900 Subject: [PATCH 4/6] remove comment of template Co-authored-by: Uilian Ries --- recipes/svector/all/test_package/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/svector/all/test_package/conanfile.py b/recipes/svector/all/test_package/conanfile.py index 1111583fea732..a9fb96656f203 100644 --- a/recipes/svector/all/test_package/conanfile.py +++ b/recipes/svector/all/test_package/conanfile.py @@ -4,7 +4,6 @@ import os -# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" From c0115c563cf1ca82c33152ceb95e57c9dcd33a49 Mon Sep 17 00:00:00 2001 From: toge Date: Wed, 28 Sep 2022 00:57:12 +0900 Subject: [PATCH 5/6] use `self.info.settings` Co-authored-by: Uilian Ries --- recipes/svector/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/svector/all/conanfile.py b/recipes/svector/all/conanfile.py index ea656adbb91de..1f4372a51f68e 100644 --- a/recipes/svector/all/conanfile.py +++ b/recipes/svector/all/conanfile.py @@ -40,10 +40,10 @@ def package_id(self): self.info.clear() def validate(self): - if self.settings.get_safe("compiler.cppstd"): + if self.info.settings.get_safe("compiler.cppstd"): check_min_cppstd(self, self._minimum_cpp_standard) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.get_safe("compiler.version")) < minimum_version: raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") def source(self): From d4ccea9b0254f4e4c634b71041fb9b762dc93fb7 Mon Sep 17 00:00:00 2001 From: toge Date: Sat, 1 Oct 2022 23:50:37 +0900 Subject: [PATCH 6/6] use self.settings instead of self.info.settings (workaround) --- recipes/svector/all/conanfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/recipes/svector/all/conanfile.py b/recipes/svector/all/conanfile.py index ea656adbb91de..e34f4bcf6acd7 100644 --- a/recipes/svector/all/conanfile.py +++ b/recipes/svector/all/conanfile.py @@ -40,10 +40,11 @@ def package_id(self): self.info.clear() def validate(self): - if self.settings.get_safe("compiler.cppstd"): + # FIXME: self.info.settings.compiler does not work with header-only packages + if self.info.settings.get_safe("compiler.cppstd"): check_min_cppstd(self, self._minimum_cpp_standard) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.get_safe("compiler.version")) < minimum_version: raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") def source(self):