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

Add logr v0.1.0 #3812

Merged
merged 15 commits into from
Dec 14, 2020
Merged

Add logr v0.1.0 #3812

merged 15 commits into from
Dec 14, 2020

Conversation

ngrodzitski
Copy link
Contributor

Specify library name and version: logr/0.1.0

  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the
    conan-center hook activated.

@CLAassistant
Copy link

CLAassistant commented Dec 6, 2020

CLA assistant check
All committers have signed the CLA.

@conan-center-bot
Copy link
Collaborator

All green in build 1 (9bdaddfddfb2c11e4d24fc0201960e18917e43c0)! 😊

recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
Comment on lines 18 to 25
options = { 'spdlog_backend' : [True, False],
'glog_backend' : [True, False],
'log4cplus_backend' : [True, False] }

default_options = { 'spdlog_backend': True,
'glog_backend': True,
'log4cplus_backend': True }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename these options to: spdlog, glog and log4cplus.
Also can all 3 backends be used together, or are they to be used exclusive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of this options is whether the corresponding header file would be installed or not. By default all of them are present.

recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
recipes/logr/0.1.0/test_package/conanfile.py Outdated Show resolved Hide resolved
def _build_subfolder(self):
return "build_subfolder"

def requirements(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised you don't add a requirement on either spdlog, glog or log4plus.
If this is a frontend substitution, then the backend should be available. Isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider the following reasoning:

  • Deciding what logger to use in your application (among the three supported).
  • Once logger library is decided, the application adds it to the list of dependencies (so logger is already in deps list).
  • Then it is decided to use another "frontend" to it.

Deciding the logger happens in the first place (so deps machinery is applied for logger lib), and the logr is like an extension to a selected library.

And in case of using in conanfile it would be less bothering to just specify logr without forcing the user to dig into options.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that logr won't work when having the following conanfile.txt:

[requires]
spdlog/0.1.0
[options]
logr:with_spdlog_backend=True
logr:with_glog_backend=False
logr:with_log4cplus_backend=False

because spdlog is is not available.
I would do this in requirements:

if self.options.with_spdlog_backend:
    self.requires("spdlog/x.y")
elif self.options.with_glog_backend
    self.requires("log4cplus/x.y")
elif self.options.with_log4cplus_backend:
    self.requires("log4cplus/x.y")

Copy link
Contributor Author

@ngrodzitski ngrodzitski Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the following conanfile.txt

[requires]
logr/0.1.0
[options]
logr:spdlog_backend=True
logr:glog_backend=False
logr:log4cplus_backend=False

[generators]
cmake

And a project based on test_project works just fine.

The libs is a collection of headers and it has some options to add a certain headers or not.

Would it be ok to just remove all options and make all headers to be unconditionally present?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How usable is this library without any backend?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be a way, but I think you should also add these library as a requirement of logr. Or shouldn't you?

Copy link
Contributor Author

@ngrodzitski ngrodzitski Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

all is the option for local dev builds. As I want all of them to be available in single build (for examples and benchmarks) and I want to keep local conanfile at most similar to projects own conanfile.

Does Conan introduces dependencie propogation when I specify self.requires("spdlog/x.y")? Or I need to modify projects cmake files and add something like target_link_libraries(logr INTERFACE spdlog::spdlog)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I have given up on keeping project's conanfiles equal to cci's conanfiles.
Mostly because I don't want the project to need a cmake wrapper script, just for conan.

When you add self.requires("spdlog/x.y") to logr,
then linking to the logr::logr cmake target will also link to spdlog::spdlog.

I changed your example a bit by removing the list from default_options.
It can only have one.

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

As @prince-chrismc already mentioned, I don't think an all option does not make muck sense for cci. For your personal development branch, it might.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I have given up on keeping project's conanfiles equal to cci's conanfiles.

Yep! CCI is trying to provide the most convince to as many consumers as possible. Which may not meet the needs of the project!

That being said, as a very happy RESTinio consumer, it seems unlikely that a project will have multiple logging methods.... but then they wouldn't need this library either!

✅ There is no right or wrong answer, so ultimately the choice is yours.

I have to agree with @madebr suggestion for a single option that adds the correct requires... for myself this adds the freedom to change in the future with little impact.

Again the opinion of a potential consumer =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to a single option "backend", which implies dependency to a specific logger library.

ngrodzitski and others added 3 commits December 6, 2020 22:55
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
@conan-center-bot
Copy link
Collaborator

All green in build 2 (4fd98031e66a7754bbbfe6398f0d549a71010b21)! 😊

@conan-center-bot
Copy link
Collaborator

All green in build 3 (72992035a6c91c3990fdd8d26ff028235c7cf39d)! 😊

ngrodzitski and others added 2 commits December 6, 2020 23:02
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
@prince-chrismc prince-chrismc mentioned this pull request Dec 6, 2020
4 tasks
@conan-center-bot
Copy link
Collaborator

An unexpected error happened and has been reported. Help is on its way! 🏇

prince-chrismc
prince-chrismc previously approved these changes Dec 6, 2020
Comment on lines 21 to 23
default_options = { "spdlog_backend": True,
"glog_backend": True,
"log4cplus_backend": True }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seem's a little odd to have 3 logging method's 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relevant comment to similar comment
#3812 (comment)

recipes/logr/0.1.0/test_package/CMakeLists.txt Outdated Show resolved Hide resolved
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
@conan-center-bot
Copy link
Collaborator

All green in build 7 (24d586c5b85a6946f21eee235d5f2c01c8521d85)! 😊

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

def package_id(self):
self.info.header_only()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An optimisation we like to add is no_copy_source attribute near the options.

On mobile so I do not have an example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to set no_copy_source, but then I have to use projects own root CMakeLists.txt, and it doesn't workout great as I use "cmake_find_package" generator there and some cmake-scripts are in submodule wich is not a part of tarball. For next release I'll handle those issues and will apply this options.

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
@conan-center-bot
Copy link
Collaborator

All green in build 8 (a00beb0556ff7e930df82f38fc8d9443a419c094)! 😊

@prince-chrismc
Copy link
Contributor

ericLemanissier pointed out "this PR is missing config.yml" I do not see it either

@ericLemanissier
Copy link
Contributor

Yes, I removed my message, because I realized that config.yml is not mandatory if the folder name is identical to the version

@prince-chrismc
Copy link
Contributor

Yes, I removed my message, because I realized that config.yml is not mandatory if the folder name is identical to the version

I was unaware that was a feature!

@conan-center-bot
Copy link
Collaborator

All green in build 9 (06c8d8cc6c0fe93c1241851a8fc578403f9dfe4f)! 😊

@conan-center-bot
Copy link
Collaborator

All green in build 11 (ece574b701cc61012c7f0f4d050edc538027c372)! 😊

Comment on lines 36 to 41
elif self.options.backend == "log4cplus":
self.requires("log4cplus/2.0.5")
self.build_requires_options["log4cplus"].unicode = False
elif self.options.backend == "log4cplus-unicode":
self.requires("log4cplus/2.0.5")
self.build_requires_options["log4cplus"].unicode = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to change anything for logr https://github.com/conan-io/conan-center-index/pull/3812/files#diff-ad137baee4c6c3f95ccebfa8aa275fa0c0d5fff4e1f37e8b7ca65d2541479aeaR73

would it be possible to just have one and let the consumer set his own options?

prince-chrismc
prince-chrismc previously approved these changes Dec 8, 2020
Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid forcing dependencies options, it creates an implicit package id, doesn't matter what you pass, it forces another package id. Instead, raise an error to warn the user.

recipes/logr/0.1.0/conanfile.py Show resolved Hide resolved
recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
recipes/logr/0.1.0/conanfile.py Outdated Show resolved Hide resolved
Co-authored-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot
Copy link
Collaborator

All green in build 12 (f1b4e53c318419f60bddce35472ee8d35ba2d9df)! 😊

ngrodzitski and others added 2 commits December 8, 2020 18:13
Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot
Copy link
Collaborator

All green in build 14 (6750c8fcca8aee1e46d16b5c8c9f6294fbce687b)! 😊

@conan-center-bot conan-center-bot merged commit 264a2e3 into conan-io:master Dec 14, 2020
@ngrodzitski ngrodzitski deleted the add-logr-v0.1.0 branch December 14, 2020 11:01
cacay added a commit to cacay/conan-center-index that referenced this pull request Dec 15, 2020
* master: (73 commits)
  (conan-io#3878) opengl: support FreeBSD
  (conan-io#3882) [system-cci] Fix hooks
  (conan-io#3881) [szip] Fix hooks
  (conan-io#3880) [tcl] Fix hooks
  (conan-io#3866) xorg: add freebsd packages
  (conan-io#3825) Adds baikal-p7 5.6
  (conan-io#3758) minimal recipe for pciutils/3.7.0
  (conan-io#3211) added recipe for extra-cmake-modules
  (conan-io#3870) tl: fix compiler version check again
  (conan-io#3865) bump eigen/3.3.9
  (conan-io#3864) add functionalplus/0.2.13-p0
  bump fmt/7.1.3 (conan-io#3694)
  (conan-io#3858) fix: zulu-openjdk package info
  (conan-io#3836) gmp: bump + enable building static libraries on MSVC
  (conan-io#3812) Add logr v0.1.0
  (conan-io#3786) add Open62541 recipe v1.0.3 and v1.1.3
  (conan-io#3696) openh264: refactor + add 2.1.1 release
  (conan-io#3607) add botan/2.17.2
  (conan-io#3854) Add PEGTL 3.0.0
  (conan-io#3859) bump spdlog/1.8.2
  ...
ngrodzitski added a commit to ngrodzitski/logr that referenced this pull request Dec 18, 2020
See details here: conan-io/conan-center-index#3812
It is honoured to make it possible to package a library without extra CMake wrapper.
ngrodzitski added a commit to ngrodzitski/logr that referenced this pull request Dec 18, 2020
* Adjustments for conan packaging

See details here: conan-io/conan-center-index#3812
It is honoured to make it possible to package a library without any extra CMake wrapper.
@ngrodzitski ngrodzitski mentioned this pull request Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants