diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-02-25 10:29:47 -0500 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-02-26 14:24:12 -0500 |
commit | 8101b0ddab1dea8de3b2588a4b75da525865c404 (patch) | |
tree | 0464532a0a29a382f92ad6490c6b4d7a3b4a4483 | |
parent | c175e97a8862be5c87196aa94cb911975c84cf84 (diff) | |
download | meson-8101b0ddab1dea8de3b2588a4b75da525865c404.zip meson-8101b0ddab1dea8de3b2588a4b75da525865c404.tar.gz meson-8101b0ddab1dea8de3b2588a4b75da525865c404.tar.bz2 |
summary: Add more info in Subprojects section
This adds a warnings counter for subprojects that passed. This is to
encourage developpers to check warnings in the logs and hopefully fix
them. Otherwise they could be hidden in hundreds lines of logs.
This also print the error message for subprojects that did not pass. The
error message is often enough to fix the issue (e.g. missing
dependency) and it's easier than searching in the logs why a subproject
failed.
-rw-r--r-- | docs/markdown/snippets/summary.md | 3 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 40 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 2 |
4 files changed, 36 insertions, 13 deletions
diff --git a/docs/markdown/snippets/summary.md b/docs/markdown/snippets/summary.md index 2ab7996..67f29da 100644 --- a/docs/markdown/snippets/summary.md +++ b/docs/markdown/snippets/summary.md @@ -3,3 +3,6 @@ A new `list_sep` keyword argument has been added to `summary()` function. If defined and the value is a list, elements will be separated by the provided string instead of being aligned on a new line. + +The automatic `subprojects` section now also print the number of warnings encountered +during that subproject configuration, or the error message if the configuration failed. diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index c9e559c..53225c4 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -963,10 +963,14 @@ class Test(InterpreterObject): class SubprojectHolder(InterpreterObject, ObjectHolder): - def __init__(self, subinterpreter, subproject_dir, name): + def __init__(self, subinterpreter, subproject_dir, name, warnings=0, disabled_feature=None, + exception=None): InterpreterObject.__init__(self) ObjectHolder.__init__(self, subinterpreter) self.name = name + self.warnings = warnings + self.disabled_feature = disabled_feature + self.exception = exception self.subproject_dir = subproject_dir self.methods.update({'get_variable': self.get_variable_method, 'found': self.found_method, @@ -2602,10 +2606,9 @@ external dependencies (including libraries) must go to "dependencies".''') dirname = args[0] return self.do_subproject(dirname, 'meson', kwargs) - def disabled_subproject(self, dirname, feature=None): - sub = SubprojectHolder(None, self.subproject_dir, dirname) - if feature: - sub.disabled_feature = feature + def disabled_subproject(self, dirname, disabled_feature=None, exception=None): + sub = SubprojectHolder(None, self.subproject_dir, dirname, + disabled_feature=disabled_feature, exception=exception) self.subprojects[dirname] = sub return sub @@ -2613,7 +2616,7 @@ external dependencies (including libraries) must go to "dependencies".''') disabled, required, feature = extract_required_kwarg(kwargs, self.subproject) if disabled: mlog.log('Subproject', mlog.bold(dirname), ':', 'skipped: feature', mlog.bold(feature), 'disabled') - return self.disabled_subproject(dirname, feature) + return self.disabled_subproject(dirname, disabled_feature=feature) default_options = mesonlib.stringlistify(kwargs.get('default_options', [])) default_options = coredata.create_options_dict(default_options) @@ -2654,7 +2657,7 @@ external dependencies (including libraries) must go to "dependencies".''') if not required: mlog.log(e) mlog.log('Subproject ', mlog.bold(subprojdir), 'is buildable:', mlog.red('NO'), '(disabling)') - return self.disabled_subproject(dirname) + return self.disabled_subproject(dirname, exception=e) raise e subdir = os.path.join(self.subproject_dir, resolved) @@ -2682,7 +2685,7 @@ external dependencies (including libraries) must go to "dependencies".''') # fatal and VS CI treat any logs with "ERROR:" as fatal. mlog.exception(e, prefix=mlog.yellow('Exception:')) mlog.log('\nSubproject', mlog.bold(dirname), 'is buildable:', mlog.red('NO'), '(disabling)') - return self.disabled_subproject(dirname) + return self.disabled_subproject(dirname, exception=e) raise e def _do_subproject_meson(self, dirname, subdir, default_options, kwargs, ast=None, build_def_files=None): @@ -2694,7 +2697,12 @@ external dependencies (including libraries) must go to "dependencies".''') subi.subproject_stack = self.subproject_stack + [dirname] current_active = self.active_projectname + current_warnings_counter = mlog.log_warnings_counter + mlog.log_warnings_counter = 0 subi.run() + subi_warnings = mlog.log_warnings_counter + mlog.log_warnings_counter = current_warnings_counter + mlog.log('Subproject', mlog.bold(dirname), 'finished.') mlog.log() @@ -2706,7 +2714,8 @@ external dependencies (including libraries) must go to "dependencies".''') raise InterpreterException('Subproject %s version is %s but %s required.' % (dirname, pv, wanted)) self.active_projectname = current_active self.subprojects.update(subi.subprojects) - self.subprojects[dirname] = SubprojectHolder(subi, self.subproject_dir, dirname) + self.subprojects[dirname] = SubprojectHolder(subi, self.subproject_dir, dirname, + warnings=subi_warnings) # Duplicates are possible when subproject uses files from project root if build_def_files: self.build_def_files = list(set(self.build_def_files + build_def_files)) @@ -2982,11 +2991,18 @@ external dependencies (including libraries) must go to "dependencies".''') all_subprojects = collections.OrderedDict() for name, subp in sorted(self.subprojects.items()): value = subp.found() - if not value and hasattr(subp, 'disabled_feature'): - value = 'Feature {!r} disabled'.format(subp.disabled_feature) + if subp.disabled_feature: + value = [value, 'Feature {!r} disabled'.format(subp.disabled_feature)] + elif subp.exception: + value = [value, str(subp.exception)] + elif subp.warnings > 0: + value = [value, '{} warnings'.format(subp.warnings)] all_subprojects[name] = value if all_subprojects: - self.summary_impl('Subprojects', all_subprojects, {'bool_yn': True}) + self.summary_impl('Subprojects', all_subprojects, + {'bool_yn': True, + 'list_sep': ' ', + }) # Print all summaries, main project last. mlog.log('') # newline main_summary = self.summary.pop('', None) diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index b28eca1..ecd93f3 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -59,6 +59,7 @@ log_disable_stdout = False # type: bool log_errors_only = False # type: bool _in_ci = 'CI' in os.environ # type: bool _logged_once = set() # type: T.Set[T.Tuple[str, ...]] +log_warnings_counter = 0 # type: int def disable() -> None: global log_disable_stdout @@ -254,6 +255,9 @@ def _log_error(severity: str, *rargs: T.Union[str, AnsiDecorator], else: log(*args, **kwargs) + global log_warnings_counter + log_warnings_counter += 1 + if log_fatal_warnings: raise MesonException("Fatal warnings enabled, aborting") diff --git a/run_unittests.py b/run_unittests.py index 09bdcf1..cbc2d1f 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4355,7 +4355,7 @@ recommended as it is not supported on some platforms''') Subprojects sub: YES - sub2: NO + sub2: NO Problem encountered: This subproject failed ''') expected_lines = expected.split('\n')[1:] out_start = out.find(expected_lines[0]) |