Skip to content

fix(library-select): honor Arduino library spec for 1.0 flat layout; release v2.2.6#268

Merged
zackees merged 1 commit into
mainfrom
fix/267-arduino-lib-spec
May 23, 2026
Merged

fix(library-select): honor Arduino library spec for 1.0 flat layout; release v2.2.6#268
zackees merged 1 commit into
mainfrom
fix/267-arduino-lib-spec

Conversation

@zackees
Copy link
Copy Markdown
Member

@zackees zackees commented May 23, 2026

Closes #267 (Fix 2 — scanner correctness). Cuts release v2.2.6.

The bug

fbuild 2.2.5 fails to build any sketch for teensy41:

fatal error: ft2build.h: No such file or directory
   23 | #include <ft2build.h>
compilation terminated.

The offending file is framework-arduinoteensy/libraries/ssd1351/fontconvert/fontconvert.c — a host-only desktop tool that links -lfreetype. ssd1351 ships it as a font preprocessor; it was never meant to be ARM-cross-compiled.

Root cause

collect_library_sources in framework_library.rs walked the entire library directory recursively for 1.0 flat-layout libraries (no src/), violating the Arduino library spec:

  • 1.5 recursive layout (has src/): scan src/** only.
  • 1.0 flat layout (no src/): scan root non-recursively plus literal utility/.

Subdirectories like fontconvert/, util/, Fonts/, examples/, extras/ must be ignored. The ssd1351 author parked fontconvert.c in fontconvert/ (not utility/) precisely so Arduino IDE and PlatformIO would skip it. fbuild's recursive walk swept it in.

Fix

Rewrite collect_library_sources to dispatch on layout — 1.5 stays recursive into src/; 1.0 is non-recursive at root plus a single recurse into utility/. Matches arduino-cli exactly.

Regression tests

  • collect_library_sources_flat_layout_arduino_spec — ssd1351 fixture. Asserts root + utility/ only; fontconvert/ + util/ + Fonts/ + examples/ are all dropped.
  • collect_library_sources_recursive_layout_arduino_specsrc/ fixture. Asserts only src/**; root-level baz.cpp dropped.

Release v2.2.6

Cargo + pyproject bumped to 2.2.6. On merge, release-auto.yml triggers (path filter matches Cargo.toml + pyproject.toml).

Deferred (separate work)

Fix 1 from #267 — investigate why ssd1351 is reaching the compile set at all when Blink doesn't #include <ssd1351.h>. With Fix 2 in place, even if ssd1351 IS selected, only ssd1351.cpp at the root would be compiled (which cross-compiles fine for ARM). The user-reported build failure is resolved by Fix 2 alone.

Test plan

  • soldr cargo check --workspace --all-targets — clean
  • soldr cargo clippy --workspace --all-targets -- -D warnings — clean
  • soldr cargo fmt --all -- --check — clean
  • soldr cargo test --workspace — all green; new framework_library tests pass
  • CI passes
  • release-auto.yml ships v2.2.6 to PyPI + GitHub
  • FastLED's bash compile teensy41 succeeds on v2.2.6

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Version updated to 2.2.6
  • Bug Fixes

    • Improved library source collection handling. Libraries with src/ directories now recursively scan only that directory, while libraries without src/ scan the root non-recursively plus the utility/ subdirectory. Other subdirectories are now properly excluded.

Review Change Stack

…release v2.2.6

Closes #267 (Fix 2 — the scanner correctness fix).

## The bug

`fbuild 2.2.5` fails to build any sketch for `teensy41`:

    fatal error: ft2build.h: No such file or directory
       23 | #include <ft2build.h>
    compilation terminated.

The offending file is `framework-arduinoteensy/libraries/ssd1351/fontconvert/fontconvert.c`
— a *host-only* desktop tool that links `-lfreetype`. ssd1351 ships it
as a font preprocessor; it was never intended to be ARM-cross-compiled.

## Root cause

`collect_library_sources` in `framework_library.rs` walked the entire
library directory recursively for 1.0 flat-layout libraries (no `src/`),
violating the Arduino library specification. The spec says:

- **1.5 recursive layout** (has `src/`): scan `src/**` only.
- **1.0 flat layout** (no `src/`): scan root *non-recursively* plus
  the literal `utility/` subdirectory.

Subdirectories like `fontconvert/`, `util/`, `Fonts/`, `examples/`,
and `extras/` must be ignored. The ssd1351 author parked `fontconvert.c`
in `fontconvert/` (not `utility/`) precisely so Arduino IDE / PlatformIO
would skip it. fbuild's recursive walk swept it in.

## The fix

Rewrite `collect_library_sources` to dispatch on layout:
- 1.5 (has `src/`): recurse into `src/` only — already correct.
- 1.0 (no `src/`): `collect_root_level_sources` (non-recursive) +
  recurse into `utility/` only.

This matches `arduino-cli` exactly and protects fbuild from any
well-formed library shipping companion tooling in a non-`utility/`
subdirectory.

## Tests

- `collect_library_sources_flat_layout_arduino_spec` — fixture mimics
  ssd1351 (root .cpp + utility/ + fontconvert/ + util/ + Fonts/ +
  examples/). Asserts only root + utility/ are returned; fontconvert/
  (with the `#include <ft2build.h>` that breaks the build), util/,
  Fonts/, and examples/ are dropped.
- `collect_library_sources_recursive_layout_arduino_spec` — fixture
  with `src/SPI.cpp`, `src/sub/bar.cpp`, root-level `baz.cpp`,
  and `examples/`. Asserts only `src/**` is returned; root `baz.cpp`
  and examples/ are dropped.

Full workspace cargo check / clippy / fmt / test all green.

## Release v2.2.6

Patch release rolling up the #267 scanner-correctness fix. Both teensy41
regressions from earlier today (#261 LTO tmpdir, #263 bundled FastLED
dup) carry over from v2.2.5.

Cargo.toml + pyproject.toml bumped to 2.2.6.

## Deferred (out of scope for this PR)

Fix 1 from #267 — investigate why ssd1351 is reaching the compile set
at all when Blink doesn't `#include <ssd1351.h>` — is a separate
LDF-leak investigation. With Fix 2 in place, even if ssd1351 IS
selected, only `ssd1351.cpp` at the root would be compiled (which
should cross-compile fine for ARM). The user-reported build failure
is resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

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: 46c0d0c9-ad44-40c7-89d2-ef7360ff10a7

📥 Commits

Reviewing files that changed from the base of the PR and between 48bf377 and fc2d61c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml
  • crates/fbuild-packages/src/library/framework_library.rs
  • pyproject.toml

📝 Walkthrough

Walkthrough

This PR fixes Arduino library specification compliance in source discovery. The library scanner now correctly dispatches on layout type: 1.5 layouts with src/ directories scan only src/** recursively, while 1.0 flat layouts scan the root non-recursively and utility/ recursively, ignoring other subdirectories. Workspace and project versions are bumped to 2.2.6.

Changes

Arduino Library Specification Compliance

Layer / File(s) Summary
Arduino spec-compliant library source collection
crates/fbuild-packages/src/library/framework_library.rs
Entry point collect_library_sources dispatches on layout type: recursive src/** scan for 1.5 layouts (when src/ exists), or non-recursive root scan plus recursive utility/-only scan for 1.0 flat layouts. Refactored with collect_root_level_sources helper and is_buildable_source filter (c/cpp/cc/cxx/s extensions). Recursive walker defensively skips examples/, tests/, extras/. Prior test replaced with new regression tests for both layouts.
Workspace and project version synchronization
Cargo.toml, pyproject.toml
Version bumped from 2.2.5 to 2.2.6 in both Rust workspace and Python project configuration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • FastLED/fbuild#203: Modifies Arduino framework library source discovery in the same crates/fbuild-packages/src/library/framework_library.rs file, with this PR refining scan rules for src/ vs flat layouts that directly affect the resolver introduced in #203.

Poem

🐰 Hop along, dear builders true,
Now our specs are tried and true!
Flat or nested, src or root,
Arduino knows the scanner's route.
No fontconvert in the compile set—
fbuild 2.2.6 won't forget! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 changes: fixing Arduino library spec compliance for flat-layout libraries and releasing v2.2.6.
Linked Issues check ✅ Passed The PR successfully implements Fix 2 from issue #267 with comprehensive changes to honor Arduino library spec, including flat-layout and recursive-layout source collection and regression tests.
Out of Scope Changes check ✅ Passed All changes are in scope: version bumps in Cargo.toml and pyproject.toml align with the v2.2.6 release, and the library scanner refactoring directly addresses the Arduino spec violation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 fix/267-arduino-lib-spec

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 merged commit 0bdba41 into main May 23, 2026
82 checks passed
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.

fix(library-select): teensy41 — ssd1351/fontconvert/fontconvert.c host tool compiled (ft2build.h missing)

1 participant