Skip to content

feat(ldf): evaluate active preprocessor branches during library selection #1098

Description

@zackees

Problem

After #1097 changes framework library selection to seed only from sketch translation units, FastLED Teensy Blink no longer selects Audio, SD, SdFat, or SerialFlash. However fbuild lib-select --explain still selects DmxSimple, OctoWS2811, and SoftwareSerial because fbuild-header-scan deliberately traverses both sides of every conditional.

Examples in reachable FastLED headers:

  • #ifdef USE_OCTOWS2811 ? <OctoWS2811.h>
  • #ifdef DmxSimple_h ? <DmxSimple.h>
  • #if defined(ARDUINO) && defined(SoftwareSerial_h) ? <SoftwareSerial.h>

Those macros are not enabled by Blink, so the headers are not in the compiler's active include graph.

Required behavior

Library selection must follow the active include graph for the target build:

  1. Start from sketch translation units.
  2. Seed preprocessor state from the target's compile defines and sketch-local defines.
  3. Evaluate #if, #ifdef, #ifndef, #elif, #else, and #endif sufficiently to skip inactive #includes.
  4. Preserve selection when a sketch explicitly defines the relevant feature macro or includes the feature header directly.
  5. Incorporate the define set / conditional mode into the library-selection cache key.

Acceptance

  • FastLED Teensy 4.1 Blink selects only framework libraries in its active graph.
  • Blink does not select DmxSimple, OctoWS2811, SoftwareSerial, Audio, SD, SdFat, or SerialFlash unless the sketch enables/includes that feature.
  • Existing direct and transitive library-selection tests remain valid.
  • Add unit coverage for #if 0, inactive #ifdef, enabled sketch macro, and target compile defines.

Parent: #1094. Consumer: FastLED/FastLED#3696.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions