Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Add bazel run :refresh_compile_commands for clangd #47964

Merged
merged 10 commits into from
Oct 30, 2024
22 changes: 22 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ load("@com_github_grpc_grpc//bazel:cython_library.bzl", "pyx_library")
load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("//bazel:ray.bzl", "COPTS", "PYX_COPTS", "PYX_SRCS", "copy_to_workspace", "ray_cc_binary", "ray_cc_library", "ray_cc_test")
load("@python3_9//:defs.bzl", python39 = "interpreter")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

package(
default_visibility = ["//visibility:public"],
Expand Down Expand Up @@ -85,6 +86,27 @@ config_setting(
flag_values = {":jemalloc_flag": "true"},
)

# bazel run :refresh_compile_commands for compile_commands generation for clangd
# https://github.com/hedronvision/bazel-compile-commands-extractor?tab=readme-ov-file#vscode - directions for clangd config
refresh_compile_commands(
name = "refresh_compile_commands",
# Specify the targets of interest.
# For example, specify a dict of targets and any flags required to build.
targets = {
"//:ray_pkg": "",
},
exclude_external_sources = True, # removed below to have lsp index external cc files at the cost of 2x index time
# No need to add flags already in .bazelrc. They're automatically picked up.
)

# bazel run :refresh_compile_commands_external_sources for generation with external source files (cc files)
refresh_compile_commands(
name = "refresh_compile_commands_external_sources",
targets = {
"//:ray_pkg": "",
},
)

# === Begin of rpc definitions ===
# GRPC common lib.
ray_cc_library(
Expand Down
2 changes: 0 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ versions.check(
minimum_bazel_version = "6.5.0",
)

# Tools to generate `compile_commands.json` to enable awesome tooling of the C language family.
# Just run `bazel run @hedron_compile_commands//:refresh_all`
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")

hedron_compile_commands_setup()
Expand Down