Platform restrictions on dependencies of submodule in project not honored

Using:
PlatformIO 6.1.16
VSCode: 1.96.4
PlatformIO IDE extension: 3.3.4


Our project makes use of submodules, including our own specific libraries into a project. A submodule has its own dependencies, listed in the library.json file.
Of course the dependencies listed in the submodule have their own dependencies.

Example:

 ProjectX
   /lib/Sense_Modbus (submodule)
      miq19/eModbus
          AsyncTcp   restricted to platforms: ["espressif32"]
          Ethernet     restricted to platform: ["espressif32"]
          ESPAsyncTCP restricted to platforms: ["espressif8266"]

When compiling and downloading dependencies using espressif32 platform, all three dependencies of eModbus are installed in .pio/libdeps and this will cause compile errors in the ESPAsyncTCP library.

When I open the Sense_Modbus library as a standalone project and build it using espressif32, the ESPAsyncTCP dependency is NOT downloaded.

There are no references to any source files from the ESPAsyncTCP library in the code, so it looks like the dependency finder does not use the platform setting when adding dependencies of dependencies of submodules to the list.

Is this a bug or am I doing something wrong?


library.json of Sense_Modbus (relevant part)

  "frameworks": "Arduino",
  "platforms": [
    "espressif32"
  ],
  "dependencies": [
    {
      "name": "EspSoftwareSerial",
      "version": "plerup/EspSoftwareSerial @ ^6.17.0"
    },
    {
      "name": "eModbus",
      "version": "miq19/eModbus @ 1.7.2"
    }
  ]

library.json of eModbus (relevant portion)

  "repository": {
    "type": "git",
    "url": "https://github.com/eModbus/eModbus",
    "branch": "master"
  },
  "dependencies": [
    {
      "owner": "me-no-dev",
      "name": "AsyncTCP",
      "version": "*",
      "platforms": ["espressif32"]
    },
    {
      "owner": "me-no-dev",
      "name": "ESPAsyncTCP",
      "version": "*",
      "platforms": ["espressif8266"]
    },
    {
      "name": "Ethernet",
      "version": "https://github.com/arduino-libraries/Ethernet.git",
      "platforms": ["espressif32"]
    }
  ],
  "frameworks": "arduino",
  "platforms": [
    "espressif32",
    "espressif8266"
  ]

We found a workaround by specifying lib_ignore

lib_ignore = ESPAsyncTCP

But that is only a workaround … not a real solution

Default lib_compat mode is to check that it’s only framework compatible, not also platform compatible. Can you, in the library.json, additionally set libCompatMode to “strict”? See docs.

I added this to the library.json the Sense_Modbus library.json but that doesnt make a difference. Also added lib_compat_mode = strict to the platformio of my toplevel project, but that also does not make a difference

Then that more looks like a bug. Can you file one in https://github.com/platformio/platformio-core/issues?

Create issues: Platform restrictions on dependencies of submodule in project not honored · Issue #5073 · platformio/platformio-core · GitHub