Skip to content

Commit c0d6cfc

Browse files
committed
add example demonstrating advanced PlatformIO environment inheritance
Adds a self-documented example demonstrating how a user can inherit from a core WLED configuration and add their own values without needing to copy all of the upstream values manually. This new method simplifies configuration maintenance for the users.
1 parent e76e9a3 commit c0d6cfc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

platformio_override.sample.ini

+33
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,36 @@ extends = env:esp32dev
536536
build_flags = ${env:esp32dev.build_flags} -D USERMOD_RF433
537537
lib_deps = ${env:esp32dev.lib_deps}
538538
sui77/rc-switch @ 2.6.4
539+
540+
# ------------------------------------------------------------------------------
541+
# Advanced example: Inheriting all settings from an upstream "base" config, and
542+
# adding/overriding specific build flags, which is useful if you want to base
543+
# your environment on a stable core env but just override certain WLED defaults.
544+
# ------------------------------------------------------------------------------
545+
546+
[env:esp32_eth_custom]
547+
;; Inherit all settings from upstream config. We can then override specific settings.
548+
;; WARNING: The upstream environment's name, such as "esp32_eth" in this example,
549+
;; must also be specified in the other inherited settings (see example below).
550+
extends = env:esp32_eth
551+
552+
;; Remove conflicting upstream flags to fix compiler "variable redefined" warnings.
553+
;; WARNING: Must specify the EXACT upstream "build_flags" flag VALUES to unset;
554+
;; because if we don't specify any value then it unsets ALL instances of the
555+
;; flag, meaning that it would erase our new values too.
556+
;; NOTE: If the upstream values are ever changed, the compiler will encounter
557+
;; duplicate values and complain about "variable redefined" again, meaning that
558+
;; these values will simply need to be revised. So maintenance is safe and easy.
559+
build_unflags = ${env:esp32_eth.build_unflags}
560+
;; Unset the old, conflicting flag values:
561+
-D WLED_RELEASE_NAME=\"ESP32_Ethernet\"
562+
-D RLYPIN=-1
563+
564+
;; Inherit all upstream flags and then overwrite/append with some custom values.
565+
;; NOTE: You can add/modify ANY of the WLED build-time variables here (it doesn't
566+
;; have to be values that were in the original upstream config).
567+
build_flags = ${env:esp32_eth.build_flags}
568+
;; Set/add your new flag values:
569+
-D WLED_RELEASE_NAME=\"ESP32_Ethernet_Custom\"
570+
-D RLYPIN=24
571+

0 commit comments

Comments
 (0)