diff options
author | Tobias Diez <code@tobiasdiez.com> | 2025-07-21 10:31:08 +0200 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-08-26 01:46:28 -0400 |
commit | d1090edb914be0efaddabd5a254bb2051d74bb59 (patch) | |
tree | d25279b656cca3d7654ccffed7b6657f6dc14c92 | |
parent | b5bd201420d48d7a030b78f8dfc23161cb058841 (diff) | |
download | meson-d1090edb914be0efaddabd5a254bb2051d74bb59.zip meson-d1090edb914be0efaddabd5a254bb2051d74bb59.tar.gz meson-d1090edb914be0efaddabd5a254bb2051d74bb59.tar.bz2 |
Print external project logfile on CI systems
-rw-r--r-- | mesonbuild/modules/external_project.py | 9 | ||||
-rw-r--r-- | mesonbuild/scripts/externalproject.py | 10 |
2 files changed, 13 insertions, 6 deletions
diff --git a/mesonbuild/modules/external_project.py b/mesonbuild/modules/external_project.py index 339d000..ba7b300 100644 --- a/mesonbuild/modules/external_project.py +++ b/mesonbuild/modules/external_project.py @@ -201,10 +201,10 @@ class ExternalProject(NewExtensionModule): def _run(self, step: str, command: T.List[str], workdir: Path) -> None: mlog.log(f'External project {self.name}:', mlog.bold(step)) m = 'Running command ' + str(command) + ' in directory ' + str(workdir) + '\n' - log_filename = Path(mlog.get_log_dir(), f'{self.name}-{step}.log') + logfile = Path(mlog.get_log_dir(), f'{self.name}-{step}.log') output = None if not self.verbose: - output = open(log_filename, 'w', encoding='utf-8') + output = open(logfile, 'w', encoding='utf-8') output.write(m + '\n') output.flush() else: @@ -215,7 +215,10 @@ class ExternalProject(NewExtensionModule): if p.returncode != 0: m = f'{step} step returned error code {p.returncode}.' if not self.verbose: - m += '\nSee logs: ' + str(log_filename) + m += '\nSee logs: ' + str(logfile) + contents = mlog.ci_fold_file(logfile, f'CI platform detected, click here for {os.path.basename(logfile)} contents.') + if contents: + print(contents) raise MesonException(m) def _create_targets(self, extra_depends: T.List[T.Union['BuildTarget', 'CustomTarget']]) -> T.List['TYPE_var']: diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py index 4013b0a..b782a85 100644 --- a/mesonbuild/scripts/externalproject.py +++ b/mesonbuild/scripts/externalproject.py @@ -10,6 +10,7 @@ from pathlib import Path import typing as T from ..mesonlib import Popen_safe, split_args, determine_worker_count +from .. import mlog class ExternalProject: def __init__(self, options: argparse.Namespace): @@ -67,10 +68,10 @@ class ExternalProject: def _run(self, step: str, command: T.List[str], env: T.Optional[T.Dict[str, str]] = None) -> int: m = 'Running command ' + str(command) + ' in directory ' + str(self.build_dir) + '\n' - log_filename = Path(self.log_dir, f'{self.name}-{step}.log') + logfile = Path(self.log_dir, f'{self.name}-{step}.log') output = None if not self.verbose: - output = open(log_filename, 'w', encoding='utf-8') + output = open(logfile, 'w', encoding='utf-8') output.write(m + '\n') output.flush() else: @@ -84,8 +85,11 @@ class ExternalProject: if p.returncode != 0: m = f'{step} step returned error code {p.returncode}.' if not self.verbose: - m += '\nSee logs: ' + str(log_filename) + m += '\nSee logs: ' + str(logfile) print(m) + contents = mlog.ci_fold_file(logfile, f'CI platform detected, click here for {os.path.basename(logfile)} contents.') + if contents: + print(contents) return p.returncode def run(args: T.List[str]) -> int: |