platformio / platformio/platformio-core

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

Open
#4,818 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug LDF
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

Description of problem

LDF (in any mode that evaluates C/C++ Preprocessor conditional syntax) is not able to find a dependency when a header from that dependency is hidden under an ifdef guard and the macro that enables the include header file is located outside search paths (framework libraries, include and src folders) passed to CCONDITIONAL_SCANNER,

For example the CONFIG_ETH_ENABLED macro in the code below is set in the sdkconfig.h file which is located in the framework folder $PIO_PACKAGES/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include.

Steps to Reproduce

Compile the following code:

#include <Arduino.h>
#include <sdkconfig.h>

#ifdef CONFIG_ETH_ENABLED
#include "ETH.h"
#endif

void setup() {}

void loop() {}

with the following configuration:

[env:esp32dev]
platform = espressif32
framework = arduino
board = esp32dev
lib_ldf_mode = deep+
Actual Results
Scanning dependencies...
No dependencies
Compiling .pio\build\esp32dev\src\main.cpp.o
src/main.cpp:25:10: fatal error: ETH.h: No such file or directory
Expected Results
Scanning dependencies...
Dependency Graph
|-- Ethernet @ 2.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided ESP32 Arduino configuration and lib_ldf_mode = deep+. Start by tracing the LDF conditional scanner and CCONDITIONAL_SCANNER search paths while examining the sdkconfig.h and ETH.h include flow. Done means the dependency graph reports Ethernet @ 2.0.0 and compilation no longer fails to find ETH.h.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.