From b61acb689ad956176f1915b8079bc5d2bf4dd4b4 Mon Sep 17 00:00:00 2001 From: toge Date: Sun, 5 Jun 2022 20:04:31 +0900 Subject: [PATCH] (#11010) croncpp: add recipe * croncpp: add recipe * remove build() Co-authored-by: Uilian Ries Co-authored-by: Uilian Ries --- recipes/croncpp/all/CMakeLists.txt | 9 ++++ recipes/croncpp/all/conandata.yml | 4 ++ recipes/croncpp/all/conanfile.py | 45 +++++++++++++++++++ .../croncpp/all/test_package/CMakeLists.txt | 11 +++++ recipes/croncpp/all/test_package/conanfile.py | 16 +++++++ .../croncpp/all/test_package/test_package.cpp | 18 ++++++++ recipes/croncpp/config.yml | 3 ++ 7 files changed, 106 insertions(+) create mode 100644 recipes/croncpp/all/CMakeLists.txt create mode 100644 recipes/croncpp/all/conandata.yml create mode 100644 recipes/croncpp/all/conanfile.py create mode 100644 recipes/croncpp/all/test_package/CMakeLists.txt create mode 100644 recipes/croncpp/all/test_package/conanfile.py create mode 100644 recipes/croncpp/all/test_package/test_package.cpp create mode 100644 recipes/croncpp/config.yml diff --git a/recipes/croncpp/all/CMakeLists.txt b/recipes/croncpp/all/CMakeLists.txt new file mode 100644 index 0000000000..46247ce0c9 --- /dev/null +++ b/recipes/croncpp/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(conan_wrapper CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_CXX_STANDARD 11) + +add_subdirectory(source_subfolder) diff --git a/recipes/croncpp/all/conandata.yml b/recipes/croncpp/all/conandata.yml new file mode 100644 index 0000000000..7f25de8a50 --- /dev/null +++ b/recipes/croncpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220503": + url: "https://github.com/mariusbancila/croncpp/archive/5c28f410db1af9507ef8469c9796a7070e5e8e2e.tar.gz" + sha256: "cabc480c78ebf12b11bd9fcd705a7ecb1c85ac88a8c9debe8de67f30abd808a8" diff --git a/recipes/croncpp/all/conanfile.py b/recipes/croncpp/all/conanfile.py new file mode 100644 index 0000000000..cecf595a5a --- /dev/null +++ b/recipes/croncpp/all/conanfile.py @@ -0,0 +1,45 @@ +import os +import functools +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.33.0" + +class CroncppConan(ConanFile): + name = "croncpp" + description = "A C++11/14/17 header-only cross-platform library for handling CRON expressions" + topics = ("cron", "header-only") + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mariusbancila/croncpp/" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def package(self): + self.copy("LICENSE*", "licenses", self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) diff --git a/recipes/croncpp/all/test_package/CMakeLists.txt b/recipes/croncpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..1bb4c146bf --- /dev/null +++ b/recipes/croncpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(croncpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} croncpp::croncpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/croncpp/all/test_package/conanfile.py b/recipes/croncpp/all/test_package/conanfile.py new file mode 100644 index 0000000000..6cae150e67 --- /dev/null +++ b/recipes/croncpp/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class CroncppConan(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 tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/croncpp/all/test_package/test_package.cpp b/recipes/croncpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000..f8b277d966 --- /dev/null +++ b/recipes/croncpp/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include + +#include "croncpp.h" + +int main(int argc, const char** argv) { + try { + auto cron = cron::make_cron("* 0/5 * * * ?"); + + auto now = std::time(0); + auto next = cron::cron_next(cron, now); + std::cout << (next - now) << "[sec]" << std::endl; + return 0; + } catch (cron::bad_cronexpr const& ex) { + std::cerr << ex.what() << std::endl; + } + return -1; +} diff --git a/recipes/croncpp/config.yml b/recipes/croncpp/config.yml new file mode 100644 index 0000000000..162ec03638 --- /dev/null +++ b/recipes/croncpp/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220503": + folder: "all"