Expand conditional LDF scanner include paths to use full compile-time include context#5408
Conversation
…mpile-time include context Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to fix LDF dependency resolution in deep+/chain+ modes by ensuring the conditional include scanner can see the full compile-time include context (e.g., framework headers like sdkconfig.h) so #ifdef-guarded includes are evaluated correctly.
Changes:
- Added
LibBuilderBase.get_conditional_scanner_cpppath()to mergeCPPPATHfrom the original and current build environments with library include dirs (deduped).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def get_conditional_scanner_cpppath(self): | ||
| cpppath = [] | ||
| for item in self.envorigin.get("CPPPATH", []) + self.env.get("CPPPATH", []): | ||
| if item not in cpppath: | ||
| cpppath.append(item) | ||
| for item in self.get_include_dirs(): | ||
| if item not in cpppath: | ||
| cpppath.append(item) | ||
| return cpppath |
There was a problem hiding this comment.
get_conditional_scanner_cpppath() is never called, so the conditional scanner still uses only get_include_dirs() / _INCLUDE_DIRS_CACHE (see get_implicit_includes()), and the described LDF(+)-mode failure won’t be fixed. Either wire this method into the CCONDITIONAL_SCANNER (and likely CLASSIC_SCANNER) invocation by building include_dirs from the returned CPPPATH (ensuring entries are SCons Dir nodes / normalized paths), or remove the unused helper to avoid dead code.
Summary
In
deep+/chain+-style LDF modes, dependency resolution currently fails when a macro-gating header (for examplesdkconfig.h) is not inside the limited scanner roots (src,include, framework-lib folders). The conditional scanner evaluates#ifdefblocks without seeing macro definitions from that external header, so guarded includes (likeETH.h) are skipped and the dependency graph is incomplete.Files changed
platformio/builder/tools/piolib.py(modified)Testing
Closes #4818