Skip to content

Commit 2a47374

Browse files
nglevinluispadron
authored andcommitted
Add support for handling secure_features within build test rules.
Cherry-pick: 52b9a8a
1 parent a2fc3d5 commit 2a47374

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

apple/internal/testing/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ bzl_library(
6262
"//apple:__subpackages__",
6363
],
6464
deps = [
65+
"//apple/internal:features_support",
6566
"//apple/internal:providers",
67+
"//apple/internal:rule_attrs",
68+
"//apple/internal:secure_features_support",
6669
"//apple/internal:transition_support",
6770
],
6871
)

apple/internal/testing/build_test_rules.bzl

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@
1414

1515
"""Rules for writing build tests for libraries that target Apple platforms."""
1616

17+
load(
18+
"//apple/internal:features_support.bzl",
19+
"features_support",
20+
)
1721
load(
1822
"//apple/internal:providers.bzl",
1923
"AppleBinaryInfo",
2024
"AppleDsymBundleInfo",
2125
)
26+
load(
27+
"//apple/internal:rule_attrs.bzl",
28+
"rule_attrs",
29+
)
30+
load(
31+
"//apple/internal:secure_features_support.bzl",
32+
"secure_features_support",
33+
)
2234
load(
2335
"//apple/internal:transition_support.bzl",
2436
"transition_support",
@@ -59,6 +71,17 @@ def _apple_build_test_rule_impl(ctx):
5971
rule_kind = ctx.attr._platform_type + "_build_test",
6072
))
6173

74+
cc_configured_features_init = features_support.make_cc_configured_features_init(ctx)
75+
cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder
76+
77+
# Check that the requested secure features are supported and enabled for the toolchain.
78+
secure_features_support.validate_secure_features_support(
79+
cc_configured_features_init = cc_configured_features_init,
80+
cc_toolchain_forwarder = cc_toolchain_forwarder,
81+
rule_label = ctx.label,
82+
secure_features = ctx.attr.secure_features,
83+
)
84+
6285
transitive_files = [target[DefaultInfo].files for target in targets]
6386

6487
# The test's executable is a vacuously passing script. We pass all of the
@@ -96,16 +119,22 @@ def apple_build_test_rule(doc, platform_type):
96119
# compile successfully; right now we just verify that the code in the
97120
# libraries compiles.
98121
return rule(
99-
attrs = {
100-
# TODO: b/449684779 - Add a "secure_features" attribute to set required Clang
101-
# features for the purposes of build testing. Don't concern ourselves with setting
102-
# entitlements as they should not be necessary for validating compile time behavior.
122+
attrs = rule_attrs.static_library_archive_attrs(
123+
# Matching "targets" below.
124+
deps_cfg = transition_support.apple_platform_split_transition,
125+
) | {
103126
"minimum_os_version": attr.string(
104127
mandatory = True,
105128
doc = """\
106129
A required string indicating the minimum OS version that will be used as the
107130
deployment target when building the targets, represented as a dotted version
108131
number (for example, `"9.0"`).
132+
""",
133+
),
134+
"secure_features": attr.string_list(
135+
doc = """
136+
A list of strings representing Apple Enhanced Security crosstool features that should be enabled for
137+
this target.
109138
""",
110139
),
111140
"targets": attr.label_list(

0 commit comments

Comments
 (0)