PlatformIO Community

How to ignore some source files from a library when building

I’d like to use this library in an stm32 project. Adding it to platformio.ini file worked to acquire it, but when building I get some errors.

Compiling .pio/build/genericSTM32F103RC/libea6/Trinamic-library/tmc2209hal.o
.pio/libdeps/genericSTM32F103RC/Trinamic-library/tmc2130hal.c:42:10: fatal error: grbl/hal.h: No such file or directory
 #include "grbl/hal.h"
compilation terminated.

The error is correct because I’m not using grbl (the dependency should be missing). However, I don’t need the object that is built. At this point I don’t even include any tmc headers in my project.

Is there a way to only build the headers that are included in my project source files before building lib files?


platform = ststm32
board = genericSTM32F103RC
framework = stm32cube
debug_tool = stlink
upload_protocol = stlink
monitor_speed = 115200
board_build.stm32cube.custom_config_header = yes
    -mthumb #-mfpu=fpv4-sp-d16 -mfloat-abi=softfp
lib_extra_dirs =
    ; Middlewares
lib_deps =

src_dir = Core/Src
include_dir = Core/Inc

Do you mean Build Middlewares — PlatformIO latest documentation ?

Some extra scripting could do the trick but I think that is overkill. The build task is automatically building things I’m not including.

I can fork it and add my own pio manifests, I guess.

Wanted to add that I also run into this somewhat frequently. Ideally, PlatformIO would build libraries lazily, only building files which are included elsewhere, if possible.