aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-01-30 11:30:16 +0000
committerGitHub <noreply@github.com>2021-01-30 11:30:16 +0000
commitc67e0a8a6785ab5f139491786fa064905278d951 (patch)
tree848cd21be5fbf4c8cedae03fa0f4f72f59b92f0a /mesonbuild/scripts
parentf0fbb31ccfa78ca1d7b7f9cedfbb090bf36d3e64 (diff)
parentef7dfa97fc6f20d8793609fc086718399c08a85a (diff)
downloadmeson-c67e0a8a6785ab5f139491786fa064905278d951.zip
meson-c67e0a8a6785ab5f139491786fa064905278d951.tar.gz
meson-c67e0a8a6785ab5f139491786fa064905278d951.tar.bz2
Merge pull request #8264 from xclaesse/ep-misc
external_project: misc improvements
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')