Ldf not following environment variables in 6.1.0rc1

Hi

In our ventilator project, we use a hack to compile different programs on the same environment (our integration testing environment) by using an environment variable to define the path to a h file, and use it as such in main.cpp: #include INTEGRATION_TEST_H

The h file to which INTEGRATION_TEST_H leads most of the times includes headers from libraries, and when trying this with development version (6.1.0rc1), it appears ldf cannot find those libraries.

I have a workaround which is to include one header file from each of our libraries in main.cpp, but this seems hard to maintain.

I’ll build an example for this soon if needed.

Then there might a regression in the LDF in regards to this (rather complex) substitution of macros and discovery of libraries. Can you file an issue at Issues · platformio/platformio-core · GitHub pointing at the source code, or better a minimal reproduction of the problem?

This is correct behavior. We don’t parse anymore ALL includes from the projects if they were not included in the project. The PIO Core <6.1 parsed all files and we had very often issues when PIO included libraries to the compilation projects from the headers that WERE NOT USED in the project but were located in the “include” folder.

In your case, the default chain mode does not expose any C Preprocessor macros. Could you try switching to the lib_ldf_mode=chain+ ?

I just tested with chain+, it seems to work fine for some of our use cases, but we are using deep+, which is necessary for others, and seem not to evaluate #include INTEGRATION_TEST_H properly as of this writing.

This is a bug of SCons. I’ve just made PR:

Also, we published a patched package to the registry:

Could re-run pio upgrade --dev. It should pull the new SCons tool. Does it work now?

P.S: The code which I tested:

some.h

#include <unity.h>
#include INTEGRATION_TEST_H

platformio.ini

[env]
lib_ldf_mode = chain+
build_flags =
	'-DINTEGRATION_TEST_H=\<my.h\>'
[env]
lib_ldf_mode = deep+
build_flags =
	'-DINTEGRATION_TEST_H=\"my.h\"'

or

extra_script.py

env.Append(CPPDEFINES=[("INTEGRATION_TEST_H", '\\"my.h\\"')])

Working like a charm, thank you for the quick solution!

1 Like

PlatformIO Core 6.1 is out! Please upgrade to the stable version.

1 Like