-
-
Notifications
You must be signed in to change notification settings - Fork 823
Description
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
- Create a PlatformIO project using
pio project init -b d1_mini --ide vim --sample-code
. - Update
platformio.ini
with python script to include toolchain - Add dependencies that use Arduino built-in libraries, e.g., include
<SPI.h>
or<Wire.h>
. - Run
pio run -t compiledb
to generatecompile_commands.json
. - Open the project with clangd or any language server expecting complete include paths.
- 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/```