Skip to content

refactor(channels): trampoline enableAllDrivers platform bundles - #2480

Merged
zackees merged 1 commit into
masterfrom
refactor-enable-all-drivers-trampoline
May 14, 2026
Merged

zackees merged 1 commit into
masterfrom
refactor-enable-all-drivers-trampoline

Conversation

@zackees

@zackees zackees commented May 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Supersedes #2478 with a single squashed commit.

  • moves fl::enableAllDrivers() out of all_drivers.h and into the platform unity build
  • uses the repo's sparse dispatch convention: platforms/channel_drivers.impl.cpp.hpp is the include-once router, and platform-owned *.impl.hpp fragments provide ESP32, Teensy 4.x, stub/WASM, plus a null fallthrough implementation
  • keeps the fallthrough platform as an empty no-op definition, so unsupported platforms do not implicitly register BIT_BANG
  • keeps FastLED.enableAllDrivers() callable from <FastLED.h> without the old magic include requirement
  • updates host tests to assert registry behavior instead of comparing BusTraits function-local singleton addresses across DLL boundaries

Verification

  • python -m ci.lint_cpp.impl_hpp_includes_checker
  • python -m ci.lint_cpp.cpp_hpp_includes_checker
  • python -m ci.lint_cpp.iwyu_pragma_check
  • bash lint --cpp
  • bash test fl_channels_all_drivers --debug
  • bash test --cpp --force - 304/304 passing
  • bash lint - not clean locally due pre-existing Python KeyboardInterrupt checker findings in ci/compiler/pio.py and ci/util/fbuild_runner.py
  • bash compile --no-interactive --local --max-failures 1 esp32s3 SpecialDrivers/ESP/DriverTest - timed out locally after 30 minutes with no useful output before timeout

Notes

This keeps the tree-shaking strategy from #2478, but routes the per-platform bus_traits.h include list through the existing .impl.cpp.hpp trampoline pattern and its special linting rules. The final router branch now lands on platforms/shared/channel_drivers_null.impl.hpp, whose enableAllChannelDrivers() body is intentionally empty.

Summary by CodeRabbit

  • Documentation

    • Simplified FastLED.enableAllDrivers() usage—header inclusion no longer required
    • Updated guides reflect streamlined approach to enabling all channel drivers
  • Refactor

    • Improved binary efficiency: enableAllDrivers() now incurs zero binary size cost when unused through compiler optimization

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57f70e46-5c85-45a7-8186-9e1a7ac3c510

📥 Commits

Reviewing files that changed from the base of the PR and between d87106b and 8553d60.

📒 Files selected for processing (11)
  • src/FastLED.cpp.hpp
  • src/FastLED.h
  • src/fl/channels/README.md
  • src/fl/channels/all_drivers.h
  • src/platforms/_build.cpp.hpp
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp
  • src/platforms/channel_drivers.impl.cpp.hpp
  • src/platforms/esp/32/channel_drivers_esp32.impl.hpp
  • src/platforms/shared/channel_drivers_null.impl.hpp
  • src/platforms/stub/channel_drivers_stub.impl.hpp
  • tests/fl/channels/all_drivers.cpp
✅ Files skipped from review due to trivial changes (4)
  • src/platforms/shared/channel_drivers_null.impl.hpp
  • src/platforms/_build.cpp.hpp
  • src/fl/channels/README.md
  • src/FastLED.h
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/platforms/stub/channel_drivers_stub.impl.hpp
  • src/platforms/esp/32/channel_drivers_esp32.impl.hpp
  • tests/fl/channels/all_drivers.cpp
  • src/FastLED.cpp.hpp
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp
  • src/platforms/channel_drivers.impl.cpp.hpp
  • src/fl/channels/all_drivers.h

📝 Walkthrough

Walkthrough

The PR refactors fl::enableAllDrivers() from an inline header implementation into a modular out-of-line libfastled function. Users call FastLED.enableAllDrivers(), which forwards to platform-specific driver bundles dispatched at compile time. Header includes are simplified, build integration is updated, and test assertions are centralized via a helper function.

Changes

Driver enablement refactor

Layer / File(s) Summary
Public API forwarder and documentation
src/FastLED.cpp.hpp, src/FastLED.h
CFastLED::enableAllDrivers() method forwards to fl::enableAllDrivers(), with updated documentation explaining out-of-line implementation and -Wl,--gc-sections tree-shaking behavior.
Header simplification to declaration-only
src/fl/channels/all_drivers.h
all_drivers.h converted from kitchen-sink header with inline implementation and per-platform includes to lightweight declaration-only header, removing inline wrapper and eager BusTraits includes.
Out-of-line core implementation router
src/platforms/channel_drivers.impl.cpp.hpp
src/platforms/channel_drivers.impl.cpp.hpp serves as central translation unit defining fl::enableAllDrivers() as a wrapper around platforms::enableAllChannelDrivers(), with conditional includes selecting exactly one platform-specific implementation.
Platform-specific driver bundle implementations
src/platforms/esp/32/channel_drivers_esp32.impl.hpp, src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp, src/platforms/stub/channel_drivers_stub.impl.hpp, src/platforms/shared/channel_drivers_null.impl.hpp
Platform abstraction layer with concrete enableAllChannelDrivers() implementations: ESP32 (feature-gated RMT/PARLIO/SPI/I2S/LCD/UART), Teensy (BIT_BANG plus Teensy 4.x extensions), Stub/WASM (BIT_BANG and STUB), and generic null implementation (empty body).
Build integration and documentation updates
src/platforms/_build.cpp.hpp, src/fl/channels/README.md
Adds channel-drivers implementation to unity-build includes. Updates README.md to show minimal FastLED.enableAllDrivers() pattern without manual header includes, clarifying that libfastled provides the implementation with zero overhead via tree-shaking.
Test refactoring and helper extraction
tests/fl/channels/all_drivers.cpp
Extracts repeated driver registry assertion logic into checkHostDriversRegistered() helper that validates BIT_BANG and STUB driver registration by name and capability flags. Helper is applied to three test cases: host registration, FastLED forwarding, and idempotency.

Sequence Diagram

sequenceDiagram
  participant Sketch
  participant CFastLED
  participant FlEnable as fl::enableAllDrivers
  participant PlatEnable as platforms::enableAllChannelDrivers
  participant ChannelManager
  Sketch->>CFastLED: FastLED.enableAllDrivers()
  CFastLED->>FlEnable: forwards
  FlEnable->>PlatEnable: delegates (platform-selected)
  PlatEnable->>ChannelManager: registers drivers
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • FastLED/FastLED#2428: Both changes touch and modify the same driver-enablement API—specifically adding/relocating fl::enableAllDrivers() and CFastLED::enableAllDrivers() runtime driver-enable plumbing.

Possibly related PRs

  • FastLED/FastLED#2437: The main PR's new FastLED.enableAllDrivers()/fl::enableAllDrivers() forwarding is tightly coupled to the fl::enableDrivers<Bus...>() opt-in registration API and BusTraits<...>::registerWithManager() machinery introduced in the retrieved PR.
  • FastLED/FastLED#2461: Both PRs touch the fl::enableAllDrivers() / FastLED.enableAllDrivers() pathway—main PR refactors where enableAllDrivers() is declared/implemented and forwarded, while the other PR's non-template FastLED.add() runtime dispatch explicitly calls fl::enableAllDrivers().
  • FastLED/FastLED#2429: The main PR's new enableAllDrivers()/enableAllChannelDrivers() dispatchers directly enable specific fl::Bus values and its tests validate driver capability flags via the fl::BusTraits model introduced in the retrieved PR.

Poem

🐰 A rabbit refactors with care,
Moving code from here to there,
Platform bundles, clean and neat,
Each driver dances to its beat!
Tree-shaking magic, zero cost,
No header bloat, nothing lost! 🌳✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving fl::enableAllDrivers() implementation into a platform-dispatch trampoline system (platforms/channel_drivers.impl.cpp.hpp) with platform-specific bundles.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-enable-all-drivers-trampoline

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees force-pushed the refactor-enable-all-drivers-trampoline branch from 178442c to d87106b Compare May 14, 2026 14:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp (1)

1-1: ⚡ Quick win

Replace raw #pragma once with the project-approved guard style.

Line 1 uses a raw pragma directive. Please switch to include guards (or the repository’s compiler-control macro form) to match project conventions.

As per coding guidelines, "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp` at line 1, Replace
the raw `#pragma once` at the top of channel_drivers_teensy.impl.hpp with the
project-approved include guard style: either include `fl/stl/compiler_control.h`
and wrap the header with the repository’s compiler control macros, or use a
conventional include guard like `#ifndef CHANNEL_DRIVERS_TEENSY_IMPL_HPP` /
`#define CHANNEL_DRIVERS_TEENSY_IMPL_HPP` ... `#endif`; ensure the guard macro
is unique (e.g., CHANNEL_DRIVERS_TEENSY_IMPL_HPP) and remove the `#pragma once`
line.
src/platforms/esp/32/channel_drivers_esp32.impl.hpp (1)

1-1: ⚡ Quick win

Replace raw #pragma once with the project-approved guard style.

Line 1 uses a raw pragma directive. Please switch to include guards (or the repository’s compiler-control macro form) to match project conventions.

As per coding guidelines, "Use FastLED compiler control macros from fl/stl/compiler_control.h instead of raw #pragma directives".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platforms/esp/32/channel_drivers_esp32.impl.hpp` at line 1, Remove the
raw "#pragma once" at the top of
src/platforms/esp/32/channel_drivers_esp32.impl.hpp and replace it with the
project-approved include guard pattern: add `#include` "fl/stl/compiler_control.h"
(to use the FastLED compiler-control macros) and then wrap the header with a
conventional include guard macro (for example, use
SRC_PLATFORMS_ESP_32_CHANNEL_DRIVERS_ESP32_IMPL_HPP) or the specific
compiler-control BEGIN/END macros from fl/stl/compiler_control.h if the project
provides them; ensure the guard macro name matches the header and closes at the
end of the file to prevent multiple inclusion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp`:
- Line 1: Replace the raw `#pragma once` at the top of
channel_drivers_teensy.impl.hpp with the project-approved include guard style:
either include `fl/stl/compiler_control.h` and wrap the header with the
repository’s compiler control macros, or use a conventional include guard like
`#ifndef CHANNEL_DRIVERS_TEENSY_IMPL_HPP` / `#define
CHANNEL_DRIVERS_TEENSY_IMPL_HPP` ... `#endif`; ensure the guard macro is unique
(e.g., CHANNEL_DRIVERS_TEENSY_IMPL_HPP) and remove the `#pragma once` line.

In `@src/platforms/esp/32/channel_drivers_esp32.impl.hpp`:
- Line 1: Remove the raw "#pragma once" at the top of
src/platforms/esp/32/channel_drivers_esp32.impl.hpp and replace it with the
project-approved include guard pattern: add `#include` "fl/stl/compiler_control.h"
(to use the FastLED compiler-control macros) and then wrap the header with a
conventional include guard macro (for example, use
SRC_PLATFORMS_ESP_32_CHANNEL_DRIVERS_ESP32_IMPL_HPP) or the specific
compiler-control BEGIN/END macros from fl/stl/compiler_control.h if the project
provides them; ensure the guard macro name matches the header and closes at the
end of the file to prevent multiple inclusion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 577996a5-8093-463c-859f-cc7ca0361e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 178442c and d87106b.

📒 Files selected for processing (11)
  • src/FastLED.cpp.hpp
  • src/FastLED.h
  • src/fl/channels/README.md
  • src/fl/channels/all_drivers.h
  • src/platforms/_build.cpp.hpp
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp
  • src/platforms/channel_drivers.impl.cpp.hpp
  • src/platforms/esp/32/channel_drivers_esp32.impl.hpp
  • src/platforms/shared/channel_drivers_default.impl.hpp
  • src/platforms/stub/channel_drivers_stub.impl.hpp
  • tests/fl/channels/all_drivers.cpp
✅ Files skipped from review due to trivial changes (6)
  • src/platforms/stub/channel_drivers_stub.impl.hpp
  • src/platforms/_build.cpp.hpp
  • src/platforms/shared/channel_drivers_default.impl.hpp
  • src/FastLED.cpp.hpp
  • src/FastLED.h
  • src/fl/channels/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/fl/channels/all_drivers.cpp
  • src/fl/channels/all_drivers.h

Move enableAllDrivers out of the declaration header and route the implementation through platform-specific channel-driver bundles. This keeps call sites on FastLED.h only while ensuring each platform owns the bus_traits includes used to instantiate its supported drivers.

Also updates host tests to verify registry behavior rather than comparing BusTraits function-local singleton addresses across DLL boundaries.
@zackees
zackees force-pushed the refactor-enable-all-drivers-trampoline branch from d87106b to 8553d60 Compare May 14, 2026 18:27
@zackees
zackees merged commit 6657bbf into master May 14, 2026
5 of 6 checks passed
zackees added a commit that referenced this pull request May 18, 2026
* perf(wasm): wire ctc-emcc native launcher into WASM cross-file

The native build pipeline previously replaced clang-tool-chain-cpp.EXE
(a Python entry point with ~828ms startup per invocation) with the raw
clang++ binary resolved in the Meson native file. That alone cut total
native build time 54% (Meson Setup 27.6s -> 10.1s, see PR #2480 and
predecessor work).

The WASM build still routed every emcc invocation through
clang-tool-chain-emcc (Python entry point). This change wires the
compiled ctc-emcc / ctc-em++ native launchers (built on demand via
clang_tool_chain.commands.compile_native) into a dynamically generated
WASM Meson cross-file at <build_dir>/wasm_cross_file.generated.ini.

The launcher implements a 3-tier strategy (user-template -> flag-hash
auto-cache -> Python fallback), so uncached link/preprocess steps still
work correctly via the Python emcc.py underneath.

Fallback is preserved: if launcher resolution fails for any reason the
generated cross-file falls back to clang-tool-chain-emcc, matching the
historical static cross-file content. Worst case: WASM build is no
slower than before.

The static template at ci/meson/wasm_cross_file.ini is retained as both
documentation and a stable fingerprint anchor (so structural edits to
host_machine/properties still invalidate the library cache).

Out of scope (follow-up issues):
- ctc-wasm-ld.exe wiring (separate optimization)
- ctc-emar (no native launcher exists for it yet)

Closes #2485
Refs #2480

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(wasm): address CodeRabbit feedback on ctc-emcc launcher

- _ensure_emcc_native_launcher: log a [WASM] warning with the exception
  text before falling back to the Python wrapper (previously a silent
  except Exception: pass masked compile failures). KeyboardInterrupt
  still routes through handle_keyboard_interrupt.
- resolve_wasm_native_entries: same logging treatment on the outer
  resolver fallback path so callers see why the native launcher was
  bypassed.
- ensure_meson_configured: render the WASM cross-file before the
  fast-path return so a freshly built or repaired native launcher is
  picked up on the next meson invocation against an existing build
  directory. No reconfigure is forced; the cheap ini write is enough.
- Apply ruff format normalizations to ci/compiler/pio.py and
  ci/esbuild_frontend.py that were flagged by bash lint.

Skipped:
- @TypeChecked on WasmNativeEntries: decorator is not used elsewhere
  in ci/meson/build_config.py and the dataclass plus consumers are
  already statically typed. Better handled in a repo-wide pass.
- Reworking the hardcoded wasm_cross_file.ini contents into a
  template: the static file is still referenced as a fingerprint
  anchor in _compute_library_fingerprint (line 144), so removing or
  templating it adds non-trivial scope to this PR. Deferred to a
  follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the refactor-enable-all-drivers-trampoline branch August 21, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant