From 38e59cb49d39c755f112d3ca4e443fabd3b45479 Mon Sep 17 00:00:00 2001 From: David Montero Date: Mon, 4 May 2026 05:52:02 +0200 Subject: [PATCH] fix(espidf): scan transitive includes recursively for libs with src/ layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- backend/app/services/espidf_compiler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app/services/espidf_compiler.py b/backend/app/services/espidf_compiler.py index 1e42a5d4..b17e4e9f 100644 --- a/backend/app/services/espidf_compiler.py +++ b/backend/app/services/espidf_compiler.py @@ -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):