clang_tidy_arch.py 894 B

123456789101112131415161718192021222324252627282930313233
  1. import os
  2. import argparse
  3. import json
  4. def parse_args():
  5. parser = argparse.ArgumentParser()
  6. parser.add_argument("--output-file")
  7. parser.add_argument("--build-root")
  8. parser.add_argument("--source-root")
  9. return parser.parse_known_args()
  10. def main():
  11. args, unknown_args = parse_args()
  12. inputs = unknown_args
  13. result_json = {}
  14. for inp in inputs:
  15. if os.path.exists(inp) and inp.endswith("tidyjson"):
  16. with open(inp, 'r') as afile:
  17. file_content = afile.read().strip()
  18. if not file_content:
  19. continue
  20. errors = json.loads(file_content)
  21. testing_src = errors["file"]
  22. result_json[testing_src] = errors
  23. with open(args.output_file, 'w') as afile:
  24. json.dump(result_json, afile, indent=4) # TODO remove indent
  25. if __name__ == "__main__":
  26. main()