Skip to content

ino conversion hoists #include lines out of #if blocks, breaking sketches with platform-conditional includes #1440

Description

@zackees

Symptom

FastLED's clone and compile job, which runs fbuild build on the root project (src_dir = examples/Sailboat, default_envs = esp32s3), has failed on every master run since it switched to fbuild (e.g. FastLED/FastLED run 35323494299):

.fbuild/build/esp32s3/release/src/Sailboat.ino.cpp:3:10: fatal error: Audio.h: No such file or directory

Cause

The sketch includes a Teensy-only header behind a guard:

#include <FastLED.h>

#if defined(FL_IS_TEENSY)
#include <Audio.h>
#endif

fbuild 2.5.23 generates this Sailboat.ino.cpp, with every #include lifted above the #line directive and the #if dropped:

#include <Arduino.h>
#include <FastLED.h>
#include <Audio.h>          // <- was inside #if defined(FL_IS_TEENSY)
#include "fl/channels/config.h"
...
#line 1 "Sailboat/Sailboat.ino"

So the include is compiled unconditionally on esp32s3, where the PJRC Audio library does not exist.

Expected

Match arduino-cli / arduino-builder: leave the sketch's #include lines where they are, inside their preprocessor conditionals, and insert only #include <Arduino.h> and the generated prototypes. Prototypes go after the last include, like the fix for #1196 / #1275.

Scope

About ten FastLED examples use a platform-guarded #include in the .ino (Audio, AudioReactive, AudioUrl, BeatDetection, ElPanelReactive, Animartrix, Sailboat, AudioInput, SmartMatrix, AutoResearch). Any of them fails as the root src_dir. FastLED's own example sweep is unaffected, because it wraps the sketch in a generated main.cpp that #includes the .ino and so never goes through this conversion.

Repro

git clone https://github.com/FastLED/FastLED && cd FastLED
fbuild build     # platformio.ini: src_dir = examples/Sailboat, default_envs = esp32s3

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions