-
Notifications
You must be signed in to change notification settings - Fork 412
/
platform.bzl
94 lines (83 loc) · 2.13 KB
/
platform.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""Definitions for support config settings and platform definitions"""
load("@bazel_skylib//lib:selects.bzl", "selects")
load(
":triple_mappings.bzl",
"SUPPORTED_PLATFORM_TRIPLES",
"cpu_arch_to_constraints",
"system_to_constraints",
"triple_to_constraint_set",
)
_SUPPORTED_CPU_ARCH = [
"aarch64",
"arm",
"armv7",
"i686",
"powerpc",
"s390x",
"x86_64",
"riscv32",
"riscv64",
]
_SUPPORTED_SYSTEMS = [
"android",
"darwin",
"freebsd",
"ios",
"linux",
"windows",
"nto",
]
# buildifier: disable=unnamed-macro
def declare_config_settings():
"""Helper function for declaring `config_setting`s"""
for cpu_arch in _SUPPORTED_CPU_ARCH:
native.config_setting(
name = cpu_arch,
constraint_values = cpu_arch_to_constraints(cpu_arch),
)
for system in _SUPPORTED_SYSTEMS:
native.config_setting(
name = system,
constraint_values = system_to_constraints(system),
)
# Add alias for OSX to "darwin" to match what users will be expecting.
native.alias(
name = "osx",
actual = ":darwin",
)
# Add alias for OSX to "macos" to be consistent with the long-term
# direction of `@platforms` in using the OS's modern name.
native.alias(
name = "macos",
actual = ":darwin",
)
all_supported_triples = SUPPORTED_PLATFORM_TRIPLES
for triple in all_supported_triples:
native.config_setting(
name = triple,
constraint_values = triple_to_constraint_set(triple),
)
native.platform(
name = "wasm",
constraint_values = [
"@platforms//cpu:wasm32",
str(Label("//rust/platform/os:unknown")),
],
)
native.platform(
name = "wasi",
constraint_values = [
"@platforms//cpu:wasm32",
"@platforms//os:wasi",
],
)
selects.config_setting_group(
name = "unix",
match_any = [
":android",
":darwin",
":freebsd",
":linux",
":nto",
],
)