[llvm] [Runtimes] Merge 'compile_commands.json' files from runtimes build (PR #116303)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 14 16:47:03 PST 2024
================
@@ -313,3 +313,18 @@ if(SUB_COMPONENTS)
${LLVM_BINARY_DIR}/runtimes/Components.cmake)
endif()
endif()
+
+# If the user requested 'compile_commands.json' we merge the generated JSON from
+# the created directories.
+if(CMAKE_EXPORT_COMPILE_COMMANDS)
+ file(TO_NATIVE_PATH "${LLVM_MAIN_SRC_DIR}/utils/merge-json.py" MERGE_JSON_PATH)
+ add_custom_command(OUTPUT ${LLVM_BINARY_DIR}/compile_commands.json
+ COMMAND ${CMAKE_COMMAND} -E touch ${LLVM_BINARY_DIR}/compile_commands.json
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/compile_commands.json
+ COMMAND ${Python3_EXECUTABLE} ${MERGE_JSON_PATH}
+ ${LLVM_BINARY_DIR}/compile_commands.json
+ ${CMAKE_BINARY_DIR}/compile_commands.json
+ -o ${LLVM_BINARY_DIR}/compile_commands.json
+ DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json)
----------------
jhuber6 wrote:
Yeah I'm not 100% positive on how this will work out. When I test it under normal circumstances (fresh build and modification of files) it works fine. however if I manually delete the compile_commands.json it will get into a dumb state where it keeps thinking it's not there.
https://github.com/llvm/llvm-project/pull/116303
More information about the llvm-commits
mailing list