diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2018-03-10 18:39:10 +0000 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-04-13 01:05:54 +0000 |
commit | cb597adb0170a4818a4950ca9a4fe3f6d5a6c9d2 (patch) | |
tree | 102db07ff897c5766539d5b533b0c11a71db46d7 /mesonbuild | |
parent | 57654bf36784c771fb16d90fd39ed58849d19564 (diff) | |
download | meson-cb597adb0170a4818a4950ca9a4fe3f6d5a6c9d2.zip meson-cb597adb0170a4818a4950ca9a4fe3f6d5a6c9d2.tar.gz meson-cb597adb0170a4818a4950ca9a4fe3f6d5a6c9d2.tar.bz2 |
Indicate subproject depth in console output
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter.py | 20 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 29 |
2 files changed, 34 insertions, 15 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 6ecd285..b99a413 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1862,21 +1862,23 @@ external dependencies (including libraries) must go to "dependencies".''') subdir = os.path.join(self.subproject_dir, resolved) os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True) self.global_args_frozen = True - mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='') - subi = Interpreter(self.build, self.backend, dirname, subdir, self.subproject_dir, - mesonlib.stringlistify(kwargs.get('default_options', []))) - subi.subprojects = self.subprojects - - subi.subproject_stack = self.subproject_stack + [dirname] - current_active = self.active_projectname - subi.run() + mlog.log() + with mlog.nested(): + mlog.log('Executing subproject ', mlog.bold(dirname), '.\n', sep='') + subi = Interpreter(self.build, self.backend, dirname, subdir, self.subproject_dir, + mesonlib.stringlistify(kwargs.get('default_options', []))) + subi.subprojects = self.subprojects + + subi.subproject_stack = self.subproject_stack + [dirname] + current_active = self.active_projectname + subi.run() + mlog.log('\nSubproject', mlog.bold(dirname), 'finished.') if 'version' in kwargs: pv = subi.project_version wanted = kwargs['version'] if pv == 'undefined' or not mesonlib.version_compare(pv, wanted): raise InterpreterException('Subproject %s version is %s but %s required.' % (dirname, pv, wanted)) self.active_projectname = current_active - mlog.log('\nSubproject', mlog.bold(dirname), 'finished.') self.build.subprojects[dirname] = subi.project_version self.subprojects.update(subi.subprojects) self.subprojects[dirname] = SubprojectHolder(subi) diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 347cede..6cbaf60 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -13,6 +13,7 @@ # limitations under the License. import sys, os, platform, io +from contextlib import contextmanager """This is (mostly) a standalone module used to write logging information about Meson runs. Some output goes to screen, @@ -25,6 +26,7 @@ else: log_dir = None log_file = None log_fname = 'meson-log.txt' +log_depth = 0 def initialize(logdir): global log_dir, log_file @@ -77,15 +79,21 @@ def process_markup(args, keep): return arr def force_print(*args, **kwargs): + iostr = io.StringIO() + kwargs['file'] = iostr + print(*args, **kwargs) + + raw = iostr.getvalue() + if log_depth > 0: + prepend = '|' * log_depth + raw = prepend + raw.replace('\n', '\n' + prepend, raw.count('\n') - 1) + # _Something_ is going to get printed. try: - print(*args, **kwargs) + print(raw, end='') except UnicodeEncodeError: - iostr = io.StringIO() - kwargs['file'] = iostr - print(*args, **kwargs) - cleaned = iostr.getvalue().encode('ascii', 'replace').decode('ascii') - print(cleaned) + cleaned = raw.encode('ascii', 'replace').decode('ascii') + print(cleaned, end='') def debug(*args, **kwargs): arr = process_markup(args, False) @@ -146,3 +154,12 @@ def format_list(list): return list[0] else: return '' + +@contextmanager +def nested(): + global log_depth + log_depth += 1 + try: + yield + finally: + log_depth -= 1 |