Skip to content

Commit 1b698e9

Browse files
committed
pass down feature_configuration
1 parent c4dc970 commit 1b698e9

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

cc/common/cc_helper.bzl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,17 +1025,10 @@ def _linkopts(ctx, additional_make_variable_substitutions, cc_toolchain):
10251025
fail("in linkopts attribute of cc_library rule {}: Apple builds do not support statically linked binaries".format(ctx.label))
10261026
return tokens
10271027

1028-
def _get_coverage_environment(ctx, cc_config, cc_toolchain):
1028+
def _get_coverage_environment(ctx, cc_config, cc_toolchain, feature_configuration):
10291029
if not ctx.configuration.coverage_enabled:
10301030
return {}
10311031

1032-
feature_configuration = cc_common.configure_features(
1033-
ctx = ctx,
1034-
cc_toolchain = cc_toolchain,
1035-
requested_features = ctx.features,
1036-
unsupported_features = ctx.disabled_features,
1037-
)
1038-
10391032
# buildifier: disable=unsorted-dict-items
10401033
env = {
10411034
"COVERAGE_GCOV_PATH": _tool_path(cc_toolchain, "gcov", feature_configuration, ACTION_NAMES.gcov),
@@ -1050,15 +1043,15 @@ def _get_coverage_environment(ctx, cc_config, cc_toolchain):
10501043
env["FDO_DIR"] = cc_config.fdo_instrument()
10511044
return env
10521045

1053-
def _create_cc_instrumented_files_info(ctx, cc_config, cc_toolchain, metadata_files, virtual_to_original_headers = None):
1046+
def _create_cc_instrumented_files_info(ctx, cc_config, cc_toolchain, feature_configuration, metadata_files, virtual_to_original_headers = None):
10541047
source_extensions = extensions.CC_SOURCE + \
10551048
extensions.C_SOURCE + \
10561049
extensions.CC_HEADER + \
10571050
extensions.ASSEMBLER_WITH_C_PREPROCESSOR + \
10581051
extensions.ASSEMBLER
10591052
coverage_environment = {}
10601053
if ctx.configuration.coverage_enabled:
1061-
coverage_environment = _get_coverage_environment(ctx, cc_config, cc_toolchain)
1054+
coverage_environment = _get_coverage_environment(ctx, cc_config, cc_toolchain, feature_configuration)
10621055
coverage_support_files = cc_toolchain._coverage_files if ctx.configuration.coverage_enabled else depset([])
10631056
info = coverage_common.instrumented_files_info(
10641057
ctx = ctx,

cc/private/rules_impl/cc_binary_impl.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def _add_transitive_info_providers(ctx, cc_toolchain, cpp_config, feature_config
107107
ctx = ctx,
108108
cc_config = cpp_config,
109109
cc_toolchain = cc_toolchain,
110+
feature_configuration = feature_configuration,
110111
metadata_files = additional_meta_data + gcno_files + pic_gcno_files,
111112
virtual_to_original_headers =
112113
compilation_context.virtual_to_original_headers() if hasattr(compilation_context, "virtual_to_original_headers") else compilation_context._virtual_to_original_headers,

cc/private/rules_impl/cc_library_impl.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def _cc_library_impl(ctx):
273273
ctx = ctx,
274274
cc_config = ctx.fragments.cpp,
275275
cc_toolchain = cc_toolchain,
276+
feature_configuration = feature_configuration,
276277
metadata_files = gcno_files + pic_gcno_files,
277278
)
278279

cc/private/rules_impl/objc_library.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""objc_library Starlark implementation replacing native"""
1616

17+
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
1718
load("//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain")
1819
load("//cc/common:cc_helper.bzl", "cc_helper")
1920
load("//cc/common:cc_info.bzl", "CcInfo")
@@ -85,12 +86,18 @@ def _objc_library_impl(ctx):
8586
pic_gcno_files = compilation_outputs.pic_gcno_files()
8687
else:
8788
pic_gcno_files = compilation_outputs._pic_gcno_files
89+
feature_configuration = cc_common.configure_features(
90+
ctx = ctx,
91+
cc_toolchain = cc_toolchain,
92+
requested_features = ctx.features,
93+
unsupported_features = ctx.disabled_features,
94+
)
8895
instrumented_files_info = coverage_common.instrumented_files_info(
8996
ctx = ctx,
9097
source_attributes = ["srcs", "non_arc_srcs", "hdrs"],
9198
dependency_attributes = ["deps", "data", "binary", "xctest_app"],
9299
extensions = extensions.NON_CPP_SOURCES + extensions.CPP_SOURCES + extensions.HEADERS,
93-
coverage_environment = cc_helper.get_coverage_environment(ctx, ctx.fragments.cpp, cc_toolchain),
100+
coverage_environment = cc_helper.get_coverage_environment(ctx, ctx.fragments.cpp, cc_toolchain, feature_configuration),
94101
# TODO(cmita): Use ctx.coverage_instrumented() instead when rules_swift can access
95102
# cc_toolchain.coverage_files and the coverage_support_files parameter of
96103
# coverage_common.instrumented_files_info(...)

0 commit comments

Comments
 (0)