Can not ignore library subdirectory when compiling


I have a library I need to compile for two different platforms, so I want to remove all other platform-specific code from compilation. I found this page, which gives an example exactly for what I want to do.

My directory structure is this (located in .pio/libdeps/debug):

├── src
│   ├── bananapi
│   ├── feather
├── library.json

Contents of library.json:

  "name": "avarange-cnc",
  "version": "0.0.0",
  "build": {
    "extraScript": ""

Contents of

from os.path import realpath

env.Replace(SRC_FILTER=["+<*>", "-<src*>", "+<src/feather>"])

But this does not work. PlatformIO still attempts to compile code from the wrong subdirectory:

.pio/libdeps/debug/avarange-cnc/src/bananapi/avarange_cnc.c:2:10: fatal error: avarange-platform/macros.h: No such file or directory
    2 | #include <avarange-platform/macros.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I checked that the script is executed, and it is, realpath works etc. so I don’t know what is wrong.
What am I missing?


Usually paths for the source filter are relative to src/, so you would need to -<*> +<feather/> instead.