From 796485c519384de71ab5fa05f4ef7dd5dcfaeac9 Mon Sep 17 00:00:00 2001 From: toge Date: Wed, 15 May 2024 01:32:20 +0900 Subject: [PATCH 1/2] mini: add recipe --- recipes/mini/all/conandata.yml | 4 ++ recipes/mini/all/conanfile.py | 65 +++++++++++++++++++ recipes/mini/all/test_package/CMakeLists.txt | 8 +++ recipes/mini/all/test_package/conanfile.py | 26 ++++++++ .../mini/all/test_package/test_package.cpp | 14 ++++ recipes/mini/config.yml | 3 + 6 files changed, 120 insertions(+) create mode 100644 recipes/mini/all/conandata.yml create mode 100644 recipes/mini/all/conanfile.py create mode 100644 recipes/mini/all/test_package/CMakeLists.txt create mode 100644 recipes/mini/all/test_package/conanfile.py create mode 100644 recipes/mini/all/test_package/test_package.cpp create mode 100644 recipes/mini/config.yml diff --git a/recipes/mini/all/conandata.yml b/recipes/mini/all/conandata.yml new file mode 100644 index 0000000000000..da5a086ee7d80 --- /dev/null +++ b/recipes/mini/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.9.15": + url: "https://github.com/metayeti/mINI/archive/refs/tags/0.9.15.tar.gz" + sha256: "241e105ab074827ab8b40582aa7b04c6191f84b244603969965c0874ad4f942c" diff --git a/recipes/mini/all/conanfile.py b/recipes/mini/all/conanfile.py new file mode 100644 index 0000000000000..938a8179ad53f --- /dev/null +++ b/recipes/mini/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.52.0" + +class MiniConan(ConanFile): + name = "mini" + description = "INI file reader and writer" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/metayeti/mINI" + topics = ("ini", "writer", "reader", "header-only") + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 14 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "msvc": "191", + "gcc": "5", + "clang": "5", + "apple-clang": "5.1", + } + + 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 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, "src"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/mini/all/test_package/CMakeLists.txt b/recipes/mini/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b1d6d15b13411 --- /dev/null +++ b/recipes/mini/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(mini REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mini::mini) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/mini/all/test_package/conanfile.py b/recipes/mini/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a91c9439218e --- /dev/null +++ b/recipes/mini/all/test_package/conanfile.py @@ -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") diff --git a/recipes/mini/all/test_package/test_package.cpp b/recipes/mini/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7abe8585a7821 --- /dev/null +++ b/recipes/mini/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include + +#include "mini/ini.h" + +int main(void) { + mINI::INIFile file("test_package.ini"); + + mINI::INIStructure ini; + + ini["things"]["chairs"] = "20"; + ini["things"]["balloons"] = "100"; + + file.generate(ini); +} diff --git a/recipes/mini/config.yml b/recipes/mini/config.yml new file mode 100644 index 0000000000000..0382c3dda0836 --- /dev/null +++ b/recipes/mini/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.15": + folder: all From c69fea3fec59da34b53cc89cec3f4b7fcd5f3c55 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:00:06 +0100 Subject: [PATCH 2/2] Update recipes/mini/all/test_package/test_package.cpp --- recipes/mini/all/test_package/test_package.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/recipes/mini/all/test_package/test_package.cpp b/recipes/mini/all/test_package/test_package.cpp index 7abe8585a7821..ee74c82e08d01 100644 --- a/recipes/mini/all/test_package/test_package.cpp +++ b/recipes/mini/all/test_package/test_package.cpp @@ -5,10 +5,6 @@ int main(void) { mINI::INIFile file("test_package.ini"); - mINI::INIStructure ini; - - ini["things"]["chairs"] = "20"; - ini["things"]["balloons"] = "100"; - - file.generate(ini); + std::cout << "mini test successful \n"; + return 0; }