@@ -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)
0 commit comments