Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>CompileDBNew to Visual Studio Code? Get it now.
CompileDB

CompileDB

Mohamed Hakeem

|
1 install
| (0) | Free
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.
Copied to clipboard
More Info

CompileDB — compile_commands.json for Embedded

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
IAR EWARM .ewp Project-level CCDefines/CCIncludePath + <file> list; $PROJ_DIR$ resolved
PlatformIO platformio.ini Adopts .pio/build/<env>/compile_commands.json per [env:*] (run pio run -t compiledb first)
CMake / existing Detects build*/compile_commands.json and adopts it; Ensure CMake runs cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
Eclipse CDT .cproject STM32CubeIDE, e²studio (Renesas), STM32CubeMX-IDE, generic CDT — per-<configuration> GCC_SYMBOLS/GCC_INCLUDES + sourceEntries
GNU Make / CubeMX Makefile 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.

Test

npm install
npm test
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft