Skip to content

Commit ccfe585

Browse files
brentleyjonesfmeum
andauthored
Use ctx.coverage_instrumented to detect if a target should be instrumented (#1547)
Signed-off-by: Brentley Jones <[email protected]> Co-authored-by: Fabian Meumertzheim <[email protected]>
1 parent 321bf26 commit ccfe585

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

swift/internal/features.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,21 @@ def configure_features(
9696
passed to other `swift_common` functions. Note that the structure of
9797
this value should otherwise not be relied on or inspected directly.
9898
"""
99+
requested_features = list(requested_features)
100+
unsupported_features = list(unsupported_features)
99101

100102
# Always disable these two features so that any `cc_common` APIs called by
101103
# `swift_common` APIs don't cause certain actions to be created (for
102104
# example, when using `cc_common.compile` to create the compilation context
103105
# for a generated header).
104-
unsupported_features = list(unsupported_features)
105106
unsupported_features.extend([
106107
"cc_include_scanning",
107108
"parse_headers",
108109
])
109110

111+
if ctx.coverage_instrumented():
112+
requested_features.append(SWIFT_FEATURE_COVERAGE)
113+
110114
# HACK: This is the only way today to check whether the caller is inside an
111115
# aspect. We have to do this because accessing `ctx.aspect_ids` halts the
112116
# build if called from outside an aspect, but we can't use `hasattr` to
@@ -180,8 +184,6 @@ def features_for_build_modes(ctx, cpp_fragment = None):
180184
compilation_mode = ctx.var["COMPILATION_MODE"]
181185
features = []
182186
features.append("swift.{}".format(compilation_mode))
183-
if ctx.configuration.coverage_enabled:
184-
features.append(SWIFT_FEATURE_COVERAGE)
185187
if compilation_mode in ("dbg", "fastbuild"):
186188
features.append(SWIFT_FEATURE_ENABLE_TESTING)
187189
if cpp_fragment and cpp_fragment.apple_generate_dsym:

0 commit comments

Comments
 (0)