Skip to content

Commit 9b55e4c

Browse files
authored
Merge pull request #31 from dtolnay/execplatform
Drop unneeded execution platforms
2 parents 07eb2c7 + b54f184 commit 9b55e4c

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ $ buck2 build :rustc_ast[profile][llvm_passes] --show-output
5252

5353
## Configurations
5454

55-
The following execution platforms are available for use with `--target-platforms`:
55+
The following platforms are available for use with `--target-platforms`:
5656

5757
- `//platforms/stage1:library`
5858
- `//platforms/stage1:library-build-script`

platforms/BUCK

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@prelude//platforms:defs.bzl", "host_configuration")
2-
load(":defs.bzl", "execution_platforms", "platform")
2+
load(":defs.bzl", "execution_platform", "execution_platforms")
33

4-
platform(
4+
execution_platform(
55
name = "host",
66
constraint_values = [
77
host_configuration.cpu,
@@ -14,13 +14,9 @@ execution_platforms(
1414
name = "execution",
1515
platforms = [
1616
":host",
17-
"//platforms/stage1:compiler",
1817
"//platforms/stage1:compiler-build-script",
19-
"//platforms/stage1:library",
2018
"//platforms/stage1:library-build-script",
21-
"//platforms/stage2:compiler",
2219
"//platforms/stage2:compiler-build-script",
23-
"//platforms/stage2:library",
2420
"//platforms/stage2:library-build-script",
2521
],
2622
)

platforms/defs.bzl

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,45 @@ def _platform_impl(ctx: AnalysisContext) -> list[Provider]:
4444
label = str(platform_label),
4545
configuration = configuration,
4646
),
47-
ExecutionPlatformInfo(
47+
TransitionInfo(impl = transition_impl),
48+
] + (
49+
[ExecutionPlatformInfo(
4850
label = platform_label,
4951
configuration = configuration,
5052
executor_config = CommandExecutorConfig(
5153
local_enabled = True,
5254
remote_enabled = False,
5355
use_windows_path_separators = use_windows_path_separators,
5456
),
55-
),
56-
TransitionInfo(impl = transition_impl),
57-
]
57+
)] if ctx.attrs.execution_platform else []
58+
)
59+
60+
_platform_attrs = {
61+
"base": attrs.option(attrs.dep(providers = [PlatformInfo]), default = None),
62+
"constraint_values": attrs.list(attrs.configuration_label(), default = []),
63+
# Configuration settings in this list are overwritten during a
64+
# transition to this platform, whereas configuration settings not in
65+
# this list are preserved.
66+
"transition": attrs.list(attrs.configuration_label(), default = [
67+
"//constraints:bootstrap-stage",
68+
"//constraints:build-script",
69+
"//constraints:opt-level",
70+
"//constraints:workspace",
71+
]),
72+
}
5873

59-
platform = rule(
74+
target_platform = rule(
6075
impl = _platform_impl,
61-
attrs = {
62-
"base": attrs.option(attrs.dep(providers = [PlatformInfo]), default = None),
63-
"constraint_values": attrs.list(attrs.configuration_label(), default = []),
64-
# Configuration settings in this list are overwritten during a
65-
# transition to this platform, whereas configuration settings not in
66-
# this list are preserved.
67-
"transition": attrs.list(attrs.configuration_label(), default = [
68-
"//constraints:bootstrap-stage",
69-
"//constraints:build-script",
70-
"//constraints:opt-level",
71-
"//constraints:workspace",
72-
]),
76+
attrs = _platform_attrs | {
77+
"execution_platform": attrs.default_only(attrs.bool(default = False)),
78+
},
79+
is_configuration_rule = True,
80+
)
81+
82+
execution_platform = rule(
83+
impl = _platform_impl,
84+
attrs = _platform_attrs | {
85+
"execution_platform": attrs.default_only(attrs.bool(default = True)),
7386
},
7487
is_configuration_rule = True,
7588
)

platforms/stage1/BUCK

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
load("//platforms:defs.bzl", "platform")
1+
load("//platforms:defs.bzl", "execution_platform", "target_platform")
22

3-
platform(
3+
target_platform(
44
name = "library",
55
base = "//platforms:host",
66
constraint_values = [
@@ -12,7 +12,7 @@ platform(
1212
visibility = ["PUBLIC"],
1313
)
1414

15-
platform(
15+
execution_platform(
1616
name = "library-build-script",
1717
base = ":library",
1818
constraint_values = [
@@ -22,7 +22,7 @@ platform(
2222
visibility = ["PUBLIC"],
2323
)
2424

25-
platform(
25+
target_platform(
2626
name = "compiler",
2727
base = "//platforms:host",
2828
constraint_values = [
@@ -34,7 +34,7 @@ platform(
3434
visibility = ["PUBLIC"],
3535
)
3636

37-
platform(
37+
execution_platform(
3838
name = "compiler-build-script",
3939
base = ":compiler",
4040
constraint_values = [

platforms/stage2/BUCK

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
load("//platforms:defs.bzl", "platform")
1+
load("//platforms:defs.bzl", "execution_platform", "target_platform")
22

3-
platform(
3+
target_platform(
44
name = "library",
55
base = "//platforms:host",
66
constraint_values = [
@@ -12,7 +12,7 @@ platform(
1212
visibility = ["PUBLIC"],
1313
)
1414

15-
platform(
15+
execution_platform(
1616
name = "library-build-script",
1717
base = ":library",
1818
constraint_values = [
@@ -22,7 +22,7 @@ platform(
2222
visibility = ["PUBLIC"],
2323
)
2424

25-
platform(
25+
target_platform(
2626
name = "compiler",
2727
base = "//platforms:host",
2828
constraint_values = [
@@ -34,7 +34,7 @@ platform(
3434
visibility = ["PUBLIC"],
3535
)
3636

37-
platform(
37+
execution_platform(
3838
name = "compiler-build-script",
3939
base = ":compiler",
4040
constraint_values = [

0 commit comments

Comments
 (0)