Skip to content

Commit fd35a77

Browse files
committed
Remove individual metadata files from defaultinfo
We absolutely do not need the individual metadata files in the data folder, the merged one is enough
1 parent 02395f9 commit fd35a77

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/per_file.bzl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def _run_code_checker(
9191
clang_tidy_plist,
9292
clangsa_plist,
9393
codechecker_log,
94-
codechecker_metadata,
9594
]
9695

9796
analyzer_output_paths = "clangsa," + clangsa_plist.path + \
@@ -103,7 +102,9 @@ def _run_code_checker(
103102
# Action to run CodeChecker for a file
104103
ctx.actions.run(
105104
inputs = inputs,
106-
outputs = outputs,
105+
# We do not want all individual metadata files
106+
# cluttering the data folder
107+
outputs = outputs + [codechecker_metadata],
107108
executable = ctx.outputs.per_file_script,
108109
arguments = [
109110
info.codechecker.path,
@@ -119,7 +120,7 @@ def _run_code_checker(
119120
use_default_shell_env = True,
120121
progress_message = "CodeChecker analyze {}".format(src.short_path),
121122
)
122-
return outputs
123+
return outputs, codechecker_metadata
123124

124125
def check_valid_file_type(src):
125126
"""
@@ -177,13 +178,12 @@ def _create_wrapper_script(ctx, options, compile_commands_json, config_file):
177178
},
178179
)
179180

180-
def _merge_metadata(ctx, all_files):
181+
def _merge_metadata(ctx, metadata):
181182
"""
182183
Merges metadata files of individual CodeChecker runs into 1
183184
184185
Returns the metadata file objects
185186
"""
186-
metadata = [file for file in all_files if file.path.endswith("metadata.json")]
187187
metadata_json = ctx.actions.declare_file(ctx.attr.name + "/data/metadata.json")
188188
ctx.actions.run(
189189
inputs = metadata,
@@ -207,6 +207,7 @@ def _per_file_impl(ctx):
207207
sources_and_headers = _collect_all_sources_and_headers(ctx)
208208
options = ctx.attr.default_options + ctx.attr.options
209209
all_files = [compile_commands]
210+
all_metadata = []
210211
config_file, env_vars = get_config_file(ctx)
211212
_create_wrapper_script(ctx, options, compile_commands, config_file)
212213
for target in ctx.attr.targets:
@@ -221,7 +222,7 @@ def _per_file_impl(ctx):
221222
if not check_valid_file_type(src):
222223
continue
223224
args = target[SourceFilesInfo].compilation_db.to_list()
224-
outputs = _run_code_checker(
225+
outputs, metadata = _run_code_checker(
225226
ctx,
226227
src,
227228
args,
@@ -235,7 +236,8 @@ def _per_file_impl(ctx):
235236
sources_and_headers,
236237
)
237238
all_files += outputs
238-
all_files.append(_merge_metadata(ctx, all_files))
239+
all_metadata.append(metadata)
240+
all_files.append(_merge_metadata(ctx, all_metadata))
239241
ctx.actions.write(
240242
output = ctx.outputs.test_script,
241243
is_executable = True,

0 commit comments

Comments
 (0)