Skip to content

Commit eab440f

Browse files
committed
Support setting minimum OS version in -target
See the linked issue in rules_swift_package_manager for rational for this change. We need to allow targets to set their target triple with the min os version. Changes in apple_support to export the Xcode SDK information allows us to pipe this down to the rules. Related: cgrindel/rules_swift_package_manager#892
1 parent b9b3499 commit eab440f

File tree

15 files changed

+287
-13
lines changed

15 files changed

+287
-13
lines changed

doc/api.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ A C++ `FeatureConfiguration` value (see
166166
<pre>
167167
swift_common.compile(*, <a href="#swift_common.compile-actions">actions</a>, <a href="#swift_common.compile-additional_inputs">additional_inputs</a>, <a href="#swift_common.compile-cc_infos">cc_infos</a>, <a href="#swift_common.compile-copts">copts</a>, <a href="#swift_common.compile-defines">defines</a>, <a href="#swift_common.compile-exec_group">exec_group</a>,
168168
<a href="#swift_common.compile-extra_swift_infos">extra_swift_infos</a>, <a href="#swift_common.compile-feature_configuration">feature_configuration</a>, <a href="#swift_common.compile-generated_header_name">generated_header_name</a>, <a href="#swift_common.compile-is_test">is_test</a>,
169-
<a href="#swift_common.compile-include_dev_srch_paths">include_dev_srch_paths</a>, <a href="#swift_common.compile-module_name">module_name</a>, <a href="#swift_common.compile-package_name">package_name</a>, <a href="#swift_common.compile-plugins">plugins</a>, <a href="#swift_common.compile-private_cc_infos">private_cc_infos</a>,
170-
<a href="#swift_common.compile-private_swift_infos">private_swift_infos</a>, <a href="#swift_common.compile-srcs">srcs</a>, <a href="#swift_common.compile-swift_infos">swift_infos</a>, <a href="#swift_common.compile-swift_toolchain">swift_toolchain</a>, <a href="#swift_common.compile-target_name">target_name</a>,
171-
<a href="#swift_common.compile-toolchain_type">toolchain_type</a>, <a href="#swift_common.compile-workspace_name">workspace_name</a>)
169+
<a href="#swift_common.compile-include_dev_srch_paths">include_dev_srch_paths</a>, <a href="#swift_common.compile-minimum_os_version">minimum_os_version</a>, <a href="#swift_common.compile-module_name">module_name</a>, <a href="#swift_common.compile-package_name">package_name</a>, <a href="#swift_common.compile-plugins">plugins</a>,
170+
<a href="#swift_common.compile-private_cc_infos">private_cc_infos</a>, <a href="#swift_common.compile-private_swift_infos">private_swift_infos</a>, <a href="#swift_common.compile-srcs">srcs</a>, <a href="#swift_common.compile-swift_infos">swift_infos</a>, <a href="#swift_common.compile-swift_toolchain">swift_toolchain</a>,
171+
<a href="#swift_common.compile-target_name">target_name</a>, <a href="#swift_common.compile-toolchain_type">toolchain_type</a>, <a href="#swift_common.compile-workspace_name">workspace_name</a>)
172172
</pre>
173173

174174
Compiles a Swift module.
@@ -189,6 +189,7 @@ Compiles a Swift module.
189189
| <a id="swift_common.compile-generated_header_name"></a>generated_header_name | The name of the Objective-C generated header that should be generated for this module. If omitted, no header will be generated. | `None` |
190190
| <a id="swift_common.compile-is_test"></a>is_test | Deprecated. This argument will be removed in the next major release. Use the `include_dev_srch_paths` attribute instead. Represents if the `testonly` value of the context. | `None` |
191191
| <a id="swift_common.compile-include_dev_srch_paths"></a>include_dev_srch_paths | A `bool` that indicates whether the developer framework search paths will be added to the compilation command. | `None` |
192+
| <a id="swift_common.compile-minimum_os_version"></a>minimum_os_version | A string representing the minimum OS version that this target should be compiled for (e.g., "17.0"). If provided, this is used to create a versioned target triple for the `-target` flag. If `None`, the default minimum OS version from the SDK is used. | `None` |
192193
| <a id="swift_common.compile-module_name"></a>module_name | The name of the Swift module being compiled. This must be present and valid; use `derive_swift_module_name` to generate a default from the target's label if needed. | none |
193194
| <a id="swift_common.compile-package_name"></a>package_name | The semantic package of the name of the Swift module being compiled. | none |
194195
| <a id="swift_common.compile-plugins"></a>plugins | A list of `SwiftCompilerPluginInfo` providers that represent plugins that should be loaded by the compiler. | `[]` |

doc/providers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ SwiftToolchainInfo(<a href="#SwiftToolchainInfo-action_configs">action_configs</
114114
<a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>, <a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>,
115115
<a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>,
116116
<a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>, <a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>,
117-
<a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>, <a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
117+
<a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>, <a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>, <a href="#SwiftToolchainInfo-xcode_sdk_info">xcode_sdk_info</a>)
118118
</pre>
119119

120120
Propagates information about a Swift toolchain to compilation and linking rules
@@ -144,5 +144,6 @@ that use the toolchain.
144144
| <a id="SwiftToolchainInfo-test_configuration"></a>test_configuration | `Struct` containing the following fields:<br><br>* `binary_name`: A template string used to compute the name of the output binary for `swift_test` rules. Any occurrences of the string `"{name}"` will be substituted by the name of the target.<br><br>* `env`: A `dict` of environment variables to be set when running tests that were built with this toolchain.<br><br>* `execution_requirements`: A `dict` of execution requirements for tests that were built with this toolchain.<br><br>* `objc_test_discovery`: A Boolean value indicating whether test targets should discover tests dynamically using the Objective-C runtime.<br><br>* `test_linking_contexts`: A list of `CcLinkingContext`s that provide additional flags to use when linking test binaries.<br><br>This is used, for example, with Xcode-based toolchains to ensure that the `xctest` helper and coverage tools are found in the correct developer directory when running tests. |
145145
| <a id="SwiftToolchainInfo-tool_configs"></a>tool_configs | This field is an internal implementation detail of the build rules. |
146146
| <a id="SwiftToolchainInfo-unsupported_features"></a>unsupported_features | `List` of `string`s. Features that should be implicitly disabled by default for targets built using this toolchain, unless overridden by the user by listing them in the `features` attribute of a target/package or in the `--features` command line flag.<br><br>These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |
147+
| <a id="SwiftToolchainInfo-xcode_sdk_info"></a>xcode_sdk_info | An optional `XcodeSdkVariantInfo` provider from `apple_support` that contains information about the current Xcode SDK, including:<br><br>This field may be `None` on unsupported platforms. |
147148

148149

0 commit comments

Comments
 (0)