aboutsummaryrefslogtreecommitdiff
path: root/scripts/cmake/patch-compile-commands.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cmake/patch-compile-commands.cmake')
-rw-r--r--scripts/cmake/patch-compile-commands.cmake28
1 files changed, 0 insertions, 28 deletions
diff --git a/scripts/cmake/patch-compile-commands.cmake b/scripts/cmake/patch-compile-commands.cmake
deleted file mode 100644
index d855ce3c..00000000
--- a/scripts/cmake/patch-compile-commands.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-function (patch_compile_commands input output_var)
- set(ENTRY_FILE ${CMAKE_BINARY_DIR}/compile_commands_entry)
- set(RESULT "[]")
- string(JSON COUNT LENGTH "${input}")
- message("Total commands need to patch: " ${COUNT})
- math(EXPR COUNT "${COUNT} - 1")
- foreach(INDEX RANGE ${COUNT})
- message("Patching: " ${INDEX} "/" ${COUNT})
- string(JSON ORIGINAL_COMMAND GET "${input}" ${INDEX} command)
- string(JSON WORKING_DIR GET "${input}" ${INDEX} directory)
- string(FIND "${ORIGINAL_COMMAND}" " " COMMAND_FIRST_SPACE)
- string(SUBSTRING "${ORIGINAL_COMMAND}" 0 ${COMMAND_FIRST_SPACE} COMMAND_COMPILER)
- string(SUBSTRING "${ORIGINAL_COMMAND}" ${COMMAND_FIRST_SPACE} -1 ORIGINAL_COMMAND_ARGS)
- string(CONCAT COMMAND_GENERATE "${COMMAND_COMPILER}" " -MJ ${ENTRY_FILE}" "${ORIGINAL_COMMAND_ARGS}")
- #message("Run: " "${COMMAND_GENERATE}")
- execute_process(COMMAND sh -c "${COMMAND_GENERATE}" WORKING_DIRECTORY "${WORKING_DIR}")
- file(READ ${ENTRY_FILE} ENTRY)
- string(JSON RESULT SET "${RESULT}" ${INDEX} "${ENTRY}")
- endforeach()
- set(${output_var} "${RESULT}" PARENT_SCOPE)
-endfunction()
-
-function (patch_compile_commands_file)
- file(READ ${CMAKE_BINARY_DIR}/compile_commands.json COMPILE_COMMANDS)
- patch_compile_commands("${COMPILE_COMMANDS}" COMPILE_COMMANDS_PATCHED)
- file(WRITE ${CMAKE_BINARY_DIR}/compile_commands-patched.json "${COMPILE_COMMANDS_PATCHED}")
-endfunction()
-