platformio/platformio-core

Library with `libCompatMode: strict` is not actually being strict

Open

#5171 opened on May 29, 2025

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Python (7,329 stars) (791 forks)batch import
LDFhelp wanted

Description

I have a problem during build of espressif32 platform where a library with libCompatMode of strict still tries to build other platforms code. I have to set lib_compat_mode in projects platformio.ini to work around this, but I would expect that libCompatMode would set strict mode for all dependencies of my library.

See here:

project/lib/esp32-common-lib/library.json

{
  "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
  "name": "esp32-common-lib",
  "version": "1.0.0",
  "license": "private",
  "frameworks": [
    "arduino"
  ],
  "platforms": [
    "espressif32"
  ],
  "dependencies": [
    {
      "owner": "greiman",
      "name": "SdFat",
      "version": "^2.2.0"
    },
    {
      "owner": "bblanchon",
      "name": "ArduinoJson",
      "version": "^7.0.0"
    },
    {
      "owner": "Links2004",
      "name": "WebSockets",
      "version": "^2.3.6"
    },
    {
      "owner": "esp32async",
      "name": "ESPAsyncWebServer",
      "version": "^3.7.7",
      "platforms": ["espressif32"]
    }
  ],
  "build": {
    "libCompatMode": "strict"
  }
}

The problem is RPAsyncTCP, a dependency of ESPAsyncWebServer. (ESPAsyncWebServer does not have strict libCompatMode enabled)

project/platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.filesystem = littlefs
lib_deps = xreef/PCF8574 library@^2.3.7
; Uncomment following line to workaround this bug
; lib_compat_mode = strict

Contributor guide