From 58ca9916f2c6dff6572938a0a02260c005135459 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Sun, 3 Dec 2023 20:05:59 +0100 Subject: [PATCH 01/14] Add logr v0.7.0 --- recipes/logr/config.yml | 2 + recipes/logr/v0.7/conandata.yml | 4 + recipes/logr/v0.7/conanfile.py | 115 ++++++++++++++++++ recipes/logr/v0.7/test_package/CMakeLists.txt | 8 ++ recipes/logr/v0.7/test_package/conanfile.py | 25 ++++ .../logr/v0.7/test_package/test_package.cpp | 31 +++++ 6 files changed, 185 insertions(+) create mode 100644 recipes/logr/v0.7/conandata.yml create mode 100644 recipes/logr/v0.7/conanfile.py create mode 100644 recipes/logr/v0.7/test_package/CMakeLists.txt create mode 100644 recipes/logr/v0.7/test_package/conanfile.py create mode 100644 recipes/logr/v0.7/test_package/test_package.cpp diff --git a/recipes/logr/config.yml b/recipes/logr/config.yml index 71c5abd93f78c..afa3309f2914c 100644 --- a/recipes/logr/config.yml +++ b/recipes/logr/config.yml @@ -1,4 +1,6 @@ versions: + "0.7.0": + folder: v0.7 "0.6.0": folder: all "0.5.1": diff --git a/recipes/logr/v0.7/conandata.yml b/recipes/logr/v0.7/conandata.yml new file mode 100644 index 0000000000000..745404ba635bc --- /dev/null +++ b/recipes/logr/v0.7/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.7.0": + url: "https://github.com/ngrodzitski/logr/archive/v0.7.0.tar.gz" + sha256: "b43b6624a9223bcb0a11c83afb3df69ef4388d42abef9abb1b80fbc85b890287" diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py new file mode 100644 index 0000000000000..df289268e019f --- /dev/null +++ b/recipes/logr/v0.7/conanfile.py @@ -0,0 +1,115 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy,rm +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +import os + +required_conan_version = ">=1.50.0" + +class LogrConan(ConanFile): + name = "logr" + description = ( + "Logger frontend substitution for spdlog, glog, etc " + "for server/desktop applications" + ) + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ngrodzitski/logr" + topics = ("logger", "development", "util", "utils") + settings = "os", "arch", "compiler", "build_type" + options = { + "backend": ["spdlog", "glog", "log4cplus", "boostlog", None], + } + default_options = { + "backend": "spdlog", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("fmt/10.1.1") + + if self.options.backend == "spdlog": + self.requires("spdlog/1.12.0") + elif self.options.backend == "glog": + self.requires("glog/0.6.0") + elif self.options.backend == "log4cplus": + self.requires("log4cplus/2.1.0") + elif self.options.backend == "boostlog": + self.requires("boost/1.83.0") + + def package_id(self): + self.info.clear() + + def validate(self): + minimal_cpp_standard = "17" + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, minimal_cpp_standard) + minimal_version = { + "gcc": "10", + "clang": "11", + "apple-clang": "12", + } + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = minimal_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires minimum {self.settings.compiler}-{minimum_version}." + ) + + def build(self): + pass + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.*pp", src=os.path.join(self.source_folder, "logr", "include"), dst=os.path.join(self.package_folder, "include")) + + for back in ["spdlog", "glog", "log4cplus", "boostlog"]: + if self.options.backend != back: + rm(self, f"include/logr/{back}_backend.hpp", self.package_folder) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.set_property("cmake_file_name", "logr") + + self.cpp_info.names["cmake_find_package"] = "logr" + self.cpp_info.names["cmake_find_package_multi"] = "logr" + + self.cpp_info.components["logr_base"].includedirs = ["include"] + self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] + + if self.options.backend == "spdlog": + self.cpp_info.components["logr_spdlog"].includedirs = [] + self.cpp_info.components["logr_spdlog"].requires = [ + "logr_base", + "spdlog::spdlog", + ] + elif self.options.backend == "glog": + self.cpp_info.components["logr_glog"].includedirs = [] + self.cpp_info.components["logr_glog"].requires = [ + "logr_base", + "glog::glog", + ] + elif self.options.backend == "log4cplus": + self.cpp_info.components["logr_log4cplus"].includedirs = [] + self.cpp_info.components["logr_log4cplus"].requires = [ + "logr_base", + "log4cplus::log4cplus", + ] + elif self.options.backend == "boostlog": + self.cpp_info.components["logr_boostlog"].includedirs = [] + self.cpp_info.components["logr_boostlog"].requires = [ + "logr_base", + "boost::log", + ] diff --git a/recipes/logr/v0.7/test_package/CMakeLists.txt b/recipes/logr/v0.7/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5e62d2b8b4d92 --- /dev/null +++ b/recipes/logr/v0.7/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(logr REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE logr::logr) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/logr/v0.7/test_package/conanfile.py b/recipes/logr/v0.7/test_package/conanfile.py new file mode 100644 index 0000000000000..f5cf204295e19 --- /dev/null +++ b/recipes/logr/v0.7/test_package/conanfile.py @@ -0,0 +1,25 @@ +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 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.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/logr/v0.7/test_package/test_package.cpp b/recipes/logr/v0.7/test_package/test_package.cpp new file mode 100644 index 0000000000000..1137bf54dc268 --- /dev/null +++ b/recipes/logr/v0.7/test_package/test_package.cpp @@ -0,0 +1,31 @@ +#include + +#include + +#include +#include + +auto make_logger() +{ + auto sink = std::make_shared< spdlog::sinks::stdout_sink_st >(); + sink->set_pattern("[%Y-%m-%d %T][%n][%l] %v [%g]"); + + return logr::spdlog_logger_t<>{ + "console", + std::move( sink ), + logr::log_message_level::trace + }; +} + +int main() +{ + auto logger = make_logger(); + + logger.info( []( auto & out ){ + format_to( out, + "Welcome to logr (v{}.{}.{}), package is provided by Conan!", + LOGR_VERSION_MAJOR, + LOGR_VERSION_MINOR, + LOGR_VERSION_PATCH ); + } ); +} From fdd2b49570adef5a9d747c7e536b651b15e28a31 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Thu, 1 Feb 2024 20:23:40 +0100 Subject: [PATCH 02/14] Add header-only attribute to logr --- recipes/logr/v0.7/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index df289268e019f..53c9d4dee9c63 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -20,6 +20,7 @@ class LogrConan(ConanFile): homepage = "https://github.com/ngrodzitski/logr" topics = ("logger", "development", "util", "utils") settings = "os", "arch", "compiler", "build_type" + package_type = "header-library" options = { "backend": ["spdlog", "glog", "log4cplus", "boostlog", None], } From 60f834c375024ce786a5f0f3616af0cb9f1e8da9 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Mon, 5 Feb 2024 21:09:40 +0100 Subject: [PATCH 03/14] Make fmt version flexible --- recipes/logr/v0.7/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index 53c9d4dee9c63..beae1a26b18f3 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -32,7 +32,7 @@ def layout(self): basic_layout(self, src_folder="src") def requirements(self): - self.requires("fmt/10.1.1") + self.requires("fmt/[>=9.1]") if self.options.backend == "spdlog": self.requires("spdlog/1.12.0") From 229f9590b32864e1ec83d1c109f5412a9f3477e8 Mon Sep 17 00:00:00 2001 From: Nicolai Grodzitski Date: Tue, 6 Feb 2024 23:17:54 +0100 Subject: [PATCH 04/14] Update recipes/logr/v0.7/conanfile.py Co-authored-by: Uilian Ries --- recipes/logr/v0.7/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index beae1a26b18f3..8b78514e9a69b 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -32,7 +32,7 @@ def layout(self): basic_layout(self, src_folder="src") def requirements(self): - self.requires("fmt/[>=9.1]") + self.requires("fmt/10.2.1") if self.options.backend == "spdlog": self.requires("spdlog/1.12.0") From 5c237fe3570ed1551de7999e56742e790318319f Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Wed, 7 Feb 2024 19:47:03 +0100 Subject: [PATCH 05/14] Change backend options arrangement --- recipes/logr/v0.7/conanfile.py | 46 ++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index 8b78514e9a69b..5853c02f01ad6 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -22,10 +22,16 @@ class LogrConan(ConanFile): settings = "os", "arch", "compiler", "build_type" package_type = "header-library" options = { - "backend": ["spdlog", "glog", "log4cplus", "boostlog", None], + "with_spdlog_backend": [True, False], + "with_glog_backend": [True, False], + "with_log4cplus_backend": [True, False], + "with_boostlog_backend": [True, False], } default_options = { - "backend": "spdlog", + "with_spdlog_backend": True, + "with_glog_backend": False, + "with_log4cplus_backend": False, + "with_boostlog_backend": False, } def layout(self): @@ -34,13 +40,16 @@ def layout(self): def requirements(self): self.requires("fmt/10.2.1") - if self.options.backend == "spdlog": + if self.options.with_spdlog_backend: self.requires("spdlog/1.12.0") - elif self.options.backend == "glog": + + if self.options.with_glog_backend: self.requires("glog/0.6.0") - elif self.options.backend == "log4cplus": + + if self.options.with_log4cplus_backend: self.requires("log4cplus/2.1.0") - elif self.options.backend == "boostlog": + + if self.options.with_boostlog_backend: self.requires("boost/1.83.0") def package_id(self): @@ -74,9 +83,17 @@ def package(self): copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) copy(self, "*.*pp", src=os.path.join(self.source_folder, "logr", "include"), dst=os.path.join(self.package_folder, "include")) - for back in ["spdlog", "glog", "log4cplus", "boostlog"]: - if self.options.backend != back: - rm(self, f"include/logr/{back}_backend.hpp", self.package_folder) + if not self.options.with_spdlog_backend: + rm(self, f"include/logr/spdlog_backend.hpp", self.package_folder) + + if not self.options.with_glog_backend: + rm(self, f"include/logr/glog_backend.hpp", self.package_folder) + + if not self.options.with_log4cplus_backend: + rm(self, f"include/logr/log4cplus_backend.hpp", self.package_folder) + + if not self.options.with_boostlog_backend: + rm(self, f"include/logr/boostlog_backend.hpp", self.package_folder) def package_info(self): self.cpp_info.bindirs = [] @@ -90,25 +107,28 @@ def package_info(self): self.cpp_info.components["logr_base"].includedirs = ["include"] self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] - if self.options.backend == "spdlog": + if self.options.with_spdlog_backend: self.cpp_info.components["logr_spdlog"].includedirs = [] self.cpp_info.components["logr_spdlog"].requires = [ "logr_base", "spdlog::spdlog", ] - elif self.options.backend == "glog": + + if self.options.with_glog_backend: self.cpp_info.components["logr_glog"].includedirs = [] self.cpp_info.components["logr_glog"].requires = [ "logr_base", "glog::glog", ] - elif self.options.backend == "log4cplus": + + if self.options.with_log4cplus_backend: self.cpp_info.components["logr_log4cplus"].includedirs = [] self.cpp_info.components["logr_log4cplus"].requires = [ "logr_base", "log4cplus::log4cplus", ] - elif self.options.backend == "boostlog": + + if self.options.with_boostlog_backend: self.cpp_info.components["logr_boostlog"].includedirs = [] self.cpp_info.components["logr_boostlog"].requires = [ "logr_base", From 9714560c33d95a0af269377af6b52ff91e366337 Mon Sep 17 00:00:00 2001 From: Nicolai Grodzitski Date: Thu, 15 Feb 2024 20:16:54 +0100 Subject: [PATCH 06/14] Update recipes/logr/v0.7/conanfile.py Co-authored-by: Uilian Ries --- recipes/logr/v0.7/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index 5853c02f01ad6..b45d222ef6d2b 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -53,7 +53,7 @@ def requirements(self): self.requires("boost/1.83.0") def package_id(self): - self.info.clear() + self.info.settings.clear() def validate(self): minimal_cpp_standard = "17" From c32db33ce108766c499fddaa66e726ed912dffe6 Mon Sep 17 00:00:00 2001 From: Nicolai Grodzitski Date: Thu, 15 Feb 2024 20:17:21 +0100 Subject: [PATCH 07/14] Update recipes/logr/v0.7/conanfile.py Co-authored-by: Uilian Ries --- recipes/logr/v0.7/conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index b45d222ef6d2b..1e98f0bb6ef6b 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -97,12 +97,8 @@ def package(self): def package_info(self): self.cpp_info.bindirs = [] - self.cpp_info.frameworkdirs = [] self.cpp_info.libdirs = [] - self.cpp_info.set_property("cmake_file_name", "logr") - self.cpp_info.names["cmake_find_package"] = "logr" - self.cpp_info.names["cmake_find_package_multi"] = "logr" self.cpp_info.components["logr_base"].includedirs = ["include"] self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] From d166805bede9b6c74833d6d4dffeea05758f1a74 Mon Sep 17 00:00:00 2001 From: Nicolai Grodzitski Date: Thu, 15 Feb 2024 20:17:48 +0100 Subject: [PATCH 08/14] Update recipes/logr/v0.7/conanfile.py Co-authored-by: Uilian Ries --- recipes/logr/v0.7/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index 1e98f0bb6ef6b..c27db334d1c6b 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -83,17 +83,18 @@ def package(self): copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) copy(self, "*.*pp", src=os.path.join(self.source_folder, "logr", "include"), dst=os.path.join(self.package_folder, "include")) + include_folder = os.path.join(self.package_folder, "include", "logr") if not self.options.with_spdlog_backend: - rm(self, f"include/logr/spdlog_backend.hpp", self.package_folder) + rm(self, "spdlog_backend.hpp", include_folder) if not self.options.with_glog_backend: - rm(self, f"include/logr/glog_backend.hpp", self.package_folder) + rm(self, "glog_backend.hpp", include_folder) if not self.options.with_log4cplus_backend: - rm(self, f"include/logr/log4cplus_backend.hpp", self.package_folder) + rm(self, "log4cplus_backend.hpp", include_folder) if not self.options.with_boostlog_backend: - rm(self, f"include/logr/boostlog_backend.hpp", self.package_folder) + rm(self, "boostlog_backend.hpp", include_folder) def package_info(self): self.cpp_info.bindirs = [] From 2b60d0d5653bee7c53ab5f4029311a3e999ab537 Mon Sep 17 00:00:00 2001 From: Nicolai Grodzitski Date: Thu, 15 Feb 2024 20:18:04 +0100 Subject: [PATCH 09/14] Update recipes/logr/v0.7/conanfile.py Co-authored-by: Uilian Ries --- recipes/logr/v0.7/conanfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index c27db334d1c6b..d729427be1045 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -41,16 +41,16 @@ def requirements(self): self.requires("fmt/10.2.1") if self.options.with_spdlog_backend: - self.requires("spdlog/1.12.0") + self.requires("spdlog/1.12.0", transitive_headers=True, transitive_lib=True) if self.options.with_glog_backend: - self.requires("glog/0.6.0") + self.requires("glog/0.6.0", transitive_headers=True, transitive_lib=True) if self.options.with_log4cplus_backend: - self.requires("log4cplus/2.1.0") + self.requires("log4cplus/2.1.0", transitive_headers=True, transitive_lib=True) if self.options.with_boostlog_backend: - self.requires("boost/1.83.0") + self.requires("boost/1.83.0", transitive_headers=True, transitive_lib=True) def package_id(self): self.info.settings.clear() From 21702e850b72a0b638a27ba23047fd05bff5df53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Fri, 16 Feb 2024 01:30:10 +0100 Subject: [PATCH 10/14] Update recipes/logr/v0.7/conanfile.py --- recipes/logr/v0.7/conanfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index d729427be1045..3eb726d197e83 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -41,16 +41,16 @@ def requirements(self): self.requires("fmt/10.2.1") if self.options.with_spdlog_backend: - self.requires("spdlog/1.12.0", transitive_headers=True, transitive_lib=True) + self.requires("spdlog/1.12.0", transitive_headers=True, transitive_libs=True) if self.options.with_glog_backend: - self.requires("glog/0.6.0", transitive_headers=True, transitive_lib=True) + self.requires("glog/0.6.0", transitive_headers=True, transitive_libs=True) if self.options.with_log4cplus_backend: - self.requires("log4cplus/2.1.0", transitive_headers=True, transitive_lib=True) + self.requires("log4cplus/2.1.0", transitive_headers=True, transitive_libs=True) if self.options.with_boostlog_backend: - self.requires("boost/1.83.0", transitive_headers=True, transitive_lib=True) + self.requires("boost/1.83.0", transitive_headers=True, transitive_libs=True) def package_id(self): self.info.settings.clear() From c1fc66e72f9fd487ea81e77fa2a4d26ef106a02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Fri, 16 Feb 2024 01:33:08 +0100 Subject: [PATCH 11/14] Apply suggestions from code review --- recipes/logr/v0.7/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index 3eb726d197e83..ac923544cf864 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -18,7 +18,7 @@ class LogrConan(ConanFile): license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/ngrodzitski/logr" - topics = ("logger", "development", "util", "utils") + topics = ("logger", "development", "util", "utils", "header-only") settings = "os", "arch", "compiler", "build_type" package_type = "header-library" options = { @@ -41,16 +41,16 @@ def requirements(self): self.requires("fmt/10.2.1") if self.options.with_spdlog_backend: - self.requires("spdlog/1.12.0", transitive_headers=True, transitive_libs=True) + self.requires("spdlog/1.12.0") if self.options.with_glog_backend: - self.requires("glog/0.6.0", transitive_headers=True, transitive_libs=True) + self.requires("glog/0.6.0") if self.options.with_log4cplus_backend: - self.requires("log4cplus/2.1.0", transitive_headers=True, transitive_libs=True) + self.requires("log4cplus/2.1.0") if self.options.with_boostlog_backend: - self.requires("boost/1.83.0", transitive_headers=True, transitive_libs=True) + self.requires("boost/1.83.0") def package_id(self): self.info.settings.clear() From 8ebb4636bdfe7ba876b878b8efac79e32d94f0e3 Mon Sep 17 00:00:00 2001 From: ngrodzitski Date: Mon, 18 Mar 2024 20:15:27 +0100 Subject: [PATCH 12/14] Switch to `with_xxx` dependency definition --- recipes/logr/v0.7/conanfile.py | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index ac923544cf864..d429a1ff1b478 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -22,16 +22,16 @@ class LogrConan(ConanFile): settings = "os", "arch", "compiler", "build_type" package_type = "header-library" options = { - "with_spdlog_backend": [True, False], - "with_glog_backend": [True, False], - "with_log4cplus_backend": [True, False], - "with_boostlog_backend": [True, False], + "with_spdlog": [True, False], + "with_glog": [True, False], + "with_log4cplus": [True, False], + "with_boostlog": [True, False], } default_options = { - "with_spdlog_backend": True, - "with_glog_backend": False, - "with_log4cplus_backend": False, - "with_boostlog_backend": False, + "with_spdlog": True, + "with_glog": False, + "with_log4cplus": False, + "with_boostlog": False, } def layout(self): @@ -40,16 +40,16 @@ def layout(self): def requirements(self): self.requires("fmt/10.2.1") - if self.options.with_spdlog_backend: + if self.options.with_spdlog: self.requires("spdlog/1.12.0") - if self.options.with_glog_backend: + if self.options.with_glog: self.requires("glog/0.6.0") - if self.options.with_log4cplus_backend: + if self.options.with_log4cplus: self.requires("log4cplus/2.1.0") - if self.options.with_boostlog_backend: + if self.options.with_boostlog: self.requires("boost/1.83.0") def package_id(self): @@ -84,16 +84,16 @@ def package(self): copy(self, "*.*pp", src=os.path.join(self.source_folder, "logr", "include"), dst=os.path.join(self.package_folder, "include")) include_folder = os.path.join(self.package_folder, "include", "logr") - if not self.options.with_spdlog_backend: + if not self.options.with_spdlog: rm(self, "spdlog_backend.hpp", include_folder) - if not self.options.with_glog_backend: + if not self.options.with_glog: rm(self, "glog_backend.hpp", include_folder) - if not self.options.with_log4cplus_backend: + if not self.options.with_log4cplus: rm(self, "log4cplus_backend.hpp", include_folder) - if not self.options.with_boostlog_backend: + if not self.options.with_boostlog: rm(self, "boostlog_backend.hpp", include_folder) def package_info(self): @@ -104,28 +104,28 @@ def package_info(self): self.cpp_info.components["logr_base"].includedirs = ["include"] self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] - if self.options.with_spdlog_backend: + if self.options.with_spdlog: self.cpp_info.components["logr_spdlog"].includedirs = [] self.cpp_info.components["logr_spdlog"].requires = [ "logr_base", "spdlog::spdlog", ] - if self.options.with_glog_backend: + if self.options.with_glog: self.cpp_info.components["logr_glog"].includedirs = [] self.cpp_info.components["logr_glog"].requires = [ "logr_base", "glog::glog", ] - if self.options.with_log4cplus_backend: + if self.options.with_log4cplus: self.cpp_info.components["logr_log4cplus"].includedirs = [] self.cpp_info.components["logr_log4cplus"].requires = [ "logr_base", "log4cplus::log4cplus", ] - if self.options.with_boostlog_backend: + if self.options.with_boostlog: self.cpp_info.components["logr_boostlog"].includedirs = [] self.cpp_info.components["logr_boostlog"].requires = [ "logr_base", From fa5d5792a2dab1039d7ff0ad7051b72b87f94030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Wed, 29 May 2024 15:55:08 +0200 Subject: [PATCH 13/14] Fix test_package --- recipes/logr/v0.7/conanfile.py | 41 ++-- .../logr/v0.7/test_package/test_package.cpp | 192 ++++++++++++++++-- 2 files changed, 195 insertions(+), 38 deletions(-) diff --git a/recipes/logr/v0.7/conanfile.py b/recipes/logr/v0.7/conanfile.py index d429a1ff1b478..7eee46ae5d249 100644 --- a/recipes/logr/v0.7/conanfile.py +++ b/recipes/logr/v0.7/conanfile.py @@ -1,14 +1,15 @@ from conan import ConanFile from conan.tools.build import check_min_cppstd -from conan.tools.files import get, copy,rm +from conan.tools.files import get, copy, rm from conan.tools.layout import basic_layout from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration -from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.microsoft import check_min_vs import os required_conan_version = ">=1.50.0" + class LogrConan(ConanFile): name = "logr" description = ( @@ -34,6 +35,18 @@ class LogrConan(ConanFile): "with_boostlog": False, } + @property + def _min_cppstd(self): + return 17 + + @property + def _minimum_compilers_version(self): + return { + "gcc": "10", + "clang": "11", + "apple-clang": "12", + } + def layout(self): basic_layout(self, src_folder="src") @@ -56,28 +69,23 @@ def package_id(self): self.info.settings.clear() def validate(self): - minimal_cpp_standard = "17" if self.settings.get_safe("compiler.cppstd"): - check_min_cppstd(self, minimal_cpp_standard) - minimal_version = { - "gcc": "10", - "clang": "11", - "apple-clang": "12", - } + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) - if not is_msvc(self): - minimum_version = minimal_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration( - f"{self.ref} requires minimum {self.settings.compiler}-{minimum_version}." - ) + + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires minimum {self.settings.compiler} version of {minimum_version}" + ) def build(self): pass def source(self): get(self, **self.conan_data["sources"][self.version], - destination=self.source_folder, strip_root=True) + destination=self.source_folder, strip_root=True) def package(self): copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) @@ -100,7 +108,6 @@ def package_info(self): self.cpp_info.bindirs = [] self.cpp_info.libdirs = [] - self.cpp_info.components["logr_base"].includedirs = ["include"] self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] diff --git a/recipes/logr/v0.7/test_package/test_package.cpp b/recipes/logr/v0.7/test_package/test_package.cpp index 1137bf54dc268..bf691ad50bc98 100644 --- a/recipes/logr/v0.7/test_package/test_package.cpp +++ b/recipes/logr/v0.7/test_package/test_package.cpp @@ -1,31 +1,181 @@ +// Logger frontend library for C++. +// +// Copyright (c) 2020 - present, Nicolai Grodzitski +// See LICENSE file in the root of the project. + + #include -#include +#include +#include -#include -#include -auto make_logger() -{ - auto sink = std::make_shared< spdlog::sinks::stdout_sink_st >(); - sink->set_pattern("[%Y-%m-%d %T][%n][%l] %v [%g]"); +int main() { + auto logger = logr::basic_ostream_logger_t<1024u>(std::cout); + logger.trace( "Hello World! [raw message]" ); + logger.trace( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - return logr::spdlog_logger_t<>{ - "console", - std::move( sink ), - logr::log_message_level::trace - }; -} + logger.trace( []() { return "Hello World! [cb]"; } ); + logger.trace( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.trace( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.trace( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.trace( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); + } ); + + logger.trace( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.debug( "Hello World! [raw message]" ); + logger.debug( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); + + logger.debug( []() { return "Hello World! [cb]"; } ); + logger.debug( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.debug( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.debug( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + logger.debug( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); + } ); + + logger.debug( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.info( "Hello World! [raw message]" ); + logger.info( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); + + logger.info( []() { return "Hello World! [cb]"; } ); + logger.info( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.info( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.info( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + logger.info( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); + } ); + + logger.info( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.warn( "Hello World! [raw message]" ); + logger.warn( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); -int main() -{ - auto logger = make_logger(); + logger.warn( []() { return "Hello World! [cb]"; } ); + logger.warn( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.warn( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.warn( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + logger.warn( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); + } ); - logger.info( []( auto & out ){ + logger.warn( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.error( "Hello World! [raw message]" ); + logger.error( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); + + logger.error( []() { return "Hello World! [cb]"; } ); + logger.error( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.error( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.error( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + logger.error( LOGR_SRC_LOCATION, []( auto out ) { format_to( out, - "Welcome to logr (v{}.{}.{}), package is provided by Conan!", - LOGR_VERSION_MAJOR, - LOGR_VERSION_MINOR, - LOGR_VERSION_PATCH ); + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); } ); + + logger.error( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.critical( "Hello World! [raw message]" ); + logger.critical( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); + + logger.critical( []() { return "Hello World! [cb]"; } ); + logger.critical( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); + + logger.critical( []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + + logger.critical( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); + } ); + logger.critical( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + FMT_STRING( "Hello {}! [{}]" ), + "World", + "cb with explicit out and FMT_STRING" ); + } ); + + logger.critical( LOGR_SRC_LOCATION, []( auto out ) { + format_to( out, + fmt::runtime( "Hello {}! [{}]" ), + "World", + "cb with explicit out and runtime-string" ); + } ); + + logger.flush(); + + return 0; } From 289732e49baa594c7c30bb78a01d50e1ceb6ee1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Wed, 29 May 2024 16:02:00 +0200 Subject: [PATCH 14/14] Simplify test_package --- .../logr/v0.7/test_package/test_package.cpp | 137 +----------------- 1 file changed, 1 insertion(+), 136 deletions(-) diff --git a/recipes/logr/v0.7/test_package/test_package.cpp b/recipes/logr/v0.7/test_package/test_package.cpp index bf691ad50bc98..27d9ac363797b 100644 --- a/recipes/logr/v0.7/test_package/test_package.cpp +++ b/recipes/logr/v0.7/test_package/test_package.cpp @@ -12,61 +12,7 @@ int main() { auto logger = logr::basic_ostream_logger_t<1024u>(std::cout); - logger.trace( "Hello World! [raw message]" ); - logger.trace( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - - logger.trace( []() { return "Hello World! [cb]"; } ); - logger.trace( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); - - logger.trace( []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.trace( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.trace( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - FMT_STRING( "Hello {}! [{}]" ), - "World", - "cb with explicit out and FMT_STRING" ); - } ); - - logger.trace( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - fmt::runtime( "Hello {}! [{}]" ), - "World", - "cb with explicit out and runtime-string" ); - } ); - - logger.debug( "Hello World! [raw message]" ); - logger.debug( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - - logger.debug( []() { return "Hello World! [cb]"; } ); - logger.debug( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); - - logger.debug( []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.debug( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - logger.debug( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - FMT_STRING( "Hello {}! [{}]" ), - "World", - "cb with explicit out and FMT_STRING" ); - } ); - - logger.debug( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - fmt::runtime( "Hello {}! [{}]" ), - "World", - "cb with explicit out and runtime-string" ); - } ); - + logger.info( "Hello World! [raw message]" ); logger.info( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); @@ -94,87 +40,6 @@ int main() { "cb with explicit out and runtime-string" ); } ); - logger.warn( "Hello World! [raw message]" ); - logger.warn( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - - logger.warn( []() { return "Hello World! [cb]"; } ); - logger.warn( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); - - logger.warn( []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.warn( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - logger.warn( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - FMT_STRING( "Hello {}! [{}]" ), - "World", - "cb with explicit out and FMT_STRING" ); - } ); - - logger.warn( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - fmt::runtime( "Hello {}! [{}]" ), - "World", - "cb with explicit out and runtime-string" ); - } ); - - logger.error( "Hello World! [raw message]" ); - logger.error( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - - logger.error( []() { return "Hello World! [cb]"; } ); - logger.error( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); - - logger.error( []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.error( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - logger.error( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - FMT_STRING( "Hello {}! [{}]" ), - "World", - "cb with explicit out and FMT_STRING" ); - } ); - - logger.error( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - fmt::runtime( "Hello {}! [{}]" ), - "World", - "cb with explicit out and runtime-string" ); - } ); - - logger.critical( "Hello World! [raw message]" ); - logger.critical( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); - - logger.critical( []() { return "Hello World! [cb]"; } ); - logger.critical( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); - - logger.critical( []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - - logger.critical( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); - } ); - logger.critical( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - FMT_STRING( "Hello {}! [{}]" ), - "World", - "cb with explicit out and FMT_STRING" ); - } ); - - logger.critical( LOGR_SRC_LOCATION, []( auto out ) { - format_to( out, - fmt::runtime( "Hello {}! [{}]" ), - "World", - "cb with explicit out and runtime-string" ); - } ); - logger.flush(); return 0;