PlatformIO Community

How to suppress automatic libdep by #include?

TL;DR, automatic library dependency picked an unused freertos dependency which breaks the build. Is there a way to suppress it?

When I try to use the LVGL library, the automatic dependency algorithm adds freertos as a dependency which breaks the build because freertos required a user provided custom configuration. The inclusion from LVL is suppressed by an #if so should be ignored for dependency detection.

#if  ... false condition ...
#include "FreeRTOS.h"
#endif

platformio.ini (forums breaks indentation)

[env:raspberry-pi-pico]
platform = wizio-pico
board = raspberry-pi-pico
framework = baremetal
upload_protocol = picoprobe
debug_tool = picoprobe
monitor_port = COM8
build_flags =
-Wno-missing-field-initializers
-D PICO_STDIO_USB
-D LV_CONF_INCLUDE_SIMPLE
-I src
-I “$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK111/hardware”
lib_deps = lvgl/lvgl@7.9.1

Build

Verbose mode can be enabled via `-v, --verbose` option
<<<<<<<<<<<< WIZIO - RASPBERRY PI PICO ( PICOPROBE ) 2021 Georgi Angelov >>>>>>>>>>>>
CONFIGURATION: https://docs.platformio.org/page/boards/wizio-pico/raspberry-pi-pico.html
PLATFORM: WizIO - Raspberry Pi Pico (1.0.8+sha.c1d1a04) > WizIO - Raspberry Pi Pico ( PICOPROBE )
HARDWARE: RP2040 125MHz, 256KB RAM, 2MB Flash
DEBUG: Current (picoprobe) External (cmsis-dap, picoprobe)
PACKAGES:
 - framework-wizio-pico 1.0.8+sha.fd9dd1d
 - tool-wizio-pico 1.0.0+sha.3a504e1
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)

SDK RASPBERRYPI PI PICO RP2040 ( PICO - SDK )
  * OPTIMIZATION : -Os
  * STACK        : 2048
  * HEAP         : 2048
  * SPECS        : nano.specs
  * BINARY TYPE  : default ['w25q080', 'memmap_default.ld', '0x10000000']
  * PICO_STDIO_USB
  * USB          : tinyusb

LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <lvgl> 7.9.1
|   |-- <freertos>

In the build output there’s this:

That’s hinting about the docs for the dependency finder. Looking on that page we see the default setting is chain which does not evaluate C/C++ preprocessor statements.

Also the we see that the chain+. Option is the same as chain but does evaluate C/C++ preprocessor statements.

You need to add lib_ldf_mode = chain+ to your platformio.ini and all should be well.

Cheers,
Norm.

Either that what @NormanDunbar said, to get a clean library detection, or lib_ignore the wrong ones by name, though you should prefer the first one.

Thanks everybody, this is very useful.

Both lib_ldf_mode and lib_ignore work and lib_ignore seems to be faster. I presume that chain+ is not the default because it takes more time.