@@ -239,16 +239,28 @@ def collect_deps(
239239 linkstamps (depset[CcLinkstamp]): A depset of CcLinkstamps that need to be compiled and linked into all linked binaries when applicable.
240240
241241 """
242+ direct_deps = []
243+
242244 direct_crates = []
243245 transitive_crates = []
246+
244247 transitive_data = []
245248 transitive_proc_macro_data = []
246249 transitive_noncrates = []
250+
251+ direct_build_infos = []
247252 transitive_build_infos = []
253+
254+ direct_link_search_paths = []
248255 transitive_link_search_paths = []
256+
249257 build_info = None
250258 linkstamps = []
259+
260+ direct_crate_outputs = []
251261 transitive_crate_outputs = []
262+
263+ direct_metadata_outputs = []
252264 transitive_metadata_outputs = []
253265
254266 crate_deps = []
@@ -287,18 +299,16 @@ def collect_deps(
287299 # label from dep.label
288300 owner = getattr (crate_info , "owner" , dep .label if type (dep ) == "Target" else None )
289301
290- direct_crates .append (AliasableDepInfo (
302+ direct_deps .append (AliasableDepInfo (
291303 name = aliases .get (owner , crate_info .name ),
292304 dep = crate_info ,
293305 ))
294306
295307 is_proc_macro = _is_proc_macro (crate_info )
296- transitive_crates .append (
297- depset (
298- [crate_info ],
299- transitive = [] if is_proc_macro else [dep_info .transitive_crates ],
300- ),
301- )
308+
309+ direct_crates .append (crate_info )
310+ if not is_proc_macro :
311+ transitive_crates .append (dep_info .transitive_crates )
302312
303313 if is_proc_macro :
304314 # This crate's data and its non-macro dependencies' data are proc macro data.
@@ -322,19 +332,13 @@ def collect_deps(
322332 # If this dependency is a proc_macro, it still can be used for lib crates
323333 # that produce metadata.
324334 # In that case, we don't depend on its metadata dependencies.
325- transitive_metadata_outputs .append (
326- depset (
327- [depend_on ],
328- transitive = [] if is_proc_macro else [dep_info .transitive_metadata_outputs ],
329- ),
330- )
335+ direct_metadata_outputs .append (depend_on )
336+ if not is_proc_macro :
337+ transitive_metadata_outputs .append (dep_info .transitive_metadata_outputs )
331338
332- transitive_crate_outputs .append (
333- depset (
334- [crate_info .output ],
335- transitive = [] if is_proc_macro else [dep_info .transitive_crate_outputs ],
336- ),
337- )
339+ direct_crate_outputs .append (crate_info .output )
340+ if not is_proc_macro :
341+ transitive_crate_outputs .append (dep_info .transitive_crate_outputs )
338342
339343 if not is_proc_macro :
340344 transitive_noncrates .append (dep_info .transitive_noncrates )
@@ -351,32 +355,47 @@ def collect_deps(
351355 fail ("Several deps are providing build information, " +
352356 "only one is allowed in the dependencies" )
353357 build_info = dep_build_info
354- transitive_build_infos .append (depset ([ build_info ]) )
358+ direct_build_infos .append (build_info )
355359 if build_info .link_search_paths :
356- transitive_link_search_paths .append (depset ([ build_info .link_search_paths ]) )
360+ direct_link_search_paths .append (build_info .link_search_paths )
357361 transitive_data .append (build_info .compile_data )
358362 else :
359363 fail ("rust targets can only depend on rust_library, rust_*_library or cc_library " +
360364 "targets." )
361365
362- transitive_crates_depset = depset (transitive = transitive_crates )
363- transitive_data_depset = depset (transitive = transitive_data )
364- transitive_proc_macro_data_depset = depset (transitive = transitive_proc_macro_data )
365-
366366 return (
367367 rust_common .dep_info (
368- direct_crates = depset (direct_crates ),
369- transitive_crates = transitive_crates_depset ,
370- transitive_data = transitive_data_depset ,
371- transitive_proc_macro_data = transitive_proc_macro_data_depset ,
368+ direct_crates = depset (direct_deps ),
369+ transitive_crates = depset (
370+ direct_crates ,
371+ transitive = transitive_crates ,
372+ ),
373+ transitive_data = depset (
374+ transitive = transitive_data ,
375+ ),
376+ transitive_proc_macro_data = depset (
377+ transitive = transitive_proc_macro_data ,
378+ ),
372379 transitive_noncrates = depset (
373380 transitive = transitive_noncrates ,
374381 order = "topological" , # dylib link flag ordering matters.
375382 ),
376- transitive_crate_outputs = depset (transitive = transitive_crate_outputs ),
377- transitive_metadata_outputs = depset (transitive = transitive_metadata_outputs ),
378- transitive_build_infos = depset (transitive = transitive_build_infos ),
379- link_search_path_files = depset (transitive = transitive_link_search_paths ),
383+ transitive_crate_outputs = depset (
384+ direct_crate_outputs ,
385+ transitive = transitive_crate_outputs ,
386+ ),
387+ transitive_metadata_outputs = depset (
388+ direct_metadata_outputs ,
389+ transitive = transitive_metadata_outputs ,
390+ ),
391+ transitive_build_infos = depset (
392+ direct_build_infos ,
393+ transitive = transitive_build_infos ,
394+ ),
395+ link_search_path_files = depset (
396+ direct_link_search_paths ,
397+ transitive = transitive_link_search_paths ,
398+ ),
380399 dep_env = build_info .dep_env if build_info else None ,
381400 ),
382401 build_info ,
0 commit comments