diff --git a/HISTORY.rst b/HISTORY.rst index dcfc498a..df159f44 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,11 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +6.1.17 (2024-??-??) +~~~~~~~~~~~~~~~~~~~ + +* Resolved an issue where the ``compiledb`` target failed to properly escape compiler executable paths containing spaces (`issue #4998 `_) + 6.1.16 (2024-09-26) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/main.py b/platformio/builder/main.py index ea8b202b..880ca155 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -147,13 +147,13 @@ if env.subst("$BUILD_CACHE_DIR"): if not int(ARGUMENTS.get("PIOVERBOSE", 0)): click.echo("Verbose mode can be enabled via `-v, --verbose` option") +if not os.path.isdir(env.subst("$BUILD_DIR")): + os.makedirs(env.subst("$BUILD_DIR")) + # Dynamically load dependent tools if "compiledb" in COMMAND_LINE_TARGETS: env.Tool("compilation_db") -if not os.path.isdir(env.subst("$BUILD_DIR")): - os.makedirs(env.subst("$BUILD_DIR")) - env.LoadProjectOptions() env.LoadPioPlatform() diff --git a/platformio/builder/tools/piobuild.py b/platformio/builder/tools/piobuild.py index b3d650a5..840c6f90 100644 --- a/platformio/builder/tools/piobuild.py +++ b/platformio/builder/tools/piobuild.py @@ -58,6 +58,7 @@ def GetBuildType(env): def BuildProgram(env): + env.ProcessCompileDbToolchainOption() env.ProcessProgramDeps() env.ProcessProjectDeps() @@ -90,6 +91,26 @@ def BuildProgram(env): return program +def ProcessCompileDbToolchainOption(env): + if "compiledb" not in COMMAND_LINE_TARGETS: + return + # Resolve absolute path of toolchain + for cmd in ("CC", "CXX", "AS"): + if cmd not in env: + continue + if os.path.isabs(env[cmd]) or '"' in env[cmd]: + continue + env[cmd] = where_is_program(env.subst("$%s" % cmd), env.subst("${ENV['PATH']}")) + if " " in env[cmd]: # issue #4998: Space in compilator path + env[cmd] = f'"{env[cmd]}"' + + if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"): + print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping") + for scope, includes in env.DumpIntegrationIncludes().items(): + if scope in ("toolchain",): + env.Append(CPPPATH=includes) + + def ProcessProgramDeps(env): def _append_pio_macros(): core_version = pepver_to_semver(__version__) @@ -126,27 +147,6 @@ def ProcessProgramDeps(env): # remove specified flags env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) - env.ProcessCompileDbToolchainOption() - - -def ProcessCompileDbToolchainOption(env): - 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"): - print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping") - for scope, includes in env.DumpIntegrationIncludes().items(): - if scope in ("toolchain",): - env.Append(CPPPATH=includes) - def ProcessProjectDeps(env): plb = env.ConfigureProjectLibBuilder()