fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreAdded a build setting for toolchain channels (#1671)46b7ea5a

main
899 B30 linesraw
1"""Rules for representing Rust toolchain channels"""
2
3_CHANNELS = [
4    "beta",
5    "nightly",
6    "stable",
7]
8
9RustToolchainChannelInfo = provider(
10    doc = "A provider describing the Rust toolchain channel.",
11    fields = {
12        "value": "string: Can be {}".format(_CHANNELS),
13    },
14)
15
16def _rust_toolchain_channel_flag_impl(ctx):
17    value = ctx.build_setting_value
18    if value not in _CHANNELS:
19        fail(str(ctx.label) + " build setting allowed to take values {" +
20             ", ".join(_CHANNELS) + "} but was set to unallowed value " +
21             value)
22    return RustToolchainChannelInfo(value = value)
23
24rust_toolchain_channel_flag = rule(
25    doc = "A build setting which represents the Rust toolchain channel. The allowed values are {}".format(_CHANNELS),
26    implementation = _rust_toolchain_channel_flag_impl,
27    build_setting = config.string(
28        flag = True,
29    ),
30)