Generate compile_commands.json for embedded projects — Keil .uvprojx, IAR .ewp, PlatformIO, STM32CubeIDE/e2studio .cproject, Makefile, CMake — so clangd gets real compile flags, with multi-config switching and a projects panel.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Generates compile_commands.json for embedded projects that don't use CMake,
so clangd gets real compile flags for goto-def,
hover, and diagnostics. First step of the embedded-clangd track.
Requirements
Mandatory:
clangd must be installed and running — this extension only generates
the DB; clangd consumes it. Install Microsoft's clangd extension
(llvm-vs-code-extensions.vscode-clangd), then run
Ctrl+Shift+P → clangd: Restart language server (or reload the window)
after generating so it picks up the new compile_commands.json.
Open the project folder — files must live inside the workspace root
for paths to resolve correctly.
Per project type (only what's needed for that flow):
Flow
Extra requirement
Keil .uvprojx, IAR .ewp, .cproject, Makefile
None — fully offline, no toolchain needed
CMake
cmake on PATH for Ensure CMake (and a configured toolchain so it can actually generate)
PlatformIO
pio CLI; run pio run -t compiledb once per env before Generate
compile_flags.txt
None — fallback clangd reads natively
Optional, for clangd correctness:
Vendor/toolchain headers clangd can't find (ARM GCC builtins, CMSIS, FSP):
add the include path via compiledb.extraFlags or a .clangd file
(CompileFlags: Add:), or set clangd's --query-driver to your compiler.
ARMClang/AC6 projects: set compiledb.compiler to armclang and
compiledb.extraFlags accordingly.
Supported project formats (#26)
Format
How
Keil MDK .uvprojx
Parses every <Target> → per-target defines, include paths, C/C++ sources
C_SOURCES/C_DEFS/C_INCLUDES vars + $(wildcard) expansion
Multi-config switching (#27)
Projects with several targets/envs get one DB per config
(compile_commands.<name>.json) plus a root compile_commands.json
mirroring the active config — so goto-def follows the active #if tree.
CompileDB: Generate compile_commands.json — detect, parse, write
(also a $(gear) CompileDB button on the status bar)
CompileDB: Switch Active Configuration — quick-pick (also on the status bar)
CompileDB: Show Projects Panel — table of every discovered project/config
(kind, source, entry count); click a row to make it active
Generate writes compiledb.manifest.json; the richest config (most
entries + flags) becomes the default active one
Only compile_commands.json appears in your workspace — per-config
DBs and the manifest live in the extension's global storage
(globalStorage/compiledb/ws<hash>/), so re-running Generate never
litters the Explorer. Older root-level compile_commands.*.json files
are cleaned up automatically.
Active config persists across reloads (globalState)
More commands
CompileDB: Ensure CMake compile_commands.json — configure with export flag
CompileDB: Write compile_flags.txt — union of -D/-I flags for clangd
(alternative to compile_commands.json for Make-style projects)
Settings
compiledb.compiler — compiler argv[0] written into entries (default arm-none-eabi-gcc)
compiledb.extraFlags — extra flags for every entry (e.g. --target=arm-arm-none-eabi for clangd's --query-driver setups)
Embedded lint ruleset (#28 MVP)
CompileDB: Install Embedded .clang-tidy Ruleset writes a curated
.clang-tidy (bugprone/clang-analyzer/misc/performance/portability).
Custom ISR/RTOS-aware clang-tidy checks are planned.