From 875c2b65237486412ffddcb7a6fdb142b28f62e1 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Tue, 29 Aug 2023 15:24:44 -0400 Subject: [PATCH] MakeDeps: Provide "require" information, and more styling tweaks --- conan/tools/gnu/makedeps.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/conan/tools/gnu/makedeps.py b/conan/tools/gnu/makedeps.py index e4d76ce2444..ab53d0120f3 100644 --- a/conan/tools/gnu/makedeps.py +++ b/conan/tools/gnu/makedeps.py @@ -230,7 +230,6 @@ class GlobalContentGenerator: """) template_deps = textwrap.dedent("""\ - {{ define_variable_value("CONAN_DEPS", deps) }} """) @@ -371,10 +370,14 @@ class DepContentGenerator: template = textwrap.dedent("""\ - # {{ dep.ref }} + # {{ dep.ref }}{% if not req.direct %} (indirect dependency){% endif +%} + CONAN_NAME_{{ name }} = {{ dep.ref.name }} + CONAN_VERSION_{{ name }} = {{ dep.ref.version }} + CONAN_REFERENCE_{{ name }} = {{ dep.ref }} + CONAN_ROOT_{{ name }} = {{ root }} {{ define_variable_value("CONAN_SYSROOT_{}".format(name), sysroot) -}} @@ -398,8 +401,9 @@ class DepContentGenerator: {{- define_variable_value("CONAN_COMPONENTS_{}".format(name), components) -}} """) - def __init__(self, dependency, root: str, sysroot, dirs: dict, flags: dict): + def __init__(self, dependency, require, root: str, sysroot, dirs: dict, flags: dict): self._dep = dependency + self._req = require self._root = root self._sysroot = sysroot self._dirs = dirs or {} @@ -411,6 +415,7 @@ def content(self) -> str: """ context = { "dep": self._dep, + "req": self._req, "name": _makefy(self._dep.ref.name), "root": self._root, "sysroot": self._sysroot, @@ -507,8 +512,9 @@ class DepGenerator: Process a dependency cpp_info variables and generate its Makefile content """ - def __init__(self, dependency): + def __init__(self, dependency, require=None): self._dep = dependency + self._req = require self._info = MakeInfo(self._dep.ref.name, [], []) @property @@ -581,7 +587,7 @@ def generate(self) -> str: sysroot = self._get_sysroot(root) dirs = self._get_dependency_dirs(root, self._dep) flags = self._get_dependency_flags(self._dep) - dep_content_gen = DepContentGenerator(self._dep, root, sysroot, dirs, flags) + dep_content_gen = DepContentGenerator(self._dep, self._req, root, sysroot, dirs, flags) content = dep_content_gen.content() for comp_name, comp in self._dep.cpp_info.get_sorted_components().items(): @@ -597,6 +603,7 @@ class MakeDeps: """ _title = "# This Makefile has been generated by Conan. DO NOT EDIT!\n" + _footer = f"# end {CONAN_MAKEFILE_FILENAME}\n" def __init__(self, conanfile): """ @@ -627,12 +634,12 @@ def generate(self) -> None: if require.build: continue - dep_gen = DepGenerator(dep) + dep_gen = DepGenerator(dep, require) make_infos.append(dep_gen.makeinfo) deps_buffer += dep_gen.generate() glob_gen = GlobalGenerator(self._conanfile, make_infos) - content_buffer += glob_gen.deps_generate() + deps_buffer + glob_gen.generate() + content_buffer += glob_gen.deps_generate() + deps_buffer + glob_gen.generate() + self._footer save(self._conanfile, CONAN_MAKEFILE_FILENAME, content_buffer) self._conanfile.output.info(f"Generated {CONAN_MAKEFILE_FILENAME}")