Skip to content

Add pio run -t compiledbtc option #4937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion platformio/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
click.echo("Verbose mode can be enabled via `-v, --verbose` option")

# Dynamically load dependent tools
if "compiledb" in COMMAND_LINE_TARGETS:
if "compiledb" or "compiledbtc" in COMMAND_LINE_TARGETS:
env.Tool("compilation_db")

if not os.path.isdir(env.subst("$BUILD_DIR")):
Expand Down Expand Up @@ -195,6 +195,9 @@
if "compiledb" in COMMAND_LINE_TARGETS:
env.Alias("compiledb", env.CompilationDatabase("$COMPILATIONDB_PATH"))

if "compiledbtc" in COMMAND_LINE_TARGETS:
env.Alias("compiledbtc", env.CompilationDatabase("$COMPILATIONDB_PATH"))

# Print configured protocols
env.AddPreAction(
"upload",
Expand Down
43 changes: 29 additions & 14 deletions platformio/builder/tools/piobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,39 @@ def _append_pio_macros():
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))

env.ProcessCompileDbToolchainOption()
env.ProcessCompileDbIncludeToolchainOption()


def ProccessCompileDb(env, include_toolchain=False):
# 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 include_toolchain:
for scope, includes in env.DumpIntegrationIncludes().items():
if scope in ("toolchain",):
env.Append(CPPPATH=includes)


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']}")
)
ProccessCompileDb(env)

if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"):
print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping")
print("Use 'pio run -t compiledbtc' instead.")
ProccessCompileDb(env, include_toolchain=True)


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 ProcessCompileDbIncludeToolchainOption(env):
if "compiledbtc" in COMMAND_LINE_TARGETS:
ProccessCompileDb(env, include_toolchain=True)


def ProcessProjectDeps(env):
Expand Down Expand Up @@ -382,6 +396,7 @@ def generate(env):
env.AddMethod(BuildProgram)
env.AddMethod(ProcessProgramDeps)
env.AddMethod(ProcessCompileDbToolchainOption)
env.AddMethod(ProcessCompileDbIncludeToolchainOption)
env.AddMethod(ProcessProjectDeps)
env.AddMethod(ParseFlagsExtended)
env.AddMethod(ProcessFlags)
Expand Down
1 change: 1 addition & 0 deletions platformio/builder/tools/piolib.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ def build(self):

self.env.PrependUnique(CPPPATH=self.get_include_dirs())
self.env.ProcessCompileDbToolchainOption()
self.env.ProcessCompileDbIncludeToolchainOption()

if self.lib_ldf_mode == "off":
for lb in self.env.GetLibBuilders():
Expand Down
2 changes: 1 addition & 1 deletion platformio/builder/tools/piomaxlen.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _file_long_data(env, data):


def exists(env):
return "compiledb" not in COMMAND_LINE_TARGETS and not env.IsIntegrationDump()
return "compiledb" and "compiledbtc" not in COMMAND_LINE_TARGETS and not env.IsIntegrationDump()


def generate(env):
Expand Down