@@ -44,32 +44,45 @@ def _platform_impl(ctx: AnalysisContext) -> list[Provider]:
44
44
label = str (platform_label ),
45
45
configuration = configuration ,
46
46
),
47
- ExecutionPlatformInfo (
47
+ TransitionInfo (impl = transition_impl ),
48
+ ] + (
49
+ [ExecutionPlatformInfo (
48
50
label = platform_label ,
49
51
configuration = configuration ,
50
52
executor_config = CommandExecutorConfig (
51
53
local_enabled = True ,
52
54
remote_enabled = False ,
53
55
use_windows_path_separators = use_windows_path_separators ,
54
56
),
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
+ }
58
73
59
- platform = rule (
74
+ target_platform = rule (
60
75
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 )),
73
86
},
74
87
is_configuration_rule = True ,
75
88
)
0 commit comments