From 9d64143a4f7cf36c052c679a1411f60ccff2fa7e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 10 Oct 2020 23:15:31 -0400 Subject: summary: Add from which subproject each subproject have been called --- mesonbuild/interpreter/interpreter.py | 14 +++++++++----- mesonbuild/interpreter/interpreterobjects.py | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 2da966c..7a3ffb1 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -999,7 +999,8 @@ class Interpreter(InterpreterBase, HoldableObject): raise InterpreterException(f'Subproject {subp_name} version is {pv} but {wanted} required.') self.active_projectname = current_active self.subprojects.update(subi.subprojects) - self.subprojects[subp_name] = SubprojectHolder(subi, subdir, warnings=subi_warnings) + self.subprojects[subp_name] = SubprojectHolder(subi, subdir, warnings=subi_warnings, + callstack=self.subproject_stack) # Duplicates are possible when subproject uses files from project root if build_def_files: self.build_def_files.update(build_def_files) @@ -1370,13 +1371,16 @@ class Interpreter(InterpreterBase, HoldableObject): # Add automatic 'Subprojects' section in main project. all_subprojects = collections.OrderedDict() for name, subp in sorted(self.subprojects.items()): - value = subp.found() + value = [subp.found()] if subp.disabled_feature: - value = [value, f'Feature {subp.disabled_feature!r} disabled'] + value += [f'Feature {subp.disabled_feature!r} disabled'] elif subp.exception: - value = [value, str(subp.exception)] + value += [str(subp.exception)] elif subp.warnings > 0: - value = [value, f'{subp.warnings} warnings'] + value += [f'{subp.warnings} warnings'] + if subp.callstack: + stack = ' => '.join(subp.callstack) + value += [f'(from {stack})'] all_subprojects[name] = value if all_subprojects: self.summary_impl('Subprojects', all_subprojects, diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py index fa91714..c1ce0da 100644 --- a/mesonbuild/interpreter/interpreterobjects.py +++ b/mesonbuild/interpreter/interpreterobjects.py @@ -731,7 +731,8 @@ class SubprojectHolder(MesonInterpreterObject): subdir: str, warnings: int = 0, disabled_feature: T.Optional[str] = None, - exception: T.Optional[Exception] = None) -> None: + exception: T.Optional[Exception] = None, + callstack: T.Optional[T.List[str]] = None) -> None: super().__init__() self.held_object = subinterpreter self.warnings = warnings @@ -739,6 +740,7 @@ class SubprojectHolder(MesonInterpreterObject): self.exception = exception self.subdir = PurePath(subdir).as_posix() self.cm_interpreter: T.Optional[CMakeInterpreter] = None + self.callstack = callstack self.methods.update({'get_variable': self.get_variable_method, 'found': self.found_method, }) -- cgit v1.1