Skip to content

Commit a52041f

Browse files
xortiveUebelAndre
andauthored
Support target_settings in rust_repository_set and rust_toolchain_repository (#1758)
* support target_settings in rust_repository_set and rust_toolchain_repository * Regenerate documentation Co-authored-by: UebelAndre <[email protected]>
1 parent 49906eb commit a52041f

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

docs/flatten.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,9 +1826,9 @@ rust_repositories(<a href="#rust_repositories-kwargs">kwargs</a>)
18261826
## rust_repository_set
18271827

18281828
<pre>
1829-
rust_repository_set(<a href="#rust_repository_set-name">name</a>, <a href="#rust_repository_set-exec_triple">exec_triple</a>, <a href="#rust_repository_set-version">version</a>, <a href="#rust_repository_set-versions">versions</a>, <a href="#rust_repository_set-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_repository_set-allocator_library">allocator_library</a>,
1830-
<a href="#rust_repository_set-extra_target_triples">extra_target_triples</a>, <a href="#rust_repository_set-iso_date">iso_date</a>, <a href="#rust_repository_set-rustfmt_version">rustfmt_version</a>, <a href="#rust_repository_set-edition">edition</a>, <a href="#rust_repository_set-dev_components">dev_components</a>, <a href="#rust_repository_set-sha256s">sha256s</a>,
1831-
<a href="#rust_repository_set-urls">urls</a>, <a href="#rust_repository_set-auth">auth</a>, <a href="#rust_repository_set-register_toolchain">register_toolchain</a>)
1829+
rust_repository_set(<a href="#rust_repository_set-name">name</a>, <a href="#rust_repository_set-exec_triple">exec_triple</a>, <a href="#rust_repository_set-target_settings">target_settings</a>, <a href="#rust_repository_set-version">version</a>, <a href="#rust_repository_set-versions">versions</a>, <a href="#rust_repository_set-include_rustc_srcs">include_rustc_srcs</a>,
1830+
<a href="#rust_repository_set-allocator_library">allocator_library</a>, <a href="#rust_repository_set-extra_target_triples">extra_target_triples</a>, <a href="#rust_repository_set-iso_date">iso_date</a>, <a href="#rust_repository_set-rustfmt_version">rustfmt_version</a>, <a href="#rust_repository_set-edition">edition</a>,
1831+
<a href="#rust_repository_set-dev_components">dev_components</a>, <a href="#rust_repository_set-sha256s">sha256s</a>, <a href="#rust_repository_set-urls">urls</a>, <a href="#rust_repository_set-auth">auth</a>, <a href="#rust_repository_set-register_toolchain">register_toolchain</a>)
18321832
</pre>
18331833

18341834
Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
@@ -1840,6 +1840,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
18401840
| :------------- | :------------- | :------------- |
18411841
| <a id="rust_repository_set-name"></a>name | The name of the generated repository | none |
18421842
| <a id="rust_repository_set-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | none |
1843+
| <a id="rust_repository_set-target_settings"></a>target_settings | A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution. | `[]` |
18431844
| <a id="rust_repository_set-version"></a>version | The version of the tool among "nightly", "beta', or an exact version. | `None` |
18441845
| <a id="rust_repository_set-versions"></a>versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. <code>["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]</code>. | `[]` |
18451846
| <a id="rust_repository_set-include_rustc_srcs"></a>include_rustc_srcs | **Deprecated** - instead see [rust_analyzer_toolchain_repository](#rust_analyzer_toolchain_repository). | `False` |
@@ -1925,8 +1926,9 @@ rust_test_suite(
19251926

19261927
<pre>
19271928
rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-version">version</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_repository-exec_compatible_with">exec_compatible_with</a>,
1928-
<a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-channel">channel</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-allocator_library">allocator_library</a>,
1929-
<a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
1929+
<a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-target_settings">target_settings</a>, <a href="#rust_toolchain_repository-channel">channel</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>,
1930+
<a href="#rust_toolchain_repository-allocator_library">allocator_library</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>,
1931+
<a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
19301932
</pre>
19311933

19321934
Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
@@ -1942,6 +1944,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
19421944
| <a id="rust_toolchain_repository-target_triple"></a>target_triple | The Rust-style target to build for. | none |
19431945
| <a id="rust_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. | `None` |
19441946
| <a id="rust_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. | `None` |
1947+
| <a id="rust_toolchain_repository-target_settings"></a>target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | `[]` |
19451948
| <a id="rust_toolchain_repository-channel"></a>channel | The channel of the Rust toolchain. | `None` |
19461949
| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. | `False` |
19471950
| <a id="rust_toolchain_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |

docs/rust_repositories.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ rust_repositories(<a href="#rust_repositories-kwargs">kwargs</a>)
291291
## rust_repository_set
292292

293293
<pre>
294-
rust_repository_set(<a href="#rust_repository_set-name">name</a>, <a href="#rust_repository_set-exec_triple">exec_triple</a>, <a href="#rust_repository_set-version">version</a>, <a href="#rust_repository_set-versions">versions</a>, <a href="#rust_repository_set-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_repository_set-allocator_library">allocator_library</a>,
295-
<a href="#rust_repository_set-extra_target_triples">extra_target_triples</a>, <a href="#rust_repository_set-iso_date">iso_date</a>, <a href="#rust_repository_set-rustfmt_version">rustfmt_version</a>, <a href="#rust_repository_set-edition">edition</a>, <a href="#rust_repository_set-dev_components">dev_components</a>, <a href="#rust_repository_set-sha256s">sha256s</a>,
296-
<a href="#rust_repository_set-urls">urls</a>, <a href="#rust_repository_set-auth">auth</a>, <a href="#rust_repository_set-register_toolchain">register_toolchain</a>)
294+
rust_repository_set(<a href="#rust_repository_set-name">name</a>, <a href="#rust_repository_set-exec_triple">exec_triple</a>, <a href="#rust_repository_set-target_settings">target_settings</a>, <a href="#rust_repository_set-version">version</a>, <a href="#rust_repository_set-versions">versions</a>, <a href="#rust_repository_set-include_rustc_srcs">include_rustc_srcs</a>,
295+
<a href="#rust_repository_set-allocator_library">allocator_library</a>, <a href="#rust_repository_set-extra_target_triples">extra_target_triples</a>, <a href="#rust_repository_set-iso_date">iso_date</a>, <a href="#rust_repository_set-rustfmt_version">rustfmt_version</a>, <a href="#rust_repository_set-edition">edition</a>,
296+
<a href="#rust_repository_set-dev_components">dev_components</a>, <a href="#rust_repository_set-sha256s">sha256s</a>, <a href="#rust_repository_set-urls">urls</a>, <a href="#rust_repository_set-auth">auth</a>, <a href="#rust_repository_set-register_toolchain">register_toolchain</a>)
297297
</pre>
298298

299299
Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
@@ -305,6 +305,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
305305
| :------------- | :------------- | :------------- |
306306
| <a id="rust_repository_set-name"></a>name | The name of the generated repository | none |
307307
| <a id="rust_repository_set-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | none |
308+
| <a id="rust_repository_set-target_settings"></a>target_settings | A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution. | `[]` |
308309
| <a id="rust_repository_set-version"></a>version | The version of the tool among "nightly", "beta', or an exact version. | `None` |
309310
| <a id="rust_repository_set-versions"></a>versions | A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. <code>["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]</code>. | `[]` |
310311
| <a id="rust_repository_set-include_rustc_srcs"></a>include_rustc_srcs | **Deprecated** - instead see [rust_analyzer_toolchain_repository](#rust_analyzer_toolchain_repository). | `False` |
@@ -326,8 +327,9 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
326327

327328
<pre>
328329
rust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-version">version</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_repository-exec_compatible_with">exec_compatible_with</a>,
329-
<a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-channel">channel</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>, <a href="#rust_toolchain_repository-allocator_library">allocator_library</a>,
330-
<a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
330+
<a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-target_settings">target_settings</a>, <a href="#rust_toolchain_repository-channel">channel</a>, <a href="#rust_toolchain_repository-include_rustc_srcs">include_rustc_srcs</a>,
331+
<a href="#rust_toolchain_repository-allocator_library">allocator_library</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-edition">edition</a>, <a href="#rust_toolchain_repository-dev_components">dev_components</a>,
332+
<a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>)
331333
</pre>
332334

333335
Assembles a remote repository for the given toolchain params, produces a proxy repository to contain the toolchain declaration, and registers the toolchains.
@@ -343,6 +345,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
343345
| <a id="rust_toolchain_repository-target_triple"></a>target_triple | The Rust-style target to build for. | none |
344346
| <a id="rust_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. | `None` |
345347
| <a id="rust_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. | `None` |
348+
| <a id="rust_toolchain_repository-target_settings"></a>target_settings | A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution. | `[]` |
346349
| <a id="rust_toolchain_repository-channel"></a>channel | The channel of the Rust toolchain. | `None` |
347350
| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. | `False` |
348351
| <a id="rust_toolchain_repository-allocator_library"></a>allocator_library | Target that provides allocator functions when rust_library targets are embedded in a cc_binary. | `None` |

rust/repositories.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ def rust_toolchain_repository(
446446
target_triple,
447447
exec_compatible_with = None,
448448
target_compatible_with = None,
449+
target_settings = [],
449450
channel = None,
450451
include_rustc_srcs = False,
451452
allocator_library = None,
@@ -467,6 +468,7 @@ def rust_toolchain_repository(
467468
channel (str, optional): The channel of the Rust toolchain.
468469
exec_compatible_with (list, optional): A list of constraints for the execution platform for this toolchain.
469470
target_compatible_with (list, optional): A list of constraints for the target platform for this toolchain.
471+
target_settings (list, optional): A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.
470472
include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support.
471473
allocator_library (str, optional): Target that provides allocator functions when rust_library targets are embedded in a cc_binary.
472474
iso_date (str, optional): The date of the tool.
@@ -514,10 +516,12 @@ def rust_toolchain_repository(
514516
auth = auth,
515517
)
516518

519+
channel_target_settings = ["@rules_rust//rust/toolchain/channel:{}".format(channel)] if channel else []
520+
517521
toolchain_repository_proxy(
518522
name = name,
519523
toolchain = "@{}//:rust_toolchain".format(tools_repo_name),
520-
target_settings = ["@rules_rust//rust/toolchain/channel:{}".format(channel)] if channel else None,
524+
target_settings = channel_target_settings + target_settings,
521525
toolchain_type = "@rules_rust//rust:toolchain",
522526
exec_compatible_with = exec_compatible_with,
523527
target_compatible_with = target_compatible_with,
@@ -774,6 +778,7 @@ rust_toolchain_set_repository = repository_rule(
774778
def rust_repository_set(
775779
name,
776780
exec_triple,
781+
target_settings = [],
777782
version = None,
778783
versions = [],
779784
include_rustc_srcs = False,
@@ -793,6 +798,7 @@ def rust_repository_set(
793798
Args:
794799
name (str): The name of the generated repository
795800
exec_triple (str): The Rust-style target that this compiler runs on
801+
target_settings (list, optional): A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution.
796802
version (str): The version of the tool among "nightly", "beta', or an exact version.
797803
versions (list, optional): A list of toolchain versions to download. This paramter only accepts one versions
798804
per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`.
@@ -871,6 +877,7 @@ def rust_repository_set(
871877
dev_components = dev_components,
872878
edition = edition,
873879
exec_triple = exec_triple,
880+
target_settings = target_settings,
874881
include_rustc_srcs = include_rustc_srcs,
875882
iso_date = info.iso_date,
876883
rustfmt_version = rustfmt_version,

0 commit comments

Comments
 (0)