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
9 changes: 8 additions & 1 deletion src/code_checker.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def _run_code_checker(
clangsa_plist = ctx.actions.declare_file(clangsa_plist_file_name)
codechecker_log = ctx.actions.declare_file(codechecker_log_file_name)

inputs = [compile_commands_json] + sources_and_headers
if "--ctu" in options:
inputs = [compile_commands_json] + sources_and_headers
else:
# NOTE: we collect only headers, so CTU may not work!
headers = depset([src], transitive = [compilation_context.headers])
inputs = depset([compile_commands_json, src], transitive = [headers])

outputs = [clang_tidy_plist, clangsa_plist, codechecker_log]

# Create CodeChecker wrapper script
Expand Down Expand Up @@ -274,6 +280,7 @@ def _compile_commands_impl(ctx):
return compile_commands_json

def _collect_all_sources_and_headers(ctx):
# NOTE: we are only using this function for CTU
all_files = []
headers = depset()
for target in ctx.attr.targets:
Expand Down
4 changes: 1 addition & 3 deletions test/unit/caching/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ def test_bazel_test_code_checker_caching(self):
self.fail(f"File not found!")
ret, _, stderr = self.run_command(f"bazel build {target} --subcommands")
self.assertEqual(ret, 0)
# FIXME: This should be 1; 2 means that both .cpp files were reanalyzed
# despite only one of them being changed.
self.assertEqual(
stderr.count(f"SUBCOMMAND: # {target} [action 'CodeChecker"), 2
stderr.count(f"SUBCOMMAND: # {target} [action 'CodeChecker"), 1
)

def test_bazel_test_code_checker_ctu_caching(self):
Expand Down