compile_commands.json
¶A compilation database is
a JSON-formatted file named compile_commands.json
that
contains structured data about every compilation unit in your project.
PlatformIO Core (CLI) supports generating of compilation database using
platformio run --target
command and compiledb
target. For example,
> platformio run -t compiledb
A default path for compile_commands.json
is “build_dir/envname”.
You can override this path with Advanced Scripting and
COMPILATIONDB_PATH
environment variable. For example, generate compile_commands.json
in a root of project:
platformio.ini
:
[env:myenv]
platform = ...
board = ...
extra_scripts = post:extra_script.py
extra_script.py
:
import os
Import("env")
env.Replace(COMPILATIONDB_PATH=os.path.join("$PROJECT_DIR", "compile_commands.json"))