Operating system: Windows 10 x64
PlatformIO Version : PlatformIO, version 4.3.4 + VS Code 1.46.0
I've found what I think is a bug. If I comment out an #include with library in one-line block comment (e.g. /*#include <EEPROM.h>*/), the library gets removed from Dependecy graph. This is correct behavior.
However, if I comment the #include with a multiline block comment like this:
/*
#include <EEPROM.h>
*/
then the library still ends up in dependency graph, gets compiled etc.
#include <Arduino.h>
/* #include <EEPROM.h> */
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Scanning dependencies...
No dependencies
#include <Arduino.h>
/*
#include <EEPROM.h>
*/
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Scanning dependencies...
Dependency Graph
|-- <EEPROM> 2.0
In both cases the library should not be included in build.
I'm using PIO from VS Code and installed all stuff via VS Code.
I've also tried enabling "chain+" mode in platformio.ini, but this did not change anything
Could it be similar behavior when the include is 'disabled' via #ifdef wrappers?
For example:
#ifdef USE_LIB_FOO
#include <foo>
#else
#include <bar>
#endif
AFAIK, since default search mode is chain, ifdefs are not supposed to work anyway (only in "chain+" or "deep+" modes). Comments, however, are.
@TD-er not sure if this help, but I created a quick test and I've added lib_ldf_mode = chain+ to platform.ini.
main.cpp:
#include <Arduino.h>
#ifdef USE_LITTLEFS
#include <FS.h>
#include <LittleFS.h>
#else
#include <FS.h>
#endif
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
platform.ini file:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
build_flags = -D USE_LITTLEFS
lib_ldf_mode = chain+
result:

platform.ini:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
build_flags = -D NOT_USE_LITTLEFS; this has changed
lib_ldf_mode = chain+

I hope this helps 馃檪
Just for reference: docs.platformio.org - ldf-mode
I will try to use the chain+ mode.
But in the past I have also looked into this and then the chain+ mode (or the deep(+) mode) had some issues. Sadly I don't remember what those were.