Skip to content

Commit

Permalink
MakeDeps: Provide "require" information, and more styling tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
iskunk committed Aug 29, 2023
1 parent ea6b41b commit 875c2b6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions conan/tools/gnu/makedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ class GlobalContentGenerator:
""")

template_deps = textwrap.dedent("""\
{{ define_variable_value("CONAN_DEPS", deps) }}
""")

Expand Down Expand Up @@ -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) -}}
Expand All @@ -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 {}
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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}")

0 comments on commit 875c2b6

Please sign in to comment.