aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-03-25 23:23:53 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-03-26 22:18:37 +0200
commit6b9b118bf598e264b93cccc4f8dd06c84885d8e2 (patch)
tree8cf9549a673ca0e0f5d3ed56b1d1503600dbb85b /mesonbuild/environment.py
parentd88bf0eb80e2531a8017de4efd4eb02f1e3081ec (diff)
downloadmeson-6b9b118bf598e264b93cccc4f8dd06c84885d8e2.zip
meson-6b9b118bf598e264b93cccc4f8dd06c84885d8e2.tar.gz
meson-6b9b118bf598e264b93cccc4f8dd06c84885d8e2.tar.bz2
support a NINJA environment variable
This can be useful to test a local ninja version (for example while developing changes to ninja or samurai) without modifying the PATH. The ninja binary that is detected is then hardcoded in the build.ninja rules for scan-build and clean, so that it is always used until reconfiguration.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 74ce058..4541ed4 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -111,7 +111,8 @@ def find_coverage_tools():
return gcovr_exe, gcovr_new_rootdir, lcov_exe, genhtml_exe
def detect_ninja(version='1.5', log=False):
- for n in ['ninja', 'ninja-build', 'samu']:
+ env_ninja = os.environ.get('NINJA', None)
+ for n in [env_ninja] if env_ninja else ['ninja', 'ninja-build', 'samu']:
try:
p, found = Popen_safe([n, '--version'])[0:2]
except (FileNotFoundError, PermissionError):
@@ -121,8 +122,9 @@ def detect_ninja(version='1.5', log=False):
# Perhaps we should add a way for the caller to know the failure mode
# (not found or too old)
if p.returncode == 0 and mesonlib.version_compare(found, '>=' + version):
+ n = shutil.which(n)
if log:
- mlog.log('Found ninja-{} at {}'.format(found, shlex.quote(shutil.which(n))))
+ mlog.log('Found ninja-{} at {}'.format(found, shlex.quote(n)))
return n
def detect_native_windows_arch():