Skip to content

compile_commands.json` generated by PlatformIO for ESP8266 framework misses Arduino libraries include paths (e.g., Wire, SPI) #5209

@kawaegle

Description

@kawaegle

PlatformIO Core Version: 6.1.18

Platform: espressif8266
Board: d1_mini
Framework: arduino (arduinoespressif8266 3.1.2)


Description

When generating the compilation database (compile_commands.json) using PlatformIO for an ESP8266 project (e.g., WeMos D1 Mini with Arduino framework), the include paths for the Arduino libraries located under:
~/.platformio/packages/framework-arduinoespressif8266/libraries/

are not included in the compilation commands.

This results in clangd (or other LSP clients) reporting missing headers for common Arduino libraries such as Wire.h, SPI.h, and others provided by the framework’s libraries directory.


Steps to Reproduce

  1. Create a PlatformIO project using pio project init -b d1_mini --ide vim --sample-code.
  2. Update platformio.ini with python script to include toolchain
  3. Add dependencies that use Arduino built-in libraries, e.g., include <SPI.h> or <Wire.h>.
  4. Run pio run -t compiledb to generate compile_commands.json.
  5. Open the project with clangd or any language server expecting complete include paths.
  6. The LSP shows errors for missing Arduino framework library headers (Wire.h, SPI.h, etc.).

Expected Behavior

The generated compile_commands.json should include the necessary -I include flags pointing to all relevant Arduino framework libraries, i.e.:

~/.platformio/packages/framework-arduinoespressif8266/libraries/Wire/
~/.platformio/packages/framework-arduinoespressif8266/libraries/SPI/

Workarounds

As a workaround, users can manually patch the compile_commands.json after generation to add these includes, or use an extra build script (extra.py) to inject those paths automatically.


Suggestion

Consider adding an option or improving the compilation database generator to automatically include all Arduino framework library include paths under:

~/.platformio/packages/framework-arduinoespressif8266/libraries/```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions