diff --git a/HISTORY.rst b/HISTORY.rst index 2aa67744..8ec95eb4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,12 @@ PlatformIO Core 6 **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** +6.1.9 (2023-07-06) +~~~~~~~~~~~~~~~~~~ + +* Rectified a regression bug that occurred when the ``-include`` flag was passed via the `build_flags `__ option as a relative path and subsequently expanded (`issue #4683 `_) +* Resolved an issue that resulted in unresolved absolute toolchain paths when generating the `Compilation database "compile_commands.json" `__ (`issue #4684 `_) + 6.1.8 (2023-07-05) ~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index 3f462c9a..f8dbf012 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 3f462c9ae63623710d48c85e16241bbb0a2b6553 +Subproject commit f8dbf012e4a7ddbe79279540e95c08a2d108c725 diff --git a/platformio/__init__.py b/platformio/__init__.py index 75b51791..c720d005 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, 8) +VERSION = (6, 1, 9) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 3aa460cd..2ca41f38 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -30,7 +30,7 @@ from SCons.Script import Variables # pylint: disable=import-error from platformio import app, fs from platformio.platform.base import PlatformBase -from platformio.proc import get_pythonexe_path, where_is_program +from platformio.proc import get_pythonexe_path from platformio.project.helpers import get_project_dir AllowSubstExceptions(NameError) @@ -195,13 +195,6 @@ if env.get("SIZETOOL") and not ( Default("checkprogsize") if "compiledb" in COMMAND_LINE_TARGETS: - # Resolve absolute path of toolchain - for cmd in ("CC", "CXX", "AS"): - if cmd not in env: - continue - if os.path.isabs(env[cmd]): - continue - env[cmd] = where_is_program(env.subst("$%s" % cmd), env.subst("${ENV['PATH']}")) env.Alias("compiledb", env.CompilationDatabase("$COMPILATIONDB_PATH")) # Print configured protocols diff --git a/platformio/builder/tools/piobuild.py b/platformio/builder/tools/piobuild.py index 1646dc95..74725a02 100644 --- a/platformio/builder/tools/piobuild.py +++ b/platformio/builder/tools/piobuild.py @@ -26,6 +26,7 @@ from SCons.Script import SConscript # pylint: disable=import-error from platformio import __version__, fs from platformio.compat import IS_MACOS, string_types from platformio.package.version import pepver_to_semver +from platformio.proc import where_is_program SRC_HEADER_EXT = ["h", "hpp"] SRC_ASM_EXT = ["S", "spp", "SPP", "sx", "s", "asm", "ASM"] @@ -125,12 +126,21 @@ def ProcessProgramDeps(env): # remove specified flags env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) - if "compiledb" in COMMAND_LINE_TARGETS and env.get( - "COMPILATIONDB_INCLUDE_TOOLCHAIN" - ): - for scope, includes in env.DumpIntegrationIncludes().items(): - if scope in ("toolchain",): - env.Append(CPPPATH=includes) + if "compiledb" in COMMAND_LINE_TARGETS: + # Resolve absolute path of toolchain + for cmd in ("CC", "CXX", "AS"): + if cmd not in env: + continue + if os.path.isabs(env[cmd]): + continue + env[cmd] = where_is_program( + env.subst("$%s" % cmd), env.subst("${ENV['PATH']}") + ) + + if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"): + for scope, includes in env.DumpIntegrationIncludes().items(): + if scope in ("toolchain",): + env.Append(CPPPATH=includes) def ProcessProjectDeps(env): @@ -207,9 +217,7 @@ def ParseFlagsExtended(env, flags): # pylint: disable=too-many-branches # fix relative path for "-include" for i, f in enumerate(result.get("CCFLAGS", [])): if isinstance(f, tuple) and f[0] == "-include": - p = env.subst(f[1].get_path()) - if os.path.exists(p): - result["CCFLAGS"][i] = (f[0], os.path.abspath(p)) + result["CCFLAGS"][i] = (f[0], env.subst(f[1].get_path())) return result diff --git a/tests/commands/test_run.py b/tests/commands/test_run.py index de13a5a8..820de44f 100644 --- a/tests/commands/test_run.py +++ b/tests/commands/test_run.py @@ -22,7 +22,10 @@ def test_generic_build(clirunner, validate_cliresult, tmpdir): ("-D TEST_INT=13", "-DTEST_INT=13"), ("-DTEST_SINGLE_MACRO", "-DTEST_SINGLE_MACRO"), ('-DTEST_STR_SPACE="Andrew Smith"', '"-DTEST_STR_SPACE=Andrew Smith"'), + ("-Iinclude", "-Iinclude"), + ("-include cpppath-include.h", "cpppath-include.h"), ("-Iextra_inc", "-Iextra_inc"), + ("-Inon-existing-dir", "non-existing-dir"), ( "-include $PROJECT_DIR/lib/component/component-forced-include.h", "component-forced-include.h", @@ -103,12 +106,22 @@ projenv.Append(CPPDEFINES="POST_SCRIPT_MACRO") #error "I_AM_FORCED_COMPONENT_INCLUDE" #endif +#ifndef I_AM_FORCED_CPPPATH_INCLUDE +#error "I_AM_FORCED_CPPPATH_INCLUDE" +#endif + #ifdef COMMENTED_MACRO #error "COMMENTED_MACRO" #endif int main() { } +""" + ) + + tmpdir.mkdir("include").join("cpppath-include.h").write( + """ +#define I_AM_FORCED_CPPPATH_INCLUDE """ ) component_dir = tmpdir.mkdir("lib").mkdir("component")