Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/per_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ def _run_code_checker(
analyzer_executables = "clangsa:" + info.clangsa.path + \
";clang-tidy:" + info.clang_tidy.path

# Convert the list of "NAME=value" strings into a dict.
# Entries without "=" are ignored.
env = {}
for entry in env_vars:
name, sep, value = entry.partition("=")
if sep:
env[name] = value

# Action to run CodeChecker for a file
# env_vars are unused for now, since
# use_default_shell_env and env are incompatible
# TODO: use env for environment variables, instead of passing it as argument
ctx.actions.run(
inputs = inputs,
outputs = outputs,
Expand Down Expand Up @@ -135,6 +140,7 @@ def _run_code_checker(
analyzer_executables,
],
mnemonic = "CodeChecker",
env = env,
progress_message = "CodeChecker analyze {}".format(src.short_path),
)
return outputs
Expand Down
5 changes: 4 additions & 1 deletion src/per_file_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ def _run_codechecker(cfg: Config) -> None:
+ ["--config", cfg.config_file]
+ [absolute_path]
)
log(cfg, f"CodeChecker command: {' '.join(codechecker_cmd)}\n")

cc_env = _get_codechecker_env(cfg)
env_prefix = " ".join(f"{key}={cc_env[key]}" for key in sorted(cc_env))
log(cfg, f"CodeChecker command: {env_prefix} {' '.join(codechecker_cmd)}\n")
log(cfg, "===---------------------------------------------===\n")
log(cfg, " CodeChecker error log \n")
log(cfg, "===---------------------------------------------===\n")
Expand Down
23 changes: 23 additions & 0 deletions test/unit/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ unit_test(
files = "test/unit/config/codechecker_env/codechecker.log",
)

codechecker_test(
name = "per_file_env",
config = "config_env",
per_file = True,
tags = ["manual"],
targets = [
"test_zero",
],
)

unit_test(
name = "per_file_env_test",
contains = [
"CC_TEST_VAR=42",
"CC_TEST_PATH=/tmp/first:/tmp/second",
"CC_TEST_FLAGS=-DFIRST=1 -DSECOND=2",
"CC_TEST_PAIRS=VAR1=1; VAR2=2",
"CC_TEST_LIST=1; 2; 3;",
],
data = [":per_file_env"],
files = "test/unit/config/per_file_env/data/test-unit-config-zero_div.cc_codechecker.log",
)

# None of these codechecker rules should find any issues
codechecker(
name = "codechecker_json",
Expand Down
Loading