@@ -51,7 +51,7 @@ def _build_feature_configuration(common_variables):
5151 unsupported_features = disabled_features ,
5252 )
5353
54- def _build_fully_linked_variable_extensions (archive , libs ):
54+ def _build_fully_linked_variable_extensions (* , archive , libs ):
5555 extensions = {}
5656 extensions ["fully_linked_archive_path" ] = archive .path
5757 extensions ["objc_library_exec_paths" ] = [lib .path for lib in libs ]
@@ -81,7 +81,7 @@ def _get_libraries_for_linking(libraries_to_link):
8181 libraries .append (_get_library_for_linking (library_to_link ))
8282 return libraries
8383
84- def _register_fully_link_action (name , common_variables , cc_linking_context ):
84+ def _register_fully_link_action (* , cc_linking_context , common_variables , name ):
8585 ctx = common_variables .ctx
8686 feature_configuration = _build_feature_configuration (common_variables )
8787
@@ -90,28 +90,29 @@ def _register_fully_link_action(name, common_variables, cc_linking_context):
9090
9191 output_archive = ctx .actions .declare_file (name + ".a" )
9292 extensions = _build_fully_linked_variable_extensions (
93- output_archive ,
94- libraries ,
93+ archive = output_archive ,
94+ libs = libraries ,
9595 )
9696
9797 return cc_common .link (
98- name = name ,
9998 actions = ctx .actions ,
100- feature_configuration = feature_configuration ,
99+ additional_inputs = libraries ,
101100 cc_toolchain = common_variables .toolchain ,
101+ feature_configuration = feature_configuration ,
102102 language = "objc" ,
103- additional_inputs = libraries ,
103+ name = name ,
104104 output_type = "archive" ,
105105 variables_extension = extensions ,
106106 )
107107
108108def _register_binary_strip_action (
109+ * ,
109110 ctx ,
110- name ,
111+ apple_platform_info ,
111112 binary ,
113+ extra_link_args ,
112114 feature_configuration ,
113- build_config ,
114- extra_link_args ):
115+ name ):
115116 """
116117 Registers an action that uses the 'strip' tool to perform binary stripping on the given binary.
117118 """
@@ -134,7 +135,7 @@ def _register_binary_strip_action(
134135 # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact().
135136 stripped_binary = ctx .actions .declare_shareable_artifact (
136137 paths .join (ctx .label .package , name ),
137- build_config .bin_dir ,
138+ apple_platform_info . target_build_config .bin_dir ,
138139 )
139140 args = ctx .actions .args ()
140141 args .add ("strip" )
@@ -144,18 +145,18 @@ def _register_binary_strip_action(
144145 args .add (binary )
145146 xcode_config = ctx .attr ._xcode_config [apple_common .XcodeVersionConfig ]
146147 apple_common_platform = platform_support .apple_common_platform_from_platform_info (
147- apple_platform_info = platform_support . apple_platform_info_from_rule_ctx ( ctx ) ,
148+ apple_platform_info = apple_platform_info ,
148149 )
149150
150151 ctx .actions .run (
151- mnemonic = "ObjcBinarySymbolStrip" ,
152- executable = "/usr/bin/xcrun" ,
153152 arguments = [args ],
154- inputs = [binary ],
155- outputs = [stripped_binary ],
156- execution_requirements = xcode_config .execution_info (),
157153 env = apple_common .apple_host_system_env (xcode_config ) |
158154 apple_common .target_apple_env (xcode_config , apple_common_platform ),
155+ executable = "/usr/bin/xcrun" ,
156+ execution_requirements = xcode_config .execution_info (),
157+ inputs = [binary ],
158+ mnemonic = "ObjcBinarySymbolStrip" ,
159+ outputs = [stripped_binary ],
159160 )
160161 return stripped_binary
161162
@@ -167,16 +168,17 @@ def _emit_builtin_objc_strip_action(ctx):
167168 )
168169
169170def _register_configuration_specific_link_actions (
170- name ,
171+ * ,
172+ additional_outputs ,
173+ apple_platform_info ,
174+ attr_linkopts ,
171175 common_variables ,
172176 cc_linking_context ,
173- build_config ,
174177 extra_link_args ,
175- stamp ,
176- user_variable_extensions ,
177- additional_outputs ,
178178 extra_link_inputs ,
179- attr_linkopts ):
179+ name ,
180+ stamp ,
181+ user_variable_extensions ):
180182 """
181183 Registers actions to link a single-platform/architecture Apple binary in a specific config.
182184
@@ -198,75 +200,45 @@ def _register_configuration_specific_link_actions(
198200 # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact().
199201 binary = ctx .actions .declare_shareable_artifact (
200202 paths .join (ctx .label .package , name + "_unstripped" ),
201- build_config .bin_dir ,
203+ apple_platform_info . target_build_config .bin_dir ,
202204 )
203205 else :
204206 # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact().
205207 binary = ctx .actions .declare_shareable_artifact (
206208 paths .join (ctx .label .package , name ),
207- build_config .bin_dir ,
209+ apple_platform_info . target_build_config .bin_dir ,
208210 )
209211
210- return _register_configuration_specific_link_actions_with_cpp_variables (
211- name ,
212- binary ,
213- common_variables ,
214- feature_configuration ,
215- cc_linking_context ,
216- build_config ,
217- extra_link_args ,
218- stamp ,
219- user_variable_extensions ,
220- additional_outputs ,
221- extra_link_inputs ,
222- attr_linkopts ,
223- )
224-
225- def _register_configuration_specific_link_actions_with_cpp_variables (
226- name ,
227- binary ,
228- common_variables ,
229- feature_configuration ,
230- cc_linking_context ,
231- build_config ,
232- extra_link_args ,
233- stamp ,
234- user_variable_extensions ,
235- additional_outputs ,
236- extra_link_inputs ,
237- attr_linkopts ):
238- ctx = common_variables .ctx
239-
240212 prefixed_attr_linkopts = [
241213 "-Wl,%s" % linkopt
242214 for linkopt in attr_linkopts
243215 ]
244216
245217 seen_flags = {}
246218 (_ , user_link_flags , seen_flags ) = _dedup_link_flags (
247- extra_link_args + prefixed_attr_linkopts ,
248- seen_flags ,
219+ flags = extra_link_args + prefixed_attr_linkopts ,
220+ seen_flags = seen_flags ,
249221 )
250- ( cc_linking_context , _ ) = _create_deduped_linkopts_linking_context (
251- ctx . label ,
252- cc_linking_context ,
253- seen_flags ,
222+ cc_linking_context = _create_deduped_linkopts_linking_context (
223+ cc_linking_context = cc_linking_context ,
224+ owner = ctx . label ,
225+ seen_flags = seen_flags ,
254226 )
255227
256228 cc_common .link (
257- name = name ,
258229 actions = ctx .actions ,
259230 additional_inputs = (
260231 extra_link_inputs +
261232 getattr (ctx .files , "additional_linker_inputs" , [])
262233 ),
263234 additional_outputs = additional_outputs ,
264- build_config = build_config ,
235+ build_config = apple_platform_info . target_build_config ,
265236 cc_toolchain = common_variables .toolchain ,
266237 feature_configuration = feature_configuration ,
267238 language = "objc" ,
268239 linking_contexts = [cc_linking_context ],
269240 main_output = binary ,
241+ name = name ,
270242 output_type = "executable" ,
271243 stamp = stamp ,
272244 user_link_flags = user_link_flags ,
@@ -275,17 +247,17 @@ def _register_configuration_specific_link_actions_with_cpp_variables(
275247
276248 if _emit_builtin_objc_strip_action (ctx ):
277249 return _register_binary_strip_action (
278- ctx ,
279- name ,
280- binary ,
281- feature_configuration ,
282- build_config ,
283- extra_link_args ,
250+ ctx = ctx ,
251+ apple_platform_info = apple_platform_info ,
252+ binary = binary ,
253+ extra_link_args = extra_link_args ,
254+ feature_configuration = feature_configuration ,
255+ name = name ,
284256 )
285257 else :
286258 return binary
287259
288- def _dedup_link_flags (flags , seen_flags = {}):
260+ def _dedup_link_flags (* , flags , seen_flags = {}):
289261 new_flags = []
290262 previous_arg = None
291263 for arg in flags :
@@ -324,35 +296,30 @@ def _dedup_link_flags(flags, seen_flags = {}):
324296
325297 return (same , new_flags , seen_flags )
326298
327- def _create_deduped_linkopts_linking_context (owner , cc_linking_context , seen_flags ):
299+ def _create_deduped_linkopts_linking_context (* , cc_linking_context , owner , seen_flags ):
328300 linker_inputs = []
329301 for linker_input in cc_linking_context .linker_inputs .to_list ():
330302 (same , new_flags , seen_flags ) = _dedup_link_flags (
331- linker_input .user_link_flags ,
332- seen_flags ,
303+ flags = linker_input .user_link_flags ,
304+ seen_flags = seen_flags ,
333305 )
334306 if same :
335307 linker_inputs .append (linker_input )
336308 else :
337309 linker_inputs .append (cc_common .create_linker_input (
338- owner = linker_input .owner ,
310+ additional_inputs = depset ( linker_input .additional_inputs ) ,
339311 libraries = depset (linker_input .libraries ),
312+ owner = linker_input .owner ,
340313 user_link_flags = new_flags ,
341- additional_inputs = depset (linker_input .additional_inputs ),
342314 ))
343315
344316 # Why does linker_input not expose linkstamp? This needs to be fixed.
345317 linker_inputs .append (cc_common .create_linker_input (
346- owner = owner ,
347318 linkstamps = cc_linking_context .linkstamps (),
319+ owner = owner ,
348320 ))
349321
350- return (
351- cc_common .create_linking_context (
352- linker_inputs = depset (linker_inputs ),
353- ),
354- seen_flags ,
355- )
322+ return cc_common .create_linking_context (linker_inputs = depset (linker_inputs ))
356323
357324compilation_support = struct (
358325 # TODO(b/331163513): Move apple_common.compliation_support.build_common_variables here, too.
0 commit comments