Skip to content
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

Add argument include_coverage to toggle if InstrumentedFilesInfo is created #2457

Merged
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
20 changes: 15 additions & 5 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,8 @@ def rustc_compile_action(
output_hash = None,
force_all_deps_direct = False,
crate_info_dict = None,
skip_expanding_rustc_env = False):
skip_expanding_rustc_env = False,
include_coverage = True):
"""Create and run a rustc compile action based on the current rule's attributes

Args:
Expand All @@ -1124,6 +1125,7 @@ def rustc_compile_action(
to the commandline as opposed to -L.
crate_info_dict: A mutable dict used to create CrateInfo provider
skip_expanding_rustc_env (bool, optional): Whether to expand CrateInfo.rustc_env
include_coverage (bool, optional): Whether to generate coverage information or not.

Returns:
list: A list of the following providers:
Expand Down Expand Up @@ -1456,12 +1458,20 @@ def rustc_compile_action(
runfiles = runfiles,
executable = executable,
),
coverage_common.instrumented_files_info(
ctx,
**instrumented_files_kwargs
),
]

# When invoked by aspects (and when running `bazel coverage`), the
# baseline_coverage.dat created here will conflict with the baseline_coverage.dat of the
# underlying target, which is a build failure. So we add an option to disable it so that this
# function can be invoked from aspects for rules that have its own InstrumentedFilesInfo.
if include_coverage:
providers.append(
coverage_common.instrumented_files_info(
ctx,
**instrumented_files_kwargs
),
)

if crate_info_dict != None:
crate_info_dict.update({
"rustc_env": env,
Expand Down
Loading