aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/scanbuild.py
diff options
context:
space:
mode:
authorElliot <35050275+Apache-HB@users.noreply.github.com>2020-11-01 10:50:15 -0800
committerGitHub <noreply@github.com>2020-11-01 10:50:15 -0800
commitff50f724bbf49739abbee9cbb4c8e6200849738f (patch)
tree3467dd03e1ac2070bfb96386b34cb2182bd3a504 /mesonbuild/scripts/scanbuild.py
parent505b5b23915ec98624e81eabeb59ac17ea18ff47 (diff)
downloadmeson-ff50f724bbf49739abbee9cbb4c8e6200849738f.zip
meson-ff50f724bbf49739abbee9cbb4c8e6200849738f.tar.gz
meson-ff50f724bbf49739abbee9cbb4c8e6200849738f.tar.bz2
Fix #5492 (#7919)
* fix 5492 with cleaner code * remove argparse import * replace list(map( with list comprehension * pass str rather than Path to get_cmd_line_file
Diffstat (limited to 'mesonbuild/scripts/scanbuild.py')
-rw-r--r--mesonbuild/scripts/scanbuild.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py
index 3e5b30f..0736b3f 100644
--- a/mesonbuild/scripts/scanbuild.py
+++ b/mesonbuild/scripts/scanbuild.py
@@ -16,9 +16,11 @@ import subprocess
import shutil
import tempfile
from ..environment import detect_ninja, detect_scanbuild
+from ..coredata import get_cmd_line_file, CmdLineFileParser
from pathlib import Path
import typing as T
-
+from ast import literal_eval
+import os
def scanbuild(exelist: T.List[str], srcdir: Path, blddir: Path, privdir: Path, logdir: Path, args: T.List[str]) -> int:
with tempfile.TemporaryDirectory(dir=str(privdir)) as scandir:
@@ -32,15 +34,27 @@ def scanbuild(exelist: T.List[str], srcdir: Path, blddir: Path, privdir: Path, l
def run(args: T.List[str]) -> int:
srcdir = Path(args[0])
- blddir = Path(args[1])
+ bldpath = Path(args[1])
+ blddir = args[1]
meson_cmd = args[2:]
- privdir = blddir / 'meson-private'
- logdir = blddir / 'meson-logs' / 'scanbuild'
+ privdir = bldpath / 'meson-private'
+ logdir = bldpath / 'meson-logs' / 'scanbuild'
shutil.rmtree(str(logdir), ignore_errors=True)
+ # if any cross or native files are specified we should use them
+ cmd = get_cmd_line_file(blddir)
+ data = CmdLineFileParser()
+ data.read(cmd)
+
+ if 'cross_file' in data['properties']:
+ meson_cmd.extend([f'--cross-file={os.path.abspath(f)}' for f in literal_eval(data['properties']['cross_file'])])
+
+ if 'native_file' in data['properties']:
+ meson_cmd.extend([f'--native-file={os.path.abspath(f)}' for f in literal_eval(data['properties']['native_file'])])
+
exelist = detect_scanbuild()
if not exelist:
print('Could not execute scan-build "%s"' % ' '.join(exelist))
return 1
- return scanbuild(exelist, srcdir, blddir, privdir, logdir, meson_cmd)
+ return scanbuild(exelist, srcdir, bldpath, privdir, logdir, meson_cmd)