Repository navigation
feat(channels): gate driver aggregator + pre-bind remaining legacy clockless (Phase 5c of #2428) - #2450
Conversation
…ockless (Phase 5c of #2428) Phase 5c of #2428 completes the binary-size fix for #2420 by gating the ESP32 driver-aggregator includes against `FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY` and pre-binding the remaining legacy clockless controllers to their default `BusTraits<Bus::X>::instancePtr()` singletons. Default behavior is byte-for-byte unchanged: with the macro at its default value of 0, every driver TU still compiles and registers, every test passes identically, and every existing sketch links the same way it does on master. What changed: 1) Per-driver `_build.cpp.hpp` self-gating Each LED-output driver subdir under `src/platforms/esp/32/drivers/` now self-gates against the macro: - `i2s/`, `lcd_cam/`, `spi/`, `uart/` — never a platform default; the TU becomes empty when the macro is on. - `parlio/` — default on ESP32-P4 / C6 / H2 / C5; always compiled there. Gated by the macro on every other ESP32 variant. - `rmt/` — default on every ESP32 variant EXCEPT P4 / C6 / H2 / C5; always compiled there. Gated by the macro on the PARLIO-default variants. - `lcd_spi/` — default true-SPI on ESP32-S3; always compiled there. Gated by the macro on every other ESP32 variant. - `i2s_spi/` — default true-SPI on ESP32dev; always compiled there. Gated by the macro on every other ESP32 variant. - `ble/`, `gpio_isr_rx/`, `rmt_rx/` — not LED-output channel drivers; remain unconditional. The top-level `src/platforms/esp/32/drivers/_build.cpp.hpp` aggregator stays as a single alphabetical list (one include per subdir) so the unity-build linter is satisfied. All conditional logic moves into each subdir's `_build.cpp.hpp`. 2) Legacy clockless controllers pre-bound to BusTraits singletons Phase 5b already wired this up for RMT5 (`idf5_clockless.h`) and stub (`clockless_channel_stub.h`). Phase 5c extends the pattern to: - `idf4_clockless_rmt_esp32.h` — RMT4 legacy clockless. Now binds to `BusTraits<Bus::RMT>::instancePtr()` when the macro is on instead of calling `ChannelManager::instance().getDriverByName("RMT")`. - `idf5_clockless_spi_esp32.h` — ESP32 clockless-over-SPI. Binds to `BusTraits<Bus::SPI>::instancePtr()`. - `clockless_channel_wasm.h` / `spi_channel_wasm.h` — WASM clockless + SPI. Both bind to `BusTraits<Bus::STUB>::instancePtr()` (WASM uses stub driver for both chipset families). - `spi_channel_stub.h` — host SPI stub. Binds to `BusTraits<Bus::STUB>`. `ClocklessBlockingGeneric` (the pure CPU-bitbang fallback in `platforms/shared/clockless_blocking.h`) does not use a Channel/Driver at all and is intentionally left unmodified. Mechanism (recap from 5a/5b): When `FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY=1` is defined: - `initChannelDrivers()` becomes a no-op (5a) — no eager `addDriver()` calls to manager. - Each per-platform legacy clockless controller ODR-uses ONLY `BusTraits<Bus::DefaultClocklessBus>::instancePtr()` in its constructor (5b + 5c) — the default driver is the only one that survives `--gc-sections`. - Each non-default driver subdir's `_build.cpp.hpp` is empty (5c) — those TUs are not compiled at all. For the #2420 reproducer (NEOPIXEL-only sketch on ESP32-S3 with `-DFASTLED_DISABLE_LEGACY_DRIVER_REGISTRY=1`), the expected behavior is: RMT5 + LCD_SPI driver TUs compile; PARLIO / I2S / I2S_SPI / LCD_CAM / clockless-SPI / UART / RMT4 driver TUs do not. Binary size should drop from ~783 KB toward the 344 KB baseline from 3.10.3. Constraints honored: - No touch to `src/fl/channels/{channel.h,config.h,_build.cpp.hpp}` — Phase 3b (templatize ChannelConfig/Channel) is in-flight on a parallel branch. - No new macros introduced; the existing `FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY` from 5a/5b is the sole opt-in flag. - Unity-build linter passes (top-level aggregator stays alphabetical; each subdir's _build.cpp.hpp has its own gate that the linter treats as a single conditional block). Verification: - `bash test --cpp` — 303/303 pass on default (macro=0) build. - `bash compile wasm --examples Blink` — succeeds. - `bash lint` — clean. - ESP32-S3 platform compile + size measurement deferred to CI (the local platform build infrastructure was unstable during this session — daemon errors and watchdog timeouts). The opt-in macro is gated behind an explicit user define, so no shipping binaries change unless the user opts in. Files touched: 14 src/platforms/esp/32/drivers/_build.cpp.hpp src/platforms/esp/32/drivers/i2s/_build.cpp.hpp src/platforms/esp/32/drivers/i2s_spi/_build.cpp.hpp src/platforms/esp/32/drivers/lcd_cam/_build.cpp.hpp src/platforms/esp/32/drivers/lcd_spi/_build.cpp.hpp src/platforms/esp/32/drivers/parlio/_build.cpp.hpp src/platforms/esp/32/drivers/rmt/_build.cpp.hpp src/platforms/esp/32/drivers/rmt/rmt_4/idf4_clockless_rmt_esp32.h src/platforms/esp/32/drivers/spi/_build.cpp.hpp src/platforms/esp/32/drivers/spi/idf5_clockless_spi_esp32.h src/platforms/esp/32/drivers/uart/_build.cpp.hpp src/platforms/stub/spi_channel_stub.h src/platforms/wasm/clockless_channel_wasm.h src/platforms/wasm/spi_channel_wasm.h Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThis PR implements Phase 5c of the legacy driver registry opt-in feature: conditionally gates platform-specific driver unity-build translation units and updates driver selection methods to bypass ChangesLegacy Driver Registry Opt-In Gating (Phase 5c)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Phase 5c of #2428 completes the binary-size fix from #2420 by:
_build.cpp.hppaggregators againstFASTLED_DISABLE_LEGACY_DRIVER_REGISTRY. When the macro is enabled (opt-in), only the per-platform default driver TUs compile; all other driver TUs become empty.BusTraits<Bus::X>::instancePtr()singleton — mirroring what 5b did for RMT5 / stub. Covers RMT4 (idf4_clockless_rmt_esp32.h), ESP32 clockless-over-SPI (idf5_clockless_spi_esp32.h), WASM clockless + SPI, and host stub SPI.ClocklessBlockingGeneric(pure CPU bitbang) does not use a Channel/Driver and is intentionally untouched.Default behavior is byte-for-byte unchanged: with the macro at its default value of
0, every driver TU still compiles and registers exactly as before.Per-platform default routing
Bus::PARLIOBus::RMTBus::LCD_SPIBus::RMTBus::I2S_SPIBus::RMTEach driver subdir's
_build.cpp.hppis unconditional on its default variant(s) and gated by the macro everywhere else.ble/,gpio_isr_rx/,rmt_rx/are non-LED-output drivers and remain unconditional.Why the conditional logic lives in each subdir's
_build.cpp.hppThe unity-build linter (
ci/lint_cpp/test_unity_build.py) requires the top-level_build.cpp.hppaggregator to list every subdir alphabetically in a single// begin sub directory includesblock. Wrapping the parent in#ifblocks fails the alphabetization check. Pushing the conditional gating into each subdir's_build.cpp.hppkeeps the parent linter-clean while still removing the unused TUs from compilation.Expected binary-size impact
For the #2420 reproducer (NEOPIXEL-only sketch on ESP32-S3 with
-DFASTLED_DISABLE_LEGACY_DRIVER_REGISTRY=1):macro=0): ~783 KB (unchanged from master HEAD).macro=1): expected to drop toward the ~344 KB baseline from 3.10.3.Local ESP32-S3 platform measurement was deferred — the
fbuilddaemon in this worktree environment hung repeatedly (daemon error: stream error: error decoding response body, watchdog timeouts). CI will produce the authoritative before/after numbers.Verification
bash test --cpp— 303/303 pass on the default (macro=0) build.bash compile wasm --examples Blink— succeeds.bash lint— clean (Python, C++, JavaScript, meson).mDriverPreBoundflag from 5b stays unchanged; default-mode tests don't observe the new code paths.Files changed (14)
src/platforms/esp/32/drivers/_build.cpp.hppsrc/platforms/esp/32/drivers/i2s/_build.cpp.hppsrc/platforms/esp/32/drivers/i2s_spi/_build.cpp.hppsrc/platforms/esp/32/drivers/lcd_cam/_build.cpp.hppsrc/platforms/esp/32/drivers/lcd_spi/_build.cpp.hppsrc/platforms/esp/32/drivers/parlio/_build.cpp.hppsrc/platforms/esp/32/drivers/rmt/_build.cpp.hppsrc/platforms/esp/32/drivers/rmt/rmt_4/idf4_clockless_rmt_esp32.hsrc/platforms/esp/32/drivers/spi/_build.cpp.hppsrc/platforms/esp/32/drivers/spi/idf5_clockless_spi_esp32.hsrc/platforms/esp/32/drivers/uart/_build.cpp.hppsrc/platforms/stub/spi_channel_stub.hsrc/platforms/wasm/clockless_channel_wasm.hsrc/platforms/wasm/spi_channel_wasm.hConstraints honored
src/fl/channels/{channel.h,config.h,_build.cpp.hpp}— Phase 3b (templatizeChannelConfig/Channel) is in flight on a parallel branch.FASTLED_DISABLE_LEGACY_DRIVER_REGISTRYfrom 5a/5b is the sole opt-in flag.Test plan
bash test --cpppasses (303/303).bash compile wasm --examples Blinkpasses.bash compile esp32s3 --examples Blinkpasses on default macro state — confirms backward compatibility.bash compile esp32s3 --examples Blink --defines FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY=1passes and produces a smaller binary ([Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420 reproducer).🤖 Generated with Claude Code
Summary by CodeRabbit