Skip to content

Commit d787648

Browse files
committed
Fixed a regression issue where custom build flags were not properly reflected in the compile_commands.json // Resolve platformio#5090 Resolve platformio#5147
1 parent 846588d commit d787648

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ test-driven methodologies, and modern toolchains for unrivaled success.
2222
6.1.19 (2025-??-??)
2323
~~~~~~~~~~~~~~~~~~~
2424

25+
* Fixed a regression issue where custom build flags were not properly reflected in the `compile_commands.json <https://docs.platformio.org/en/latest/integration/compile_commands.html>`__ file, ensuring accurate compilation database generation
26+
2527
6.1.18 (2025-03-11)
2628
~~~~~~~~~~~~~~~~~~~
2729

platformio/builder/tools/piobuild.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def GetBuildType(env):
5858

5959

6060
def BuildProgram(env):
61-
env.ProcessCompileDbToolchainOption()
6261
env.ProcessProgramDeps()
62+
env.ProcessCompileDbToolchainOption()
6363
env.ProcessProjectDeps()
6464

6565
# append into the beginning a main LD script
@@ -91,26 +91,6 @@ def BuildProgram(env):
9191
return program
9292

9393

94-
def ProcessCompileDbToolchainOption(env):
95-
if "compiledb" not in COMMAND_LINE_TARGETS:
96-
return
97-
# Resolve absolute path of toolchain
98-
for cmd in ("CC", "CXX", "AS"):
99-
if cmd not in env:
100-
continue
101-
if os.path.isabs(env[cmd]) or '"' in env[cmd]:
102-
continue
103-
env[cmd] = where_is_program(env.subst("$%s" % cmd), env.subst("${ENV['PATH']}"))
104-
if " " in env[cmd]: # issue #4998: Space in compilator path
105-
env[cmd] = f'"{env[cmd]}"'
106-
107-
if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"):
108-
print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping")
109-
for scope, includes in env.DumpIntegrationIncludes().items():
110-
if scope in ("toolchain",):
111-
env.Append(CPPPATH=includes)
112-
113-
11494
def ProcessProgramDeps(env):
11595
def _append_pio_macros():
11696
core_version = pepver_to_semver(__version__)
@@ -148,6 +128,27 @@ def _append_pio_macros():
148128
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
149129

150130

131+
def ProcessCompileDbToolchainOption(env):
132+
if "compiledb" not in COMMAND_LINE_TARGETS:
133+
return
134+
135+
# Resolve absolute path of toolchain
136+
for cmd in ("CC", "CXX", "AS"):
137+
if cmd not in env:
138+
continue
139+
if os.path.isabs(env[cmd]) or '"' in env[cmd]:
140+
continue
141+
env[cmd] = where_is_program(env.subst("$%s" % cmd), env.subst("${ENV['PATH']}"))
142+
if " " in env[cmd]: # issue #4998: Space in compilator path
143+
env[cmd] = f'"{env[cmd]}"'
144+
145+
if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"):
146+
print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping")
147+
for scope, includes in env.DumpIntegrationIncludes().items():
148+
if scope in ("toolchain",):
149+
env.Append(CPPPATH=includes)
150+
151+
151152
def ProcessProjectDeps(env):
152153
plb = env.ConfigureProjectLibBuilder()
153154

0 commit comments

Comments
 (0)