aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@mindmaze.com>2019-09-09 09:15:38 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2019-09-14 05:51:36 +0300
commite7197895b27a789a4339b493ceddb242f7f12c9e (patch)
treed2c687fbd181bea66a60706f31b345279ff69839 /mesonbuild/environment.py
parent9e04450eb694c91dcb097a388c7bf4ecc7290545 (diff)
downloadmeson-e7197895b27a789a4339b493ceddb242f7f12c9e.zip
meson-e7197895b27a789a4339b493ceddb242f7f12c9e.tar.gz
meson-e7197895b27a789a4339b493ceddb242f7f12c9e.tar.bz2
uniform scan-build detection process
Detect scan-build the same way when trying to launch it and when generating the target. The detection method is: 1. look within SCANBUILD env variable 2. shutil.which('scan-build') 3. *on non-linux platforms only*: go through all the possible name candidates and test them individually. The third step is added following this comment https://github.com/mesonbuild/meson/pull/5857#issuecomment-528305788 However, going through a list of all the possible candidates is neither easily maintainable nor performant, and is therefore skipped on platforms that should not require such a step (currently, only Linux platforms). This is a follow-up to the issue raised by @lantw44 during PR: https://github.com/mesonbuild/meson/pull/5857
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index e67e744..f5b24d8 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -163,6 +163,55 @@ def detect_ninja(version: str = '1.5', log: bool = False) -> str:
mlog.log('Found {}-{} at {}'.format(name, found, quote_arg(n)))
return n
+def detect_scanbuild():
+ """ Look for scan-build binary on build platform
+
+ First, if a SCANBUILD env variable has been provided, give it precedence
+ on all platforms.
+
+ For most platforms, scan-build is found is the PATH contains a binary
+ named "scan-build". However, some distribution's package manager (FreeBSD)
+ don't. For those, loop through a list of candidates to see if one is
+ available.
+ Since this is a costly operation, limit it to the impacted platforms
+ (currently all non-linux platforms)
+
+ Return: a single-element list of the found scan-build binary ready to be
+ passed to Popen()
+ """
+ exelist = []
+ if 'SCANBUILD' in os.environ:
+ exelist = split_args(os.environ['SCANBUILD'])
+
+ elif shutil.which('scan-build') is not None:
+ exelist = [shutil.which('scan-build')]
+
+ elif platform.system() != 'Linux':
+ tools = [
+ 'scan-build', # base
+ 'scan-build-8.0', 'scan-build80',
+ 'scan-build-7.0', 'scan-build70',
+ 'scan-build-6.0', 'scan-build60',
+ 'scan-build-5.0', 'scan-build50',
+ 'scan-build-4.0', 'scan-build40',
+ 'scan-build-3.9', 'scan-build39',
+ 'scan-build-3.8', 'scan-build38',
+ 'scan-build-3.7', 'scan-build37',
+ 'scan-build-3.6', 'scan-build36',
+ 'scan-build-3.5', 'scan-build35',
+ 'scan-build-9.0', 'scan-build-devel', # development snapshot
+ ]
+ for tool in tools:
+ if shutil.which(tool) is not None:
+ exelist = [shutil.which(tool)]
+ break
+
+ if exelist:
+ tool = exelist[0]
+ if os.path.isfile(tool) and os.access(tool, os.X_OK):
+ return [tool]
+ return []
+
def detect_native_windows_arch():
"""
The architecture of Windows itself: x86, amd64 or arm64