fork/rules_rust

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

UebelAndreDrop references to `wasm-wasi` (#3027)ba6af156

main
3.3 KiB135 linesraw
1"""Definitions for support config settings and platform definitions"""
2
3load("@bazel_skylib//lib:selects.bzl", "selects")
4load(
5    ":triple_mappings.bzl",
6    "ALL_PLATFORM_TRIPLES",
7    "cpu_arch_to_constraints",
8    "system_to_constraints",
9    "triple_to_constraint_set",
10)
11
12_SUPPORTED_CPU_ARCH = [
13    "aarch64",
14    "arm",
15    "armv7",
16    "i686",
17    "powerpc",
18    "s390x",
19    "x86_64",
20    "riscv32",
21    "riscv64",
22]
23
24_SUPPORTED_SYSTEMS = [
25    "android",
26    "darwin",
27    "freebsd",
28    "ios",
29    "linux",
30    "windows",
31    "nto",
32]
33
34# buildifier: disable=unnamed-macro
35def declare_config_settings():
36    """Helper function for declaring `config_setting`s"""
37    for cpu_arch in _SUPPORTED_CPU_ARCH:
38        native.config_setting(
39            name = cpu_arch,
40            constraint_values = cpu_arch_to_constraints(cpu_arch),
41        )
42
43    for system in _SUPPORTED_SYSTEMS:
44        native.config_setting(
45            name = system,
46            constraint_values = system_to_constraints(system),
47        )
48
49    # Add alias for OSX to "darwin" to match what users will be expecting.
50    native.alias(
51        name = "osx",
52        actual = ":darwin",
53    )
54
55    # Add alias for OSX to "macos" to be consistent with the long-term
56    # direction of `@platforms` in using the OS's modern name.
57    native.alias(
58        name = "macos",
59        actual = ":darwin",
60    )
61
62    all_supported_triples = ALL_PLATFORM_TRIPLES
63    for triple in all_supported_triples:
64        native.config_setting(
65            name = triple,
66            constraint_values = triple_to_constraint_set(triple),
67        )
68
69    # Add alias for wasm to maintain backwards compatibility.
70    native.alias(
71        name = "wasm32-wasi",
72        actual = ":wasm32-wasip1",
73        deprecation = "Use `@rules_rust//rust/platform:wasm-wasip1` instead.",
74    )
75
76    native.platform(
77        name = "wasm32",
78        constraint_values = [
79            "@platforms//cpu:wasm32",
80            str(Label("//rust/platform/os:unknown")),
81        ],
82    )
83
84    # Add alias for wasm to maintain backwards compatibility.
85    native.alias(
86        name = "wasm",
87        actual = ":wasm32",
88        deprecation = "Use `@rules_rust//rust/platform:wasm32` instead",
89    )
90
91    native.platform(
92        name = "wasm64",
93        constraint_values = [
94            "@platforms//cpu:wasm64",
95            str(Label("//rust/platform/os:unknown")),
96        ],
97    )
98
99    native.platform(
100        name = "wasip1",
101        constraint_values = [
102            "@platforms//cpu:wasm32",
103            "@platforms//os:wasi",
104        ],
105    )
106
107    # Add alias for wasi to maintain backwards compatibility.
108    native.alias(
109        name = "wasi",
110        actual = ":wasip1",
111        deprecation = "Use `@rules_rust//rust/platform:wasip1` instead",
112    )
113
114    selects.config_setting_group(
115        name = "unix",
116        match_any = [
117            ":android",
118            ":darwin",
119            ":freebsd",
120            ":linux",
121            ":nto",
122        ],
123    )
124
125    native.alias(
126        name = "aarch64-fuchsia",
127        actual = "aarch64-unknown-fuchsia",
128        deprecation = "Use `@rules_rust//rust/platform:aarch64-unknown-fuchsia` instead.",
129    )
130
131    native.alias(
132        name = "x86_64-fuchsia",
133        actual = "x86_64-unknown-fuchsia",
134        deprecation = "Use `@rules_rust//rust/platform:x86_64-unknown-fuchsia` instead.",
135    )