Skip to content

Commit

Permalink
[CMake] Store the custom compile_commands.json file in a sub-directory
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260769

Reviewed by Michael Catanzaro.

clangd and similar tools should be configured to look for the compile_commands.json file in the
DeveloperTools directory, so for GTK for instance, WebKitBuild/GTK/Release/DeveloperTools/.

* Source/cmake/WebKitCommon.cmake:
* Tools/Scripts/rewrite-compile-commands:

Canonical link: https://commits.webkit.org/267324@main
  • Loading branch information
philn committed Aug 26, 2023
1 parent 08c40bd commit 8d3c77d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/cmake/WebKitCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
if (CMAKE_EXPORT_COMPILE_COMMANDS AND ENABLE_UNIFIED_BUILDS)
add_custom_target(RewriteCompileCommands
ALL
BYPRODUCTS webkit_compile_commands.json
BYPRODUCTS DeveloperTools/compile_commands.json
DEPENDS "${CMAKE_BINARY_DIR}/compile_commands.json"
COMMAND "${PYTHON_EXECUTABLE}"
"${CMAKE_SOURCE_DIR}/Tools/Scripts/rewrite-compile-commands"
"${CMAKE_BINARY_DIR}/compile_commands.json"
"${CMAKE_BINARY_DIR}/webkit_compile_commands.json"
"${CMAKE_BINARY_DIR}/DeveloperTools/compile_commands.json"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}"
)
Expand Down
4 changes: 4 additions & 0 deletions Tools/Scripts/rewrite-compile-commands
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,9 @@ for entry in compile_commands:
else:
print('Failed to find', include_path)

output_directory = os.path.dirname(args.output_file)
if not os.path.isdir(output_directory):
os.makedirs(output_directory)

with open(args.output_file, 'w') as f:
json.dump(generated_compile_commands, f, indent=2)

0 comments on commit 8d3c77d

Please sign in to comment.