PlatformIO Community

Library depends on another library, but only on one platform

I have a library that is available for esp8266 as well as esp32. But only on esp32 the library depends on another library.

So, my library.json looks like (abbreviated):

{
    "name" : "iotsa",
    ...
    "platforms" : [ "espressif8266", "espressif32"],
    "dependencies" : [
        ...
        {
            "name" : "esp32_https_server_compat",
            "platforms" : "espressif32"
        }
    ]
}

But: if I build a project for esp8266 that uses my iotsa library for esp8266 somehow the esp32_https_server_compat library is included in the library dependencies, and then pio tries to compile it, and then things fail. I’ve tried all 4 ldf modes of chain+, deep+, chain and deep, but no difference.

Apparently I misunderstand how platforms within dependencies works.

How can I include another library only when building for a specific platform?

Could you try to set libCompatMode to strict?

Ah, that is an interesting option! I wasn’t aware of it, it isn’t exactly featured very prominently in the documentation…

And, theoretically it solves the problem I had: esp32_https_server_compat is now no longer included.

Unfortunately setting lib_compat_mode = strict reveals a completely different problem: many libraries have a library.json that lists too strict values for platforms, for example only atmelavr while the library is perfectly compatible with esp8266 or esp32. So my project still doesn’t build…

I do now understand why the default isn’t lib_compat_mode = strict:slight_smile:

For now I will just continue to use lib_ignore, and I’ll post issues on the various libraries I depend on, maybe one day I can use lib_compat_mode = strict.