1+ """Implementation of the `custom_toolchain` rule."""
12
23def _get_xcode_product_version (* , xcode_config ):
34 raw_version = str (xcode_config .xcode_version ())
@@ -14,15 +15,14 @@ def _get_xcode_product_version(*, xcode_config):
1415
1516 return version_components [3 ]
1617
17-
1818def _custom_toolchain_impl (ctx ):
1919 xcode_version = _get_xcode_product_version (
2020 xcode_config = ctx .attr ._xcode_config [apple_common .XcodeVersionConfig ],
2121 )
2222
2323 toolchain_name_base = ctx .attr .toolchain_name
2424 toolchain_dir = ctx .actions .declare_directory (
25- toolchain_name_base + ".{}" .format (xcode_version ) + ".xctoolchain"
25+ toolchain_name_base + ".{}" .format (xcode_version ) + ".xctoolchain" ,
2626 )
2727
2828 resolved_overrides = {}
@@ -35,7 +35,9 @@ def _custom_toolchain_impl(ctx):
3535
3636 if len (files ) > 1 :
3737 fail ("ERROR: Override for '{}' produces multiple files ({}). Each override must have exactly one file." .format (
38- tool_name , len (files )))
38+ tool_name ,
39+ len (files ),
40+ ))
3941
4042 override_file = files [0 ]
4143 override_files .append (override_file )
@@ -50,9 +52,9 @@ def _custom_toolchain_impl(ctx):
5052 output = script_file ,
5153 is_executable = True ,
5254 substitutions = {
53- "%toolchain_name_base%" : toolchain_name_base ,
54- "%toolchain_dir%" : toolchain_dir .path ,
5555 "%overrides_list%" : overrides_list ,
56+ "%toolchain_dir%" : toolchain_dir .path ,
57+ "%toolchain_name_base%" : toolchain_name_base ,
5658 "%xcode_version%" : xcode_version ,
5759 },
5860 )
@@ -64,9 +66,9 @@ def _custom_toolchain_impl(ctx):
6466 mnemonic = "CreateCustomToolchain" ,
6567 command = script_file .path ,
6668 execution_requirements = {
67- "no-sandbox" : "1" ,
68- "no-cache" : "1" ,
6969 "local" : "1" ,
70+ "no-cache" : "1" ,
71+ "no-sandbox" : "1" ,
7072 "requires-darwin" : "1" ,
7173 },
7274 use_default_shell_env = True ,
@@ -83,10 +85,12 @@ def _custom_toolchain_impl(ctx):
8385custom_toolchain = rule (
8486 implementation = _custom_toolchain_impl ,
8587 attrs = {
86- "toolchain_name" : attr .string (mandatory = True ),
8788 "overrides" : attr .label_keyed_string_dict (
88- allow_files = True , mandatory = False , default = {}
89+ allow_files = True ,
90+ mandatory = False ,
91+ default = {},
8992 ),
93+ "toolchain_name" : attr .string (mandatory = True ),
9094 "_symlink_template" : attr .label (
9195 allow_single_file = True ,
9296 default = Label ("//xcodeproj/internal/templates:custom_toolchain_symlink.sh" ),
@@ -99,4 +103,3 @@ custom_toolchain = rule(
99103 ),
100104 },
101105)
102-
0 commit comments