diff options
author | Nick Brassel <nick@tzarc.org> | 2021-09-20 14:15:07 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 14:15:07 +1000 |
commit | 28b8b578b055bf76b28f47f9fd02db351cacfa09 (patch) | |
tree | ced969362a90b4661290bf65d06cf3068f8ab66e | |
parent | bf613eb9dbeb05b7456019275cd3a1e6dddd62ee (diff) |
compiledb: query include paths from gcc directly. (#14462)
* Query include paths from gcc directly.
* Change to -isystem
* qmk format-python
* tests
-rwxr-xr-x | lib/python/qmk/cli/generate/compilation_database.py | 14 |
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 2748d96e7a..602635270c 100755 --- a/lib/python/qmk/cli/generate/compilation_database.py +++ b/lib/python/qmk/cli/generate/compilation_database.py @@ -1,7 +1,6 @@ """Creates a compilation database for the given keyboard build. """ -import itertools import json import os import re @@ -24,6 +23,16 @@ def system_libs(binary: str) -> List[Path]: """ cli.log.debug("searching for system library directory for binary: %s", binary) bin_path = shutil.which(binary) + + # Actually query xxxxxx-gcc to find its include paths. + if binary.endswith("gcc") or binary.endswith("g++"): + result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, input='\n') + paths = [] + for line in result.stderr.splitlines(): + if line.startswith(" "): + paths.append(Path(line.strip()).resolve()) + return paths + return list(Path(bin_path).resolve().parent.parent.glob("*/include")) if bin_path else [] @@ -55,7 +64,8 @@ def parse_make_n(f: Iterator[str]) -> List[Dict[str, str]]: # we have a hit! this_cmd = m.group(1) args = shlex.split(this_cmd) - args += ['-I%s' % s for s in system_libs(args[0])] + for s in system_libs(args[0]): + args += ['-isystem', '%s' % s] new_cmd = ' '.join(shlex.quote(s) for s in args if s != '-mno-thumb-interwork') records.append({"directory": str(QMK_FIRMWARE.resolve()), "command": new_cmd, "file": this_file}) state = 'start' |