forked from lix-project/lix
jade
3daeeaefb1
The principle of this is that you can either externally build it with
Nix (actual implementation will be in a future commit), or it can be
built with meson if the Nix one is not passed in.
The idea I have is that dev shells don't receive the one from Nix to
avoid having to build it, but CI can use the one from Nix and save some
gratuitous rebuilds.
The design of this is that you can run `ninja -C build clang-tidy` and
it will simply correctly clang-tidy the codebase in spite of PCH
bullshit caused by the cc-wrapper.
This is a truly horrendous number of hacks in a ball, caused by bugs in
several pieces of software, and I am not even getting started.
I don't consider this to fix the clang-tidy issue filing, since we still
have a fair number of issues to fix even on the existing minimal
configuration, and I have not yet implemented it in CI. Realistically we
will need to do something like https://github.com/Ericsson/codechecker
to be able to silence warnings without physically touching the code, or
at least *diff* reports between versions.
Also, the run-clang-tidy output design is rather atrocious and must
not be inflicted upon anyone I have respect for, since it buries the
diagnostics in a pile of invocation logs. We would do really well to
integrate with the Gerrit SARIF stuff so we can dump the reports on
people in a user-friendly manner.
Related: lix-project/lix#147
Change-Id: Ifefe533f3b56874795de231667046b2da6ff2461
54 lines
1.7 KiB
Python
Executable file
54 lines
1.7 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# Deletes the PCH arguments from a compilation database, to workaround nixpkgs
|
|
# stdenv having a cc-wrapper that is impossible to use for anything except cc
|
|
# itself, for example, clang-tidy.
|
|
|
|
import json
|
|
import shlex
|
|
|
|
|
|
def process_compdb(compdb: list[dict]) -> list[dict]:
|
|
|
|
def munch_command(args: list[str]) -> list[str]:
|
|
out = []
|
|
eat_next = False
|
|
for i, arg in enumerate(args):
|
|
if arg == '-fpch-preprocess':
|
|
# as used with gcc
|
|
continue
|
|
elif arg == '-include-pch' or (arg == '-include' and args[i + 1] == 'precompiled-headers.hh'):
|
|
# -include-pch some-pch (clang), or -include some-pch (gcc)
|
|
eat_next = True
|
|
continue
|
|
if not eat_next:
|
|
out.append(arg)
|
|
eat_next = False
|
|
return out
|
|
|
|
def chomp(item: dict) -> dict:
|
|
item = item.copy()
|
|
item['command'] = shlex.join(munch_command(shlex.split(item['command'])))
|
|
return item
|
|
|
|
return [chomp(x) for x in compdb if not x['file'].endswith('precompiled-headers.hh')]
|
|
|
|
|
|
def main():
|
|
import argparse
|
|
ap = argparse.ArgumentParser(
|
|
description='Delete pch arguments from compilation database')
|
|
ap.add_argument('input',
|
|
type=argparse.FileType('r'),
|
|
help='Input json file')
|
|
ap.add_argument('output',
|
|
type=argparse.FileType('w'),
|
|
help='Output json file')
|
|
args = ap.parse_args()
|
|
|
|
input_json = json.load(args.input)
|
|
json.dump(process_compdb(input_json), args.output, indent=2)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|