Enhanced Bazel integration for VS Code with automatic compile_commands.json generation.
Features
- Auto-refresh compile_commands.json - Automatically regenerates when BUILD files change
- Status bar integration - Shows refresh status and click to manually refresh
- Platform selection - Switch target platforms for cross-compilation
- Debounced updates - Configurable delay to batch rapid changes
Requirements
Setup
- Add hedron_compile_commands to your
MODULE.bazel:
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "4f28899228fb3ad0126897876f147ca15026151e",
)
- Add refresh target to your root
BUILD.bazel:
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
refresh_compile_commands(
name = "refresh_compile_commands",
targets = {"//...": ""},
)
- Install this extension and the clangd extension
- Open your Bazel workspace - the extension activates automatically
Commands
Bazel: Refresh compile_commands.json - Manually trigger refresh
Bazel: Toggle Auto-Refresh - Enable/disable automatic refresh on file changes
Bazel: Select Platform - Choose target platform for cross-compilation
Settings
| Setting |
Default |
Description |
bazelIdeToolkit.autoRefresh |
true |
Auto-refresh on BUILD file changes |
bazelIdeToolkit.debounceMs |
2000 |
Delay before refresh (ms) |
bazelIdeToolkit.targets |
//... |
Bazel targets to include |
bazelIdeToolkit.showStatusBar |
true |
Show status bar item |
How It Works
- Extension watches for changes to BUILD, BUILD.bazel, *.bzl, WORKSPACE, MODULE.bazel
- On change, waits for debounce period (default 2s)
- Runs
bazel run @hedron_compile_commands//:refresh_all or //:refresh_compile_commands
- clangd picks up the new
compile_commands.json automatically
License
Apache-2.0
| |