1414
1515"""IBTool related actions."""
1616
17- load (
18- "@bazel_skylib//lib:collections.bzl" ,
19- "collections" ,
20- )
2117load (
2218 "@bazel_skylib//lib:paths.bzl" ,
2319 "paths" ,
3127 xctoolrunner_support = "xctoolrunner" ,
3228)
3329
34- def _ibtool_arguments (min_os , families ):
35- """Returns common `ibtool` command line arguments.
36-
37- This function returns the common arguments used by both xib and storyboard
38- compilation, as well as storyboard linking. Callers should add their own
39- arguments to the returned array for their specific purposes.
40-
41- Args:
42- min_os: The minimum OS version to use when compiling interface files.
43- families: The families that should be supported by the compiled interfaces.
44-
45- Returns:
46- An array of command-line arguments to pass to ibtool.
47- """
48- return [
49- "--minimum-deployment-target" ,
50- min_os ,
51- ] + collections .before_each (
52- "--target-device" ,
53- families ,
54- )
55-
5630def compile_storyboard (
5731 * ,
5832 actions ,
@@ -73,7 +47,8 @@ def compile_storyboard(
7347 xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool.
7448 """
7549
76- args = [
50+ args = actions .args ()
51+ args .add_all ([
7752 "ibtool" ,
7853 "--compilation-directory" ,
7954 xctoolrunner_support .prefixed_path (output_dir .dirname ),
@@ -83,20 +58,24 @@ def compile_storyboard(
8358 "--auto-activate-custom-fonts" ,
8459 "--output-format" ,
8560 "human-readable-text" ,
86- ]
61+ ])
8762
8863 min_os = platform_prerequisites .minimum_os
8964 families = platform_prerequisites .device_families
90- args .extend (_ibtool_arguments (min_os , families ))
91- args .extend ([
65+
66+ # Standard ibtool options.
67+ args .add ("--minimum-deployment-target" , min_os )
68+ args .add_all (families , before_each = "--target-device" )
69+
70+ args .add_all ([
9271 "--module" ,
9372 swift_module ,
9473 xctoolrunner_support .prefixed_path (input_file .path ),
9574 ])
9675
9776 apple_support .run (
9877 actions = actions ,
99- arguments = args ,
78+ arguments = [ args ] ,
10079 apple_fragment = platform_prerequisites .apple_fragment ,
10180 executable = xctoolrunner ,
10281 execution_requirements = {"no-sandbox" : "1" },
@@ -131,20 +110,25 @@ def link_storyboards(
131110 min_os = platform_prerequisites .minimum_os
132111 families = platform_prerequisites .device_families
133112
134- args = [
113+ args = actions .args ()
114+ args .add_all ([
135115 "ibtool" ,
136116 "--link" ,
137117 xctoolrunner_support .prefixed_path (output_dir .path ),
138- ]
139- args .extend (_ibtool_arguments (min_os , families ))
140- args .extend ([
118+ ])
119+
120+ # Standard ibtool options.
121+ args .add ("--minimum-deployment-target" , min_os )
122+ args .add_all (families , before_each = "--target-device" )
123+
124+ args .add_all ([
141125 xctoolrunner_support .prefixed_path (f .path )
142126 for f in storyboardc_dirs
143127 ])
144128
145129 apple_support .run (
146130 actions = actions ,
147- arguments = args ,
131+ arguments = [ args ] ,
148132 apple_fragment = platform_prerequisites .apple_fragment ,
149133 executable = xctoolrunner ,
150134 execution_requirements = {"no-sandbox" : "1" },
@@ -179,21 +163,26 @@ def compile_xib(
179163
180164 nib_name = paths .replace_extension (paths .basename (input_file .short_path ), ".nib" )
181165
182- args = [
166+ args = actions .args ()
167+ args .add_all ([
183168 "ibtool" ,
184169 "--compile" ,
185170 xctoolrunner_support .prefixed_path (paths .join (output_dir .path , nib_name )),
186- ]
187- args .extend (_ibtool_arguments (min_os , families ))
188- args .extend ([
171+ ])
172+
173+ # Standard ibtool options.
174+ args .add ("--minimum-deployment-target" , min_os )
175+ args .add_all (families , before_each = "--target-device" )
176+
177+ args .add_all ([
189178 "--module" ,
190179 swift_module ,
191180 xctoolrunner_support .prefixed_path (input_file .path ),
192181 ])
193182
194183 apple_support .run (
195184 actions = actions ,
196- arguments = args ,
185+ arguments = [ args ] ,
197186 apple_fragment = platform_prerequisites .apple_fragment ,
198187 executable = xctoolrunner ,
199188 execution_requirements = {"no-sandbox" : "1" },
0 commit comments