-
Notifications
You must be signed in to change notification settings - Fork 993
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 MakeDeps generator #14133
Add MakeDeps generator #14133
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is looking good, please have a look at the comments.
Also, it would be better to focus on 1 good functional test that proves that this generator can actually be used to link with a regular library, and start from there to more advanced and complete cases (but that can happen later in other PRs)
Trying this out on my side. A few comments:
|
@iskunk thank you for reviewing, your feedback is valuable.
Most of generators split in several files, including pkg-config and cmake, please, take a look in https://docs.conan.io/2/reference/tools/cmake/cmakedeps.html#generated-files for instance.
Indeed it's a fragile point, need to be improved, thank you for spotting it.
GNU Make is by far, the most popular and well documented Make implementation, that's why the choice. Append variables is not expected but can occur, as users demand all kind of customization. Anyway, using only |
Ah, okay, now I remember those. I'd point out that the CMake
One of my potential use cases is running a build on AIX or Solaris, and GNU Make isn't always available, so the greater compatibility will be a plus. (I forgot to point out the |
Yes, but keeping the flexibility of what you want to include is also a feature. For those cases when you want to use a separated folder to generate your makefiles, now you can use the definition
Those are very rare cases, most used for production, not development (I know some people using AIX). About the $(sort) you are right, need to be improved and will. The |
All these files do is assign variables. If there are some dependencies in there that I don't want to use, then I can just not use those variables in my makefile. What problem is solved by including I notice that the individual
Each time GNU Make sees that, it will print out that message. I wrote a trivial makefile that includes
Also,
My organization is using Conan to drive production builds of third-party dependencies. If all I cared about were development, we'd just use Conda. The Conan buildenv mechanism is especially helpful on traditional Unix systems that can't run Python 3---I can run Conan on a Linux system, generate into a shared NFS workspace, have the Unix system load the buildenv and build in that NFS workspace, and then Conan on Linux can pick up the artifacts. |
Much obliged @uilianries, this is looking pretty good. I have a concern with how variables for components are named. In my implementation, I did a straight conversion from the
You mentioned that you didn't like the "PCRE2_PCRE2" name-doubling, and I see your code detects and drops the redundant part of the name, e.g.
But say you have a package with component names like
You'll get two The name-doubling from my implementation wasn't pretty, but it only reflected the redundant names in the original components. In the case of (I have remarks on some other aspects of the current draft, but this is the main one for now) |
@iskunk that's a nice feedback indeed, I didn't consider that scenario, because is rare, but still valid. I'll update the PR with the package name as prefix. Thank you! |
27f9bee
to
222a448
Compare
Signed-off-by: Uilian Ries <uilianries@gmail.com>
222a448
to
842673c
Compare
Signed-off-by: Uilian Ries <uilianries@gmail.com>
All right, I gave the generator another test run. Here are my observations:
|
@iskunk Thank you for checking the implementation again. The patch is now much simpler, without jinja2.
The
Yes, splitting makes sense, as we have done for environment files in Conan 2.x
If you want to use only one component, you pick only those variables related to that specific component. I don't see the scenario that you describe, maybe could write a test to validate the case, but I still see it as pretty rare case that would not worth covering now. |
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@SSE4, there is no need for this generator to use GNU Make-specific features; all it does is define a bunch of variables. My original implementation was portable across different Make implementations, and I've ensured it remains that way. |
I'll just repost my question from other discussion , as it might be relevant here: Why using custom In my opinion, adding Using these well known variables will result in that modifying |
Hi @igagis, There are several issues with the AutotoolsDeps approach using the |
It is useful to have separate flags variables for different Conan packages
and components. If you have a reasonably complex Makefile, you probably are
building up custom flags variables used by different targets or in
different conditions.
…On Mon, Aug 14, 2023, 3:12 PM Daniel Richard G. ***@***.***> wrote:
Hi @igagis <https://github.com/igagis>,
There are several issues with the AutotoolsDeps approach using the *FLAGS
variables, not least that (1) it assumes which variables are meaningful to
the build system (what if you need to set LOCAL_CXX_FLAGS instead of
CXXFLAGS? or pass them as a command-line arg instead of an env var?), and
(2) there is no easy way for subsequent scripting to obtain flags for
specific dependencies; it is all of them or nothing. The MakeDeps generator
is intended to be fully general, in the way that Make itself is fully
general. It sets CONAN_* variables to avoid collisions with ones already
in use, and lets you make use of them however you like.
—
Reply to this email directly, view it on GitHub
<#14133 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABOLEVCN2ERK4S2L5KDCKN3XVJ2CBANCNFSM6AAAAAAZNHBGSA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Well, in addition to |
Someone else would complain that they don't want the generator assigning to such variables---either because they want to set a different value, or because they don't want these set at all. (For example, I'm using the profile There is a bright line between "makes my use case easy to support" and "supports my use case out of the box." This generator opts for the former, because the latter is impossible to attain without a gazillion parameters. |
As far as I understand, different conan package means different So, anyway, I'm just suggesting. Looks like I'll continue using |
build_req = self._conanfile.dependencies.build # tool_requires | ||
test_req = self._conanfile.dependencies.test | ||
|
||
content_buffer = f"{self._title}\n" | ||
deps_buffer = "" | ||
|
||
# Filter the build_requires not activated for any requirement | ||
dependencies = [tup for tup in list(host_req.items()) + list(build_req.items()) + list(test_req.items()) if not tup[0].build] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just drop build-requires
if they are not going to be used at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. We could add another feature, just like for pkgconfigdeps
, the build_context_activated
, a list with reference that should be part of the makefile.
conan/tools/gnu/makedeps.py
Outdated
self._info.dirs = list(set(self._info.dirs)) | ||
self._info.flags = list(set(self._info.flags)) | ||
return self._info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird pattern, with inputs and outputs all inside MakeInfo
, seems this should be encapsulated and automatic in MakeInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the commit c5cd0a5
|
||
def _get_sysroot(self, root: str) -> list: | ||
""" | ||
Get the sysroot of the dependency. Sysroot is a list of directories, or a single directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far we haven't treated sysroot
as multiple directories, maybe this would be better to align with others and treat it jointly with other generators behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed is not usual having multiple sysroot, but only one when cross-building. TBH, it seems be a bug, because returning ['']
seems be something mixed, it should be empty string, but then was converted to a list to keep same pattern as other cpp_info dirs
conan/tools/gnu/makedeps.py
Outdated
for var, prefix_var in _common_cppinfo_variables().items(): | ||
cppinfo_value = getattr(dependency.cpp_info, var) | ||
# Use component cpp_info info when does not provide any value | ||
if not cppinfo_value and hasattr(dependency.cpp_info, "components"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cpp_info
always has components
defined, it is in the constructor of CppInfo
, this hasattr
check is useless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing some tests, it seems be. The idea here is capturing cpp_info value from a component, when a dependency has no such cpp_info value. It's available on the commit 614c273
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Co-authored-by: James <memsharded@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Thanks @memsharded, @uilianries. This has been a long time in coming. I've pushed a PR (#14605) with some minor tweaks on top of this, to polish it off. |
Changelog: Feature: Add support to Makefile by the new MakeDeps generator
Docs: conan-io/docs#3348
closes #13394
This PR adds a new feature, the
MakeDeps
generator, that can be used with Conan install command:conan install --requires=foobar/0.1.0 -g MakeDeps
. The idea is bringing back themake
generator from Conan 1.x but with steroids, including support for components.As real example, using Poco package, we will have:
The are 3 levels of dependencies here:
develop
branch, documenting this one.