Resolved a critical issue related to the usage of the `-include` flag // Resolve #4682

This commit is contained in:
Ivan Kravets
2023-07-03 18:37:57 +03:00
parent 0ff46bdd88
commit 01ab1fa4c0
4 changed files with 19 additions and 2 deletions

View File

@ -25,6 +25,7 @@ PlatformIO Core 6
* Refactored |UNITTESTING| engine to resolve compiler warnings with "-Wpedantic" option (`pull #4671 <https://github.com/platformio/platformio-core/pull/4671>`_)
* Eliminated erroneous warning regarding the use of obsolete PlatformIO Core when downgrading to the stable version (`issue #4664 <https://github.com/platformio/platformio-core/issues/4664>`_)
* Updated the `pio project metadata <https://docs.platformio.org/en/latest/core/userguide/project/cmd_metadata.html>`__ command to return C/C++ flags as parsed Unix shell arguments when dumping project build metadata
* Resolved a critical issue related to the usage of the ``-include`` flag within the `build_flags <https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html>`__ option, specifically when employing dynamic variables (`issue #4682 <https://github.com/platformio/platformio-core/issues/4682>`_)
* Removed PlatformIO IDE for Atom from the documentation as `Atom has been deprecated <https://github.blog/2022-06-08-sunsetting-atom/>`__
6.1.7 (2023-05-08)

2
docs

Submodule docs updated: 50bbe8ac61...daa389f68b

View File

@ -200,13 +200,16 @@ def ParseFlagsExtended(env, flags): # pylint: disable=too-many-branches
# fix relative CPPPATH & LIBPATH
for k in ("CPPPATH", "LIBPATH"):
for i, p in enumerate(result.get(k, [])):
p = env.subst(p)
if os.path.isdir(p):
result[k][i] = os.path.abspath(p)
# fix relative path for "-include"
for i, f in enumerate(result.get("CCFLAGS", [])):
if isinstance(f, tuple) and f[0] == "-include":
result["CCFLAGS"][i] = (f[0], env.File(os.path.abspath(f[1].get_path())))
p = env.subst(f[1].get_path())
if os.path.exists(p):
result["CCFLAGS"][i] = (f[0], os.path.abspath(p))
return result

View File

@ -23,6 +23,10 @@ def test_generic_build(clirunner, validate_cliresult, tmpdir):
("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"),
('-DTEST_STR_SPACE="Andrew Smith"', '"-DTEST_STR_SPACE=Andrew Smith"'),
("-Iextra_inc", "-Iextra_inc"),
(
"-include $PROJECT_DIR/lib/component/component-forced-include.h",
"component-forced-include.h",
),
]
tmpdir.join("platformio.ini").write(
@ -95,6 +99,10 @@ projenv.Append(CPPDEFINES="POST_SCRIPT_MACRO")
#error "POST_SCRIPT_MACRO"
#endif
#ifndef I_AM_FORCED_COMPONENT_INCLUDE
#error "I_AM_FORCED_COMPONENT_INCLUDE"
#endif
#ifdef COMMENTED_MACRO
#error "COMMENTED_MACRO"
#endif
@ -124,6 +132,11 @@ void dummy(void);
void dummy(void ) {};
"""
)
component_dir.join("component-forced-include.h").write(
"""
#define I_AM_FORCED_COMPONENT_INCLUDE
"""
)
result = clirunner.invoke(cmd_run, ["--project-dir", str(tmpdir), "--verbose"])
validate_cliresult(result)