summaryrefslogtreecommitdiff
path: root/buildscripts/clang_tidy_vscode.py
blob: 62f33678251e081c9f7ddd8d3f6daee9f7bfc7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/opt/mongodbtoolchain/v4/bin/python3
"""Wraps clang tidy to include our custom checks."""

# TODO: if https://github.com/notskm/vscode-clang-tidy/pull/77#issuecomment-1422910143 is resolved then this script can be removed

import subprocess
import sys
import os

CHECKS_SO = "build/install/lib/libmongo_tidy_checks.so"


def main():
    clang_tidy_args = ["/opt/mongodbtoolchain/v4/bin/clang-tidy"]
    if os.path.isfile(CHECKS_SO):
        clang_tidy_args += [f"-load={CHECKS_SO}"]
    clang_tidy_args += sys.argv[1:]
    proc = subprocess.run(clang_tidy_args, capture_output=True)
    # Write to output buffer here because that is how to copy directly from stdin to stdout without making assumptions about encoding
    sys.stdout.buffer.write(proc.stdout)
    sys.stderr.buffer.write(proc.stderr)
    return proc.returncode


if __name__ == "__main__":
    sys.exit(main())