fix(espidf): scan transitive includes recursively for libs with src/ layout

The transitive-include scan in _merge_arduino_libs_to_component used
glob('*.h') on the component dir, which only finds headers at the root.
Libraries with a src/ layout (GxEPD2, ArduinoJson, most modern Arduino
libs) keep their headers under src/<...>, so the scan saw zero headers
and never queued their transitive deps.

Symptom: compiling a sketch that includes GxEPD2_3C.h failed with
'Adafruit_GFX.h: No such file or directory' even though Adafruit_GFX
was installed via the Library Manager — because the BFS never reached
its header from inside GxEPD2_GFX.h.

Switching to rglob('*.h') walks the full directory tree and lets the
BFS pick up Adafruit_GFX, Adafruit_BusIO, and any other transitive
dependency that lives under src/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Montero 2026-05-04 05:52:02 +02:00
parent f0577e222e
commit 38e59cb49d
1 changed files with 4 additions and 1 deletions

View File

@ -492,7 +492,10 @@ class ESPIDFCompiler:
cpp_files.append(file_key)
# Scan newly copied headers for transitive includes.
for lib_file in comp_dir.glob('*.h'):
# Use rglob so libs with `src/` layout (e.g. GxEPD2, ArduinoJson)
# are scanned recursively — otherwise their headers live under
# `src/`/subdirs and we'd miss every transitive include.
for lib_file in comp_dir.rglob('*.h'):
try:
lib_content = lib_file.read_text(encoding='utf-8', errors='ignore')
for th in self._detect_external_includes(lib_content):