PlatformIO Community

Can't seem to exclude a cpp file from the build using src_filter

I am adding a library from GitHub as a submodule. It includes a main.cpp file that is causing multiple definition problems at the linking step. I tried excluding it using src_filter, but no luck. Of course, I can manually delete the file, but I would have to do that every time I update the submodule. I was hoping for a simple way to exclude it from the build.

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
lib_deps =
    [khoih-prog/ESP_WiFiManager@^1.3.0](mailto:khoih-prog/ESP_WiFiManager@%5e1.3.0)
    [arduino-libraries/NTPClient@^3.1.0](mailto:arduino-libraries/NTPClient@%5e3.1.0)
    [paulstoffregen/Time@^1.6.1](mailto:paulstoffregen/Time@%5e1.6.1)
    [arkhipenko/TaskScheduler@^3.3.0](mailto:arkhipenko/TaskScheduler@%5e3.3.0)
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/>
    -<src/DebounceSwitch_submodule/>
    +<src/DebounceSwitch_submodule/DebounceSwitch.h>
    +<src/DebounceSwitch_submodule/DebounceSwitch.cpp>

Read through

For further help we’d need to know the folder and file structure in src/.

Thanks! I suppose I was over-thinking it. I was assuming that since the other entries in src_filter specify paths relative to the main project folder (i.e., .git/ and test/) that I should do the same for the submodule folder in src/. But that is not the case. The following code does the job.

src_filter = +<*> -<.git/> -<.svn/> … -<DebounceSwitch_submodule/main.cpp>