aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-01-29 09:29:01 -0500
committerXavier Claessens <xavier.claessens@collabora.com>2021-01-29 10:01:36 -0500
commit46b68d4c83bba705bb520877c7b0bd04c2f8cd5b (patch)
tree776b89e22c2322f387ad834ff7f63bd7c61ac9aa /mesonbuild/scripts
parent9eb8b6be2874b343ffa1819a3afc2d4ed355b050 (diff)
downloadmeson-46b68d4c83bba705bb520877c7b0bd04c2f8cd5b.zip
meson-46b68d4c83bba705bb520877c7b0bd04c2f8cd5b.tar.gz
meson-46b68d4c83bba705bb520877c7b0bd04c2f8cd5b.tar.bz2
external_project: Improve logging
Write output of 'make' and 'make install' into log files as well when not verbose.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/externalproject.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py
index 2789dc0..a3ffe73 100644
--- a/mesonbuild/scripts/externalproject.py
+++ b/mesonbuild/scripts/externalproject.py
@@ -27,6 +27,7 @@ class ExternalProject:
self.src_dir = options.srcdir
self.build_dir = options.builddir
self.install_dir = options.installdir
+ self.log_dir = options.logdir
self.verbose = options.verbose
self.stampfile = options.stampfile
self.depfile = options.depfile
@@ -55,17 +56,15 @@ class ExternalProject:
def build(self) -> int:
make_cmd = [self.make]
- if not self.verbose:
- make_cmd.append('--quiet')
if self.gnu_make():
make_cmd.append('-j' + str(multiprocessing.cpu_count()))
- rc = self._run(make_cmd)
+ rc = self._run('build', make_cmd)
if rc != 0:
return rc
install_cmd = make_cmd + ['DESTDIR= ' + self.install_dir, 'install']
- rc = self._run(install_cmd)
+ rc = self._run('install', install_cmd)
if rc != 0:
return rc
@@ -74,10 +73,23 @@ class ExternalProject:
return 0
- def _run(self, command: T.List[str]) -> int:
- output = None if self.verbose else subprocess.DEVNULL
+ def _run(self, step: str, command: T.List[str]) -> int:
+ m = 'Running command ' + str(command) + ' in directory ' + str(self.build_dir) + '\n'
+ log_filename = Path(self.log_dir, '{}-{}.log'.format(self.name, step))
+ output = None
+ if not self.verbose:
+ output = open(log_filename, 'w')
+ output.write(m + '\n')
+ output.flush()
+ else:
+ print(m)
p, o, e = Popen_safe(command, stderr=subprocess.STDOUT, stdout=output,
cwd=self.build_dir)
+ if p.returncode != 0:
+ m = '{} step returned error code {}.'.format(step, p.returncode)
+ if not self.verbose:
+ m += '\nSee logs: ' + str(log_filename)
+ print(m)
return p.returncode
def run(args: T.List[str]) -> int:
@@ -86,6 +98,7 @@ def run(args: T.List[str]) -> int:
parser.add_argument('--srcdir')
parser.add_argument('--builddir')
parser.add_argument('--installdir')
+ parser.add_argument('--logdir')
parser.add_argument('--make')
parser.add_argument('--verbose', action='store_true')
parser.add_argument('stampfile')