aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-08-08 21:29:19 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-08-20 09:12:20 -0400
commit12e5bfbc1c1c387fc3ea7a1b12bac6ddd068c3f1 (patch)
treea4374eae78abe0c2604a16adf4f0b488a69a6b7b /mesonbuild/scripts
parente2f4126e415abedf0af90a30332e5e72c98b3d9e (diff)
downloadmeson-12e5bfbc1c1c387fc3ea7a1b12bac6ddd068c3f1.zip
meson-12e5bfbc1c1c387fc3ea7a1b12bac6ddd068c3f1.tar.gz
meson-12e5bfbc1c1c387fc3ea7a1b12bac6ddd068c3f1.tar.bz2
external-project: Add support for WAF build system
Fixes: #7638
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/externalproject.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py
index a8e3bfe..eefa32e 100644
--- a/mesonbuild/scripts/externalproject.py
+++ b/mesonbuild/scripts/externalproject.py
@@ -19,7 +19,7 @@ import subprocess
from pathlib import Path
import typing as T
-from ..mesonlib import Popen_safe
+from ..mesonlib import Popen_safe, split_args
class ExternalProject:
def __init__(self, options: argparse.Namespace):
@@ -31,7 +31,7 @@ class ExternalProject:
self.verbose = options.verbose
self.stampfile = options.stampfile
self.depfile = options.depfile
- self.make = options.make
+ self.make = split_args(options.make)
def write_depfile(self) -> None:
with open(self.depfile, 'w', encoding='utf-8') as f:
@@ -49,22 +49,28 @@ class ExternalProject:
pass
def gnu_make(self) -> bool:
- p, o, e = Popen_safe([self.make, '--version'])
+ p, o, e = Popen_safe(self.make + ['--version'])
if p.returncode == 0 and 'GNU Make' in o:
return True
return False
def build(self) -> int:
- make_cmd = [self.make]
- if self.gnu_make():
- make_cmd.append('-j' + str(multiprocessing.cpu_count()))
-
+ is_make = self.make[0] == 'make'
+ make_cmd = self.make.copy()
+ if is_make and self.gnu_make():
+ make_cmd.append(f'-j{multiprocessing.cpu_count()}')
rc = self._run('build', make_cmd)
if rc != 0:
return rc
- install_cmd = make_cmd + ['DESTDIR= ' + self.install_dir, 'install']
- rc = self._run('install', install_cmd)
+ install_cmd = self.make.copy()
+ install_env = {}
+ if is_make:
+ install_cmd.append(f'DESTDIR={self.install_dir}')
+ else:
+ install_env['DESTDIR'] = self.install_dir
+ install_cmd.append('install')
+ rc = self._run('install', install_cmd, install_env)
if rc != 0:
return rc
@@ -73,7 +79,7 @@ class ExternalProject:
return 0
- def _run(self, step: str, command: T.List[str]) -> int:
+ 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')
output = None
@@ -83,8 +89,12 @@ class ExternalProject:
output.flush()
else:
print(m)
+ run_env = os.environ.copy()
+ if env:
+ run_env.update(env)
p, o, e = Popen_safe(command, stderr=subprocess.STDOUT, stdout=output,
- cwd=self.build_dir)
+ cwd=self.build_dir,
+ env=run_env)
if p.returncode != 0:
m = f'{step} step returned error code {p.returncode}.'
if not self.verbose: