|
14 | 14 |
|
15 | 15 | """Rules for writing build tests for libraries that target Apple platforms.""" |
16 | 16 |
|
| 17 | +load( |
| 18 | + "//apple/internal:features_support.bzl", |
| 19 | + "features_support", |
| 20 | +) |
17 | 21 | load( |
18 | 22 | "//apple/internal:providers.bzl", |
19 | 23 | "AppleBinaryInfo", |
20 | 24 | "AppleDsymBundleInfo", |
21 | 25 | ) |
| 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 | +) |
22 | 34 | load( |
23 | 35 | "//apple/internal:transition_support.bzl", |
24 | 36 | "transition_support", |
@@ -59,6 +71,17 @@ def _apple_build_test_rule_impl(ctx): |
59 | 71 | rule_kind = ctx.attr._platform_type + "_build_test", |
60 | 72 | )) |
61 | 73 |
|
| 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 | + |
62 | 85 | transitive_files = [target[DefaultInfo].files for target in targets] |
63 | 86 |
|
64 | 87 | # 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): |
96 | 119 | # compile successfully; right now we just verify that the code in the |
97 | 120 | # libraries compiles. |
98 | 121 | 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 | + ) | { |
103 | 126 | "minimum_os_version": attr.string( |
104 | 127 | mandatory = True, |
105 | 128 | doc = """\ |
106 | 129 | A required string indicating the minimum OS version that will be used as the |
107 | 130 | deployment target when building the targets, represented as a dotted version |
108 | 131 | 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. |
109 | 138 | """, |
110 | 139 | ), |
111 | 140 | "targets": attr.label_list( |
|
0 commit comments