Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quill: add version 4.3.0 #24070

Merged
merged 11 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 3 additions & 57 deletions recipes/quill/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
sources:
"3.9.0":
url: "https://github.com/odygrd/quill/archive/v3.9.0.tar.gz"
sha256: "6e6a46dc6ae94e8321aca00d27dae754dcc51ee83fe60078f8f1f3eb7b3b227b"
"3.8.0":
url: "https://github.com/odygrd/quill/archive/v3.8.0.tar.gz"
sha256: "d3e1b349c5d6904c9644e5b79ec65f21692e8094a3d75241a7fe071076eef4dd"
"3.7.0":
url: "https://github.com/odygrd/quill/archive/v3.7.0.tar.gz"
sha256: "53afe555c32b4263c9d31ec11bd0d858983374af7a5e79eb26124f803b192515"
"3.6.0":
url: "https://github.com/odygrd/quill/archive/v3.6.0.tar.gz"
sha256: "ba9dc3df262f2e65c57904580cc8407eba9a462001340c17bab7ae1dccddb4bd"
"3.5.1":
url: "https://github.com/odygrd/quill/archive/v3.5.1.tar.gz"
sha256: "9fa4ebe594c66ce2a409630c304724fa7a2ada0d842ba9c9aaf05f0a90b461f9"
"3.5.0":
url: "https://github.com/odygrd/quill/archive/v3.5.0.tar.gz"
sha256: "47a69465cddeb05645745bed0b3099b49cb627464782f765ce9545723ff1fe84"
"3.4.1":
url: "https://github.com/odygrd/quill/archive/v3.4.1.tar.gz"
sha256: "99f6497b8ba37c30c871fab89f14cd7bc989f3eaa921ccd940a521ee60a6a1c5"
"3.4.0":
url: "https://github.com/odygrd/quill/archive/v3.4.0.tar.gz"
sha256: "16a6cfadc288953f07d128bb51e8ebd4ca6bb8ce4175b5a8af53ce7dde324d8d"
"3.3.1":
url: "https://github.com/odygrd/quill/archive/v3.3.1.tar.gz"
sha256: "f929d54a115b45c32dd2acd1a9810336d35c31fde9f5581c51ad2b80f980d0d1"
"3.2.0":
url: "https://github.com/odygrd/quill/archive/v3.2.0.tar.gz"
sha256: "9745ad83b285bbd0481bd14c1b866b7e6121a981dd211b914f5d55955040fd00"
"3.1.0":
url: "https://github.com/odygrd/quill/archive/v3.1.0.tar.gz"
sha256: "9e7aa64c4f8101ed2b59d1cf3156b1c6bdd712ca89a2ec7aa7166905edc3e621"
"3.0.2":
url: "https://github.com/odygrd/quill/archive/v3.0.2.tar.gz"
sha256: "76e9f607168f71cf1028ae7374fbe91225e400c11b5a51a6ebc992c85d012eed"
"2.9.2":
url: "https://github.com/odygrd/quill/archive/v2.9.2.tar.gz"
sha256: "5b5b502f33277d1ebdb39d57898b1ca25affef4819d390927499f368dd562d91"
"2.9.1":
url: "https://github.com/odygrd/quill/archive/v2.9.1.tar.gz"
sha256: "921e053118136f63cebb2ca1d7e42456fd0bf9626facb755884709092753c054"
"2.9.0":
url: "https://github.com/odygrd/quill/archive/v2.9.0.tar.gz"
sha256: "dec64c0fbb4bfbafe28fdeeeefac10206285bf2be4a42ec5dfb7987ca4ccb372"
"2.8.0":
url: "https://github.com/odygrd/quill/archive/v2.8.0.tar.gz"
sha256: "0461a6c314e3d882f3b9ada487ef1bf558925272509ee41a9fd25f7776db6075"
"2.7.0":
url: "https://github.com/odygrd/quill/archive/v2.7.0.tar.gz"
sha256: "10b8912e4c463a3a86b809076b95bec49aa08393d9ae6b92196cd46314236b87"
"2.6.0":
url: "https://github.com/odygrd/quill/archive/v2.6.0.tar.gz"
sha256: "d72fd5a01bf8d3e59ed93a789a8f103bc31efe0fb3c09182c74036a2e3a8451b"
"1.7.3":
url: "https://github.com/odygrd/quill/archive/v1.7.3.tar.gz"
sha256: "3fff0c5ffb19bbde5429369079741f84a6acce3a781b504cec5e677b05461208"
"4.3.0":
url: "https://github.com/odygrd/quill/archive/v4.3.0.tar.gz"
sha256: "c97bf3bfac6dfb7ed77fa08d945a490e302ba07e405539fda61985b39750cb29"
132 changes: 23 additions & 109 deletions recipes/quill/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import get, copy, rmdir, replace_in_file
from conan.tools.files import get, copy, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.microsoft import is_msvc
from conan.tools.layout import basic_layout

import os

Expand All @@ -16,60 +15,28 @@ class QuillConan(ConanFile):
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/odygrd/quill/"
topics = ("logging", "log", "async")
package_type = "static-library"
topics = ("logging", "log", "async", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"with_bounded_queue": [True, False],
"with_no_exceptions": [True, False],
"with_x86_arch": [True, False],
"with_bounded_blocking_queue": [True, False],
}
default_options = {
"fPIC": True,
"with_bounded_queue": False,
"with_no_exceptions": False,
"with_x86_arch": False,
"with_bounded_blocking_queue": False,
}

@property
def _min_cppstd(self):
return "17" if Version(self.version) >= "2.0.0" else "14"
return "17"

@property
def _compilers_minimum_versions(self):
return {
"14":
{
"gcc": "5",
"Visual Studio": "15",
"clang": "5",
"apple-clang": "10",
},
"17":
{
"gcc": "8",
"Visual Studio": "16",
"clang": "7",
"apple-clang": "12",
},
"gcc": "8",
"Visual Studio": "16",
"clang": "7",
"apple-clang": "12",
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if Version(self.version) < "2.8.0":
del self.options.with_bounded_blocking_queue

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

def requirements(self):
self.requires("fmt/10.2.1", transitive_headers=True)
def package_id(self):
self.info.clear()

def validate(self):
supported_archs = ["x86", "x86_64", "armv6", "armv7", "armv7hf", "armv8"]
Expand All @@ -80,95 +47,42 @@ def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

compilers_minimum_version = self._compilers_minimum_versions[self._min_cppstd]
compilers_minimum_version = self._compilers_minimum_versions
minimum_version = compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version:
if Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")
else:
self.output.warning(f"{self.ref} requires C++{self._min_cppstd}. Your compiler is unknown. Assuming it supports C++{self._min_cppstd}.")

if Version(self.version) >= "2.0.0" and \
self.settings.compiler== "clang" and Version(self.settings.compiler.version).major == "11" and \
if self.settings.compiler== "clang" and Version(self.settings.compiler.version).major == "11" and \
self.settings.compiler.libcxx == "libstdc++":
raise ConanInvalidConfiguration(f"{self.ref} requires C++ filesystem library, which your compiler doesn't support.")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def is_quilll_x86_arch(self):
if not self.options.with_x86_arch:
return False
if Version(self.version) < "2.7.0":
return False
if self.settings.arch not in ("x86", "x86_64"):
return False
if self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libc++":
return False
if is_msvc(self):
return False
return True

def generate(self):
tc = CMakeToolchain(self)
tc.variables["QUILL_FMT_EXTERNAL"] = True
tc.variables["QUILL_ENABLE_INSTALL"] = True
if Version(self.version) < "2.8.0":
tc.variables["QUILL_USE_BOUNDED_QUEUE"] = self.options.with_bounded_queue
else:
if self.options.with_bounded_queue:
tc.preprocessor_definitions["QUILL_USE_BOUNDED_QUEUE"] = 1
tc.variables["QUILL_NO_EXCEPTIONS"] = self.options.with_no_exceptions
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
if self.is_quilll_x86_arch():
if Version(self.version) < "2.8.0":
tc.variables["QUILL_X86ARCH"] = True
else:
tc.preprocessor_definitions["QUILL_X86ARCH"] = 1
tc.variables["CMAKE_CXX_FLAGS"] = "-mclflushopt"
if Version(self.version) >= "2.8.0" and self.options.get_safe("with_bounded_blocking_queue"):
tc.preprocessor_definitions["QUILL_USE_BOUNDED_BLOCKING_QUEUE"] = 1
if Version(self.version) >= "3.2.0":
tc.variables["QUILL_DISABLE_POSITION_INDEPENDENT_CODE"] = not self.options.get_safe("fPIC")
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def _patch_sources(self):
# remove bundled fmt
rmdir(self, os.path.join(self.source_folder, "quill", "quill", "include", "quill", "bundled", "fmt"))
rmdir(self, os.path.join(self.source_folder, "quill", "quill", "src", "bundled", "fmt"))

if "2.0.0" <= Version(self.version) < "2.9.1":
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"""set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/quill/cmake" CACHE STRING "Modules for CMake" FORCE)""",
"""set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}/quill/cmake")"""
)

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
copy(
self,
"*.h",
os.path.join(self.source_folder, "quill", "include"),
os.path.join(self.package_folder, "include"),
)

rmdir(self, os.path.join(self.package_folder, "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs = ["quill"]
self.cpp_info.defines.append("QUILL_FMT_EXTERNAL")
if self.is_quilll_x86_arch():
self.cpp_info.defines.append("QUILL_X86ARCH")
self.cpp_info.cxxflags.append("-mclflushopt")
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("pthread")
if Version(self.version) >= "2.0.0" and \
self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "8":
if self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "8":
self.cpp_info.system_libs.append("stdc++fs")
11 changes: 3 additions & 8 deletions recipes/quill/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ project(test_package LANGUAGES CXX)
find_package(quill REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)

target_link_libraries(${PROJECT_NAME} PRIVATE quill::quill)
if(quill_VERSION VERSION_GREATER_EQUAL "2.0.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
endif()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_compile_definitions(${PROJECT_NAME} PRIVATE QUILL_FILE_HANDLERS_API_V3_3)

if(quill_VERSION VERSION_GREATER_EQUAL "3.3.0")
target_compile_definitions(${PROJECT_NAME} PRIVATE QUILL_FILE_HANDLERS_API_V3_3)
endif()
70 changes: 55 additions & 15 deletions recipes/quill/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,59 @@
#include "quill/Quill.h"
#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include "quill/sinks/ConsoleSink.h"

#include <string>
#include <utility>

/**
* Trivial logging example to console
*/

int main()
{
quill::start();
#ifdef QUILL_FILE_HANDLERS_API_V3_3
auto file_handler = quill::file_handler("logfile.log", []() {
quill::FileHandlerConfig cfg;
cfg.set_open_mode('w');
return cfg;
}());
#else
auto file_handler = quill::file_handler("logfile.log", "w");
#endif
auto my_logger = quill::create_logger("my_logger", std::move(file_handler));

LOG_INFO(my_logger, "Hello from {}", "Quill");
LOG_CRITICAL(my_logger, "This is a conan example {}", 1234);
// Start the backend thread
quill::BackendOptions backend_options;
quill::Backend::start(backend_options);

// Frontend
auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>("sink_id_1");
quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink));

// Change the LogLevel to print everything
logger->set_log_level(quill::LogLevel::TraceL3);

LOG_TRACE_L3(logger, "This is a log trace l3 example {}", 1);
LOG_TRACE_L2(logger, "This is a log trace l2 example {} {}", 2, 2.3);
LOG_TRACE_L1(logger, "This is a log trace l1 {} example", "string");
LOG_DEBUG(logger, "This is a log debug example {}", 4);
LOG_INFO(logger, "This is a log info example {}", sizeof(std::string));
LOG_WARNING(logger, "This is a log warning example {}", sizeof(std::string));
LOG_ERROR(logger, "This is a log error example {}", sizeof(std::string));
LOG_CRITICAL(logger, "This is a log critical example {}", sizeof(std::string));

// libfmt format specification mini language is supported
// note: named arguments are not supported
LOG_INFO(logger, "Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
LOG_INFO(logger, "Easy padding in numbers like {:08d}", 12);
LOG_INFO(logger, "{:>30}", "right aligned");
LOG_INFO(logger, "Positional arguments {1} {2} {0} ", "too", "are", "supported");
LOG_INFO(logger, "Support for precision {:.4f}", 1.23456);

// To log with a different format to the same sink, just create another logger
auto console_sink_2 = quill::Frontend::get_sink("sink_id_1"); // get the created sink
quill::Logger* logger_2 = quill::Frontend::create_or_get_logger(
"logger_2", std::move(console_sink_2), "%(time) %(log_level:<9) %(logger:<12) %(message)");

logger_2->set_log_level(quill::LogLevel::TraceL3);

LOG_TRACE_L3(logger_2, "This is a log trace l3 example {}", 1);
LOG_TRACE_L2(logger_2, "This is a log trace l2 example {} {}", 2, 2.3);
LOG_TRACE_L1(logger_2, "This is a log trace l1 {} example", "string");
LOG_DEBUG(logger_2, "This is a log debug example {}", 4);
LOG_INFO(logger_2, "This is a log info example {}", sizeof(std::string));
LOG_WARNING(logger_2, "This is a log warning example {}", sizeof(std::string));
LOG_ERROR(logger_2, "This is a log error example {}", sizeof(std::string));
LOG_CRITICAL(logger_2, "This is a log critical example {}", sizeof(std::string));
}