Fixed a regression issue where custom build flags were not properly reflected in the compile_commands.json // Resolve #5090 Resolve #5147

This commit is contained in:
Ivan Kravets
2025-05-07 19:45:16 +03:00
parent 846588deec
commit d787648e71
2 changed files with 24 additions and 21 deletions

View File

@ -22,6 +22,8 @@ test-driven methodologies, and modern toolchains for unrivaled success.
6.1.19 (2025-??-??)
~~~~~~~~~~~~~~~~~~~
* 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
6.1.18 (2025-03-11)
~~~~~~~~~~~~~~~~~~~

View File

@ -58,8 +58,8 @@ def GetBuildType(env):
def BuildProgram(env):
env.ProcessCompileDbToolchainOption()
env.ProcessProgramDeps()
env.ProcessCompileDbToolchainOption()
env.ProcessProjectDeps()
# append into the beginning a main LD script
@ -91,26 +91,6 @@ 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__)
@ -148,6 +128,27 @@ def ProcessProgramDeps(env):
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
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 ProcessProjectDeps(env):
plb = env.ConfigureProjectLibBuilder()