aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-09-20 14:15:07 +1000
committerGitHub <noreply@github.com>2021-09-20 14:15:07 +1000
commit28b8b578b055bf76b28f47f9fd02db351cacfa09 (patch)
treeced969362a90b4661290bf65d06cf3068f8ab66e /lib
parentbf613eb9dbeb05b7456019275cd3a1e6dddd62ee (diff)
downloadqmk_firmware-28b8b578b055bf76b28f47f9fd02db351cacfa09.tar.gz
qmk_firmware-28b8b578b055bf76b28f47f9fd02db351cacfa09.zip
compiledb: query include paths from gcc directly. (#14462)
* Query include paths from gcc directly. * Change to -isystem * qmk format-python * tests
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/compilation_database.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/python/qmk/cli/generate/compilation_database.py b/lib/python/qmk/cli/generate/compilation_database.py
index 2748d96e7..602635270 100755
--- a/lib/python/qmk/cli/generate/compilation_database.py
+++ b/lib/python/qmk/cli/generate/compilation_database.py
@@ -1,7 +1,6 @@
1"""Creates a compilation database for the given keyboard build. 1"""Creates a compilation database for the given keyboard build.
2""" 2"""
3 3
4import itertools
5import json 4import json
6import os 5import os
7import re 6import re
@@ -24,6 +23,16 @@ def system_libs(binary: str) -> List[Path]:
24 """ 23 """
25 cli.log.debug("searching for system library directory for binary: %s", binary) 24 cli.log.debug("searching for system library directory for binary: %s", binary)
26 bin_path = shutil.which(binary) 25 bin_path = shutil.which(binary)
26
27 # Actually query xxxxxx-gcc to find its include paths.
28 if binary.endswith("gcc") or binary.endswith("g++"):
29 result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, input='\n')
30 paths = []
31 for line in result.stderr.splitlines():
32 if line.startswith(" "):
33 paths.append(Path(line.strip()).resolve())
34 return paths
35
27 return list(Path(bin_path).resolve().parent.parent.glob("*/include")) if bin_path else [] 36 return list(Path(bin_path).resolve().parent.parent.glob("*/include")) if bin_path else []
28 37
29 38
@@ -55,7 +64,8 @@ def parse_make_n(f: Iterator[str]) -> List[Dict[str, str]]:
55 # we have a hit! 64 # we have a hit!
56 this_cmd = m.group(1) 65 this_cmd = m.group(1)
57 args = shlex.split(this_cmd) 66 args = shlex.split(this_cmd)
58 args += ['-I%s' % s for s in system_libs(args[0])] 67 for s in system_libs(args[0]):
68 args += ['-isystem', '%s' % s]
59 new_cmd = ' '.join(shlex.quote(s) for s in args if s != '-mno-thumb-interwork') 69 new_cmd = ' '.join(shlex.quote(s) for s in args if s != '-mno-thumb-interwork')
60 records.append({"directory": str(QMK_FIRMWARE.resolve()), "command": new_cmd, "file": this_file}) 70 records.append({"directory": str(QMK_FIRMWARE.resolve()), "command": new_cmd, "file": this_file})
61 state = 'start' 71 state = 'start'