Skip to content

Commit 837ea85

Browse files
committed
Resolved an issue that resulted in unresolved absolute toolchain paths when generating the "compile_commands.json" // Resolve platformio#4684
1 parent 9585e2a commit 837ea85

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PlatformIO Core 6
1919
~~~~~~~~~~~~~~~~~~
2020

2121
* Rectified a regression bug that occurred when the ``-include`` flag was passed via the `build_flags <https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html>`__ option as a relative path and subsequently expanded (`issue #4683 <https://github.com/platformio/platformio-core/issues/4683>`_)
22+
* Resolved an issue that resulted in unresolved absolute toolchain paths when generating the `Compilation database "compile_commands.json" <https://docs.platformio.org/en/latest/integration/compile_commands.html>`__ (`issue #4684 <https://github.com/platformio/platformio-core/issues/4684>`_)
2223

2324
6.1.8 (2023-07-05)
2425
~~~~~~~~~~~~~~~~~~

docs

platformio/builder/main.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from platformio import app, fs
3232
from platformio.platform.base import PlatformBase
33-
from platformio.proc import get_pythonexe_path, where_is_program
33+
from platformio.proc import get_pythonexe_path
3434
from platformio.project.helpers import get_project_dir
3535

3636
AllowSubstExceptions(NameError)
@@ -195,13 +195,6 @@
195195
Default("checkprogsize")
196196

197197
if "compiledb" in COMMAND_LINE_TARGETS:
198-
# Resolve absolute path of toolchain
199-
for cmd in ("CC", "CXX", "AS"):
200-
if cmd not in env:
201-
continue
202-
if os.path.isabs(env[cmd]):
203-
continue
204-
env[cmd] = where_is_program(env.subst("$%s" % cmd), env.subst("${ENV['PATH']}"))
205198
env.Alias("compiledb", env.CompilationDatabase("$COMPILATIONDB_PATH"))
206199

207200
# Print configured protocols

platformio/builder/tools/piobuild.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from platformio import __version__, fs
2727
from platformio.compat import IS_MACOS, string_types
2828
from platformio.package.version import pepver_to_semver
29+
from platformio.proc import where_is_program
2930

3031
SRC_HEADER_EXT = ["h", "hpp"]
3132
SRC_ASM_EXT = ["S", "spp", "SPP", "sx", "s", "asm", "ASM"]
@@ -125,12 +126,21 @@ def _append_pio_macros():
125126
# remove specified flags
126127
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
127128

128-
if "compiledb" in COMMAND_LINE_TARGETS and env.get(
129-
"COMPILATIONDB_INCLUDE_TOOLCHAIN"
130-
):
131-
for scope, includes in env.DumpIntegrationIncludes().items():
132-
if scope in ("toolchain",):
133-
env.Append(CPPPATH=includes)
129+
if "compiledb" in COMMAND_LINE_TARGETS:
130+
# Resolve absolute path of toolchain
131+
for cmd in ("CC", "CXX", "AS"):
132+
if cmd not in env:
133+
continue
134+
if os.path.isabs(env[cmd]):
135+
continue
136+
env[cmd] = where_is_program(
137+
env.subst("$%s" % cmd), env.subst("${ENV['PATH']}")
138+
)
139+
140+
if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"):
141+
for scope, includes in env.DumpIntegrationIncludes().items():
142+
if scope in ("toolchain",):
143+
env.Append(CPPPATH=includes)
134144

135145

136146
def ProcessProjectDeps(env):

0 commit comments

Comments
 (0)