[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:44:58 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)
----------------
shiltian wrote:
IIUC this custom command will just depend on the main `compile_commands.json`, which is generated after CMake configuration. However, the runtime build is the last stage of build, so I'm not sure if this dependency can push it back to the end.
https://github.com/llvm/llvm-project/pull/116303
More information about the llvm-commits
mailing list