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

Update logr to v0.6.0 #14878

Merged
merged 4 commits into from
Jan 26, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions recipes/logr/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ sources:
"0.5.1":
url: "https://github.com/ngrodzitski/logr/archive/v0.5.1.tar.gz"
sha256: "674be6a53d5b3f40273b1b5710ac9e32d870827032b5008c41621db47f4b3b0e"
"0.6.0":
url: "https://github.com/ngrodzitski/logr/archive/v0.6.0.tar.gz"
sha256: "2ecb40396add33f2120a79957633533381f3df13cb3b53278eb9dec3a1230eb2"
135 changes: 64 additions & 71 deletions recipes/logr/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get, copy, rmdir
from conan.tools.layout import basic_layout
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.scm import Version
import os

required_conan_version = ">=1.50.0"

class LogrConan(ConanFile):
name = "logr"
Expand All @@ -13,110 +20,96 @@ class LogrConan(ConanFile):
"for server/desktop applications"
)
topics = ("logger", "development", "util", "utils")
generators = "cmake"

settings = "os", "compiler", "build_type", "arch"
no_copy_source = True

options = {"backend": ["spdlog", "glog", "log4cplus", "boostlog", None]}
default_options = {"backend": "spdlog"}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"
def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("fmt/8.1.1")
if Version(self.version) >= "0.6.0":
fmt_ref = "fmt/9.1.0"
spdlog_ref = "spdlog/1.11.0"
else:
fmt_ref = "fmt/8.1.1"
spdlog_ref = "spdlog/1.9.2"

self.requires(fmt_ref)

if self.options.backend == "spdlog":
self.requires("spdlog/1.9.2")
self.requires(spdlog_ref)
elif self.options.backend == "glog":
self.requires("glog/0.5.0")
self.requires("glog/0.6.0")
elif self.options.backend == "log4cplus":
self.requires("log4cplus/2.0.5")
elif self.options.backend == "boostlog":
self.requires("boost/1.77.0")

def configure(self):
def package_id(self):
self.info.settings.clear()
self.info.requires.clear()

def validate(self):
minimal_cpp_standard = "17"
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, minimal_cpp_standard)
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, minimal_cpp_standard)
minimal_version = {
"gcc": "7",
"clang": "7",
"apple-clang": "10",
"Visual Studio": "16",
"gcc": "10",
"clang": "11",
"apple-clang": "12",
}
compiler = str(self.settings.compiler)
if compiler not in minimal_version:
self.output.warn(
(
"%s recipe lacks information about the %s compiler "
"standard version support"
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}."
)
% (self.name, compiler)
)
self.output.warn(
"%s requires a compiler that supports at least C++%s"
% (self.name, minimal_cpp_standard)
)
return

version = tools.Version(self.settings.compiler.version)
if version < minimal_version[compiler]:
raise ConanInvalidConfiguration(
"%s requires a compiler that supports at least C++%s"
% (self.name, minimal_cpp_standard)
)

def _configure_cmake(self):
if self._cmake:
return self._cmake

self._cmake = CMake(self)
self._cmake.definitions["LOGR_WITH_SPDLOG_BACKEND"] = (

def generate(self):
tc = CMakeToolchain(self)
tc.variables["LOGR_WITH_SPDLOG_BACKEND"] = (
self.options.backend == "spdlog"
)
self._cmake.definitions["LOGR_WITH_GLOG_BACKEND"] = (
tc.variables["LOGR_WITH_GLOG_BACKEND"] = (
self.options.backend == "glog"
)
self._cmake.definitions["LOGR_WITH_LOG4CPLUS_BACKEND"] = (
tc.variables["LOGR_WITH_LOG4CPLUS_BACKEND"] = (
self.options.backend == "log4cplus"
)
self._cmake.definitions["LOGR_WITH_BOOSTLOG_BACKEND"] = (
tc.variables["LOGR_WITH_BOOSTLOG_BACKEND"] = (
self.options.backend == "boostlog"
)
tc.variables["LOGR_INSTALL"] = True
tc.variables["LOGR_CONAN_PACKAGING"] = True
tc.variables["LOGR_BUILD_TESTS"] = False
tc.variables["LOGR_BUILD_EXAMPLES"] = False
tc.variables["LOGR_BUILD_BENCHMARKS"] = False
tc.generate()

self._cmake.definitions["LOGR_INSTALL"] = True
self._cmake.definitions["LOGR_CONAN_PACKAGING"] = True
self._cmake.definitions["LOGR_BUILD_TESTS"] = False
self._cmake.definitions["LOGR_BUILD_EXAMPLES"] = False
self._cmake.definitions["LOGR_BUILD_BENCHMARKS"] = False

self._cmake.configure(source_folder=self._source_subfolder)
return self._cmake
deps = CMakeDeps(self)
deps.generate()

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, "logr"))
cmake.install()

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

def package_id(self):
self.info.settings.clear()
rmdir(self, os.path.join(self.package_folder, "lib"))

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"

Expand Down
15 changes: 4 additions & 11 deletions recipes/logr/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
cmake_minimum_required(VERSION 3.8)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(PackageTest CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
project(test_package CXX)

find_package(logr REQUIRED)

add_executable(example example.cpp)
target_link_libraries(example logr::logr)
add_executable(${PROJECT_NAME} example.cpp)
target_link_libraries(${PROJECT_NAME} logr::logr)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
22 changes: 15 additions & 7 deletions recipes/logr/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

class LogrTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
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 not tools.cross_building(self):
bin_path = os.path.join("bin", "example")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/logr/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(logr REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/example.cpp)
target_link_libraries(${PROJECT_NAME} logr::logr)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
16 changes: 16 additions & 0 deletions recipes/logr/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
import os


class LogrTestConan(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):
self.run(os.path.join("bin", "test_package"), run_environment=True)
2 changes: 2 additions & 0 deletions recipes/logr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ versions:
folder: all
"0.5.1":
folder: all
"0.6.0":
folder: all