Skip to content

Commit 05828db

Browse files
committed
Fix SWIFT_TOOLCHAIN_TYPE to work with Bzlmod + AEG
Use a label to it resolves correctly regardless of the repo that references it. Signed-off-by: Brentley Jones <[email protected]>
1 parent 3dfbf33 commit 05828db

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

doc/api.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Compiles a Swift module.
198198
| <a id="swift_common.compile-swift_infos"></a>swift_infos | A list of `SwiftInfo` providers from non-private dependencies of the target being compiled. The modules defined by these providers are used as dependencies of both the Swift module being compiled and the Clang module for the generated header. | none |
199199
| <a id="swift_common.compile-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
200200
| <a id="swift_common.compile-target_name"></a>target_name | The name of the target for which the code is being compiled, which is used to determine unique file paths for the outputs. | none |
201-
| <a id="swift_common.compile-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
201+
| <a id="swift_common.compile-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `Label("@rules_swift//toolchains:toolchain_type")` |
202202
| <a id="swift_common.compile-workspace_name"></a>workspace_name | The name of the workspace for which the code is being compiled, which is used to determine unique file paths for some outputs. | none |
203203

204204
**RETURNS**
@@ -275,7 +275,7 @@ Compiles a Swift module interface.
275275
| <a id="swift_common.compile_module_interface-swift_infos"></a>swift_infos | A list of `SwiftInfo` providers from dependencies of the target being compiled. | none |
276276
| <a id="swift_common.compile_module_interface-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
277277
| <a id="swift_common.compile_module_interface-target_name"></a>target_name | The name of the target for which the code is being compiled, which is used to determine unique file paths for the outputs. | none |
278-
| <a id="swift_common.compile_module_interface-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
278+
| <a id="swift_common.compile_module_interface-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `Label("@rules_swift//toolchains:toolchain_type")` |
279279

280280
**RETURNS**
281281

@@ -395,7 +395,7 @@ command line parameters file, those actions will be created here.
395395
| <a id="swift_common.create_linking_context_from_compilation_outputs-module_context"></a>module_context | The module context returned by `compile` containing information about the Swift module that was compiled. Typically, this is the first tuple element in the value returned by `compile`. | none |
396396
| <a id="swift_common.create_linking_context_from_compilation_outputs-name"></a>name | A string that is used to derive the name of the library or libraries linked by this function. If this is not provided or is a falsy value, the name component of the `label` argument is used. | `None` |
397397
| <a id="swift_common.create_linking_context_from_compilation_outputs-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
398-
| <a id="swift_common.create_linking_context_from_compilation_outputs-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
398+
| <a id="swift_common.create_linking_context_from_compilation_outputs-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `Label("@rules_swift//toolchains:toolchain_type")` |
399399
| <a id="swift_common.create_linking_context_from_compilation_outputs-user_link_flags"></a>user_link_flags | A `list` of strings containing additional flags that will be passed to the linker for any binary that links with the returned linking context. | `[]` |
400400

401401
**RETURNS**
@@ -433,7 +433,7 @@ Extracts the symbol graph from a Swift module.
433433
| <a id="swift_common.extract_symbol_graph-output_dir"></a>output_dir | A directory-type `File` into which `.symbols.json` files representing the module's symbol graph will be extracted. If extraction is successful, this directory will contain a file named `${MODULE_NAME}.symbols.json`. Optionally, if the module contains extensions to types in other modules, then there will also be files named `${MODULE_NAME}@${EXTENDED_MODULE}.symbols.json`. | none |
434434
| <a id="swift_common.extract_symbol_graph-swift_infos"></a>swift_infos | A list of `SwiftInfo` providers from dependencies of the target being compiled. This should include both propagated and non-propagated (implementation-only) dependencies. | none |
435435
| <a id="swift_common.extract_symbol_graph-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
436-
| <a id="swift_common.extract_symbol_graph-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
436+
| <a id="swift_common.extract_symbol_graph-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `Label("@rules_swift//toolchains:toolchain_type")` |
437437

438438

439439
<a id="swift_common.get_toolchain"></a>
@@ -454,7 +454,7 @@ Gets the Swift toolchain associated with the rule or aspect.
454454
| <a id="swift_common.get_toolchain-ctx"></a>ctx | The rule or aspect context. | none |
455455
| <a id="swift_common.get_toolchain-exec_group"></a>exec_group | The name of the execution group that should contain the toolchain. If this is provided and the toolchain is not declared in that execution group, it will be looked up from `ctx` as a fallback instead. If this argument is `None` (the default), then the toolchain will only be looked up from `ctx.` | `None` |
456456
| <a id="swift_common.get_toolchain-mandatory"></a>mandatory | If `False`, this function will return `None` instead of failing if no toolchain is found. Defaults to `True`. | `True` |
457-
| <a id="swift_common.get_toolchain-toolchain_type"></a>toolchain_type | The toolchain type to use. Defaults to the standard Swift toolchain type. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
457+
| <a id="swift_common.get_toolchain-toolchain_type"></a>toolchain_type | The toolchain type to use. Defaults to the standard Swift toolchain type. | `Label("@rules_swift//toolchains:toolchain_type")` |
458458
| <a id="swift_common.get_toolchain-attr"></a>attr | The name of the attribute on the calling rule or aspect that should be used to retrieve the toolchain if it is not provided by the `toolchains` argument of the rule/aspect. Note that this is only supported for legacy/migration purposes and will be removed once migration to toolchains is complete. | `"_toolchain"` |
459459

460460
**RETURNS**
@@ -579,7 +579,7 @@ Extracts the symbol graph from a Swift module.
579579
| <a id="swift_common.synthesize_interface-output_file"></a>output_file | A `File` into which the synthesized interface will be written. | none |
580580
| <a id="swift_common.synthesize_interface-swift_infos"></a>swift_infos | A list of `SwiftInfo` providers from dependencies of the target being compiled. This should include both propagated and non-propagated (implementation-only) dependencies. | none |
581581
| <a id="swift_common.synthesize_interface-swift_toolchain"></a>swift_toolchain | The `SwiftToolchainInfo` provider of the toolchain. | none |
582-
| <a id="swift_common.synthesize_interface-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
582+
| <a id="swift_common.synthesize_interface-toolchain_type"></a>toolchain_type | The toolchain type of the `swift_toolchain` which is used for the proper selection of the execution platform inside `run_toolchain_action`. | `Label("@rules_swift//toolchains:toolchain_type")` |
583583

584584

585585
<a id="swift_common.use_toolchain"></a>
@@ -607,7 +607,7 @@ toolchains = use_swift_toolchain() + [other toolchains...]
607607
| Name | Description | Default Value |
608608
| :------------- | :------------- | :------------- |
609609
| <a id="swift_common.use_toolchain-mandatory"></a>mandatory | Whether or not it should be an error if the toolchain cannot be resolved. Defaults to True. | `True` |
610-
| <a id="swift_common.use_toolchain-toolchain_type"></a>toolchain_type | The toolchain type to use. Defaults to the standard Swift toolchain type. | `"@build_bazel_rules_swift//toolchains:toolchain_type"` |
610+
| <a id="swift_common.use_toolchain-toolchain_type"></a>toolchain_type | The toolchain type to use. Defaults to the standard Swift toolchain type. | `Label("@rules_swift//toolchains:toolchain_type")` |
611611

612612
**RETURNS**
613613

swift/internal/toolchain_utils.bzl

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

1515
"""Helpers used to depend on and access the Swift toolchain."""
1616

17-
SWIFT_TOOLCHAIN_TYPE = "@build_bazel_rules_swift//toolchains:toolchain_type"
17+
SWIFT_TOOLCHAIN_TYPE = Label("//toolchains:toolchain_type")
1818

1919
def get_swift_toolchain(
2020
ctx,

0 commit comments

Comments
 (0)