PlatformIO Community

Is second-level inheritance possible?

[env] seems to be inherited by [env:A], [env:B], etc. But, is it possible to inherit [env:A]?

For example,

[env]
platform = espressif8266
framework = arduino
lib_dep = someLinbrary
lib_extra_dirs = some directory

[env:ESP01]
board = esp01_1m

[env:ESP01:debug]
build_type = debug

[env:ESP01:release]
bulid_type=release

[env:NodeMCU]
board = nodemcuv2

[env:NodeMCU:debug]
build_type = debug

[env:NodeMCU:release]
bulid_type=release

Yes, through extends, arbitrary-depth inheritence is possible.

Though you should only be using the name scheme env:name name not env:name1:name2.

A project that uses such a structure is e.g. Marlin.

[common_stm32]
platform         = ststm32@~12.1
board_build.core = stm32

;..

[stm32_variant]
extends       = common_stm32
extra_scripts = ${common_stm32.extra_scripts}

;..

[common_STM32F103RC_variant]
extends              = stm32_variant
board                = genericSTM32F103RC

;..

[env:STM32F103RC_btt]
platform                    = ${common_stm32.platform}
extends                     = common_STM32F103RC_variant
build_flags                 = ${common_STM32F103RC_variant.build_flags}
                              -DTIMER_SERVO=TIM5