Skip to content

Expand conditional LDF scanner include paths to use full compile-time include context#5408

Open
huyhoang171106 wants to merge 1 commit intoplatformio:developfrom
huyhoang171106:fix/expand-conditional-ldf-scanner-include-p
Open

Expand conditional LDF scanner include paths to use full compile-time include context#5408
huyhoang171106 wants to merge 1 commit intoplatformio:developfrom
huyhoang171106:fix/expand-conditional-ldf-scanner-include-p

Conversation

@huyhoang171106
Copy link
Copy Markdown

Summary

In deep+/chain+-style LDF modes, dependency resolution currently fails when a macro-gating header (for example sdkconfig.h) is not inside the limited scanner roots (src, include, framework-lib folders). The conditional scanner evaluates #ifdef blocks without seeing macro definitions from that external header, so guarded includes (like ETH.h) are skipped and the dependency graph is incomplete.

Files changed

  • platformio/builder/tools/piolib.py (modified)

Testing

  • Not run in this environment.

Closes #4818

…mpile-time include context

Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 26, 2026 15:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 merge CPPPATH from 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.

Comment on lines +123 to +131
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
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

LDF doesn't resolve dependencies in (+) modes if an intermediate header file is located outside lib folders

2 participants