[llvm] [Runtimes] Merge 'compile_commands.json' files from runtimes build (PR #116303)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 14 16:40:05 PST 2024
================
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+"""A command line utility to merge two JSON files.
+
+This is a python program that merges two JSON files into a single one. The
+intended use for this is to combine generated 'compile_commands.json' files
+created by CMake when performing an LLVM runtime build.
+"""
+
+import argparse
+import json
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "-o", type=str,
+ help="The output file to write JSON data to",
+ default=None, nargs="?",
+ )
+ parser.add_argument(
+ "json_files", type=str, nargs='+', help="Input JSON files to merge"
+ )
+ args = parser.parse_args()
+
+ merged_data = []
+
+ for json_file in args.json_files:
+ try:
+ with open(json_file, 'r') as f:
+ data = json.load(f)
+ merged_data.extend(data)
+ except (IOError, json.JSONDecodeError):
+ continue
----------------
shiltian wrote:
probably drop a warning or so here
https://github.com/llvm/llvm-project/pull/116303
More information about the llvm-commits
mailing list