[PATCH] D147441: [CMake] Attempt to merge runtimes and projects compilation databases
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 11:02:11 PDT 2023
jhuber6 updated this revision to Diff 510561.
jhuber6 added a comment.
Fix help message that wasn't updated correctly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147441/new/
https://reviews.llvm.org/D147441
Files:
llvm/runtimes/CMakeLists.txt
llvm/utils/concat-compile-commands.py
Index: llvm/utils/concat-compile-commands.py
===================================================================
--- /dev/null
+++ llvm/utils/concat-compile-commands.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import argparse
+import json
+
+desc = '''Concatenate JSON files generated by CMake tools.'''
+
+def main():
+ parser = argparse.ArgumentParser(description=desc)
+ parser.add_argument(
+ 'json_files',
+ nargs='+',
+ help='list of JSON files to concatenate.')
+ parser.add_argument(
+ '--output',
+ '-o',
+ required=True,
+ help='Filename to output the merged JSON file to.')
+
+ data = []
+ args = parser.parse_args()
+ for json_file in args.json_files:
+ with open(json_file) as file:
+ data.extend(json.load(file))
+
+ with open(args.output, 'w') as file:
+ json.dump(data, file, indent=2)
+
+ print("\nI have made the file here\n")
+ print(args.output)
+
+if __name__ == '__main__':
+ main()
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -530,4 +530,23 @@
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_ADDITIONAL_TEST_TARGETS runtimes ${RUNTIMES_TEST_DEPENDS})
endif()
+
+ # Attempt to merge the runtimes' compile_commands.json file into the main
+ # file.
+ if(CMAKE_EXPORT_COMPILE_COMMANDS AND TARGET runtimes AND TARGET runtimes-configure)
+ set(files_to_concat
+ ${LLVM_BINARY_DIR}/compile_commands.json
+ ${LLVM_BINARY_DIR}/runtimes/runtimes-bins/compile_commands.json
+ )
+ set(output_file ${LLVM_BINARY_DIR}/compile_commands.json)
+ add_custom_command(
+ OUTPUT ${output_file}
+ COMMAND "${Python3_EXECUTABLE}" ${LLVM_MAIN_SRC_DIR}/utils/concat-compile-commands.py ${files_to_concat} -o ${output_file}
+ COMMENT "Merging the LLVM runtimes 'compile_commands.json' file"
+ DEPENDS runtimes-configure ${LLVM_BINARY_DIR}/runtimes/runtimes-bins/compile_commands.json
+ VERBATIM
+ )
+ add_custom_target(merge-compile-commands DEPENDS ${output_file})
+ add_dependencies(runtimes merge-compile-commands)
+ endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147441.510561.patch
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230403/e8cd2ba2/attachment.bin>
More information about the llvm-commits
mailing list