mirror of https://github.com/mongodb/mongo
27 lines
882 B
Python
Executable File
27 lines
882 B
Python
Executable File
#!/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 os
|
|
import subprocess
|
|
import sys
|
|
|
|
CHECKS_SO = "bazel-bin/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())
|