@@ -141,6 +141,7 @@ def collect_deps(
141
141
transitive_crates = []
142
142
transitive_noncrates = []
143
143
transitive_build_infos = []
144
+ transitive_link_search_paths = []
144
145
build_info = None
145
146
linkstamps = []
146
147
transitive_crate_outputs = []
@@ -175,6 +176,8 @@ def collect_deps(
175
176
)
176
177
transitive_noncrates .append (dep_info .transitive_noncrates )
177
178
transitive_build_infos .append (dep_info .transitive_build_infos )
179
+ transitive_link_search_paths .append (dep_info .link_search_path_files )
180
+
178
181
elif cc_info :
179
182
# This dependency is a cc_library
180
183
transitive_noncrates .append (cc_info .linking_context .linker_inputs )
@@ -184,6 +187,7 @@ def collect_deps(
184
187
"only one is allowed in the dependencies" )
185
188
build_info = dep_build_info
186
189
transitive_build_infos .append (depset ([build_info ]))
190
+ transitive_link_search_paths .append (depset ([build_info .link_search_paths ]))
187
191
else :
188
192
fail ("rust targets can only depend on rust_library, rust_*_library or cc_library " +
189
193
"targets." )
@@ -200,6 +204,7 @@ def collect_deps(
200
204
),
201
205
transitive_crate_outputs = depset (transitive = transitive_crate_outputs ),
202
206
transitive_build_infos = depset (transitive = transitive_build_infos ),
207
+ link_search_path_files = depset (transitive = transitive_link_search_paths ),
203
208
dep_env = build_info .dep_env if build_info else None ,
204
209
),
205
210
build_info ,
@@ -298,23 +303,24 @@ def get_linker_and_args(ctx, attr, cc_toolchain, feature_configuration, rpaths):
298
303
299
304
def _process_build_scripts (
300
305
build_info ,
306
+ dep_info ,
301
307
compile_inputs ):
302
308
"""Gathers the outputs from a target's `cargo_build_script` action.
303
309
304
310
Args:
305
311
build_info (BuildInfo): The target Build's dependency info.
312
+ dep_info (DepInfo): The Depinfo provider form the target Crate's set of inputs.
306
313
compile_inputs (depset): A set of all files that will participate in the build.
307
314
308
315
Returns:
309
316
tuple: A tuple: A tuple of the following items:
310
- - (list ): A list of all build info `OUT_DIR` File objects
317
+ - (depset[File] ): A list of all build info `OUT_DIR` File objects
311
318
- (str): The `OUT_DIR` of the current build info
312
319
- (File): An optional path to a generated environment file from a `cargo_build_script` target
313
- - (list ): All direct and transitive build flags from the current build info.
320
+ - (depset[File] ): All direct and transitive build flags from the current build info.
314
321
"""
315
- extra_inputs , out_dir , build_env_file , build_flags_files = _create_extra_input_args (build_info )
316
- if extra_inputs :
317
- compile_inputs = depset (extra_inputs , transitive = [compile_inputs ])
322
+ extra_inputs , out_dir , build_env_file , build_flags_files = _create_extra_input_args (build_info , dep_info )
323
+ compile_inputs = depset (transitive = [extra_inputs , compile_inputs ])
318
324
return compile_inputs , out_dir , build_env_file , build_flags_files
319
325
320
326
def collect_inputs (
@@ -350,7 +356,7 @@ def collect_inputs(
350
356
- (list): A list of all build info `OUT_DIR` File objects
351
357
- (str): The `OUT_DIR` of the current build info
352
358
- (File): An optional path to a generated environment file from a `cargo_build_script` target
353
- - (list ): All direct and transitive build flags from the current build info
359
+ - (depset[File] ): All direct and transitive build flag files from the current build info
354
360
- (list[File]): Linkstamp outputs.
355
361
"""
356
362
linker_script = getattr (file , "linker_script" ) if hasattr (file , "linker_script" ) else None
@@ -432,7 +438,7 @@ def collect_inputs(
432
438
)
433
439
434
440
build_env_files = getattr (files , "rustc_env_files" , [])
435
- compile_inputs , out_dir , build_env_file , build_flags_files = _process_build_scripts (build_info , compile_inputs )
441
+ compile_inputs , out_dir , build_env_file , build_flags_files = _process_build_scripts (build_info , dep_info , compile_inputs )
436
442
if build_env_file :
437
443
build_env_files = [f for f in build_env_files ] + [build_env_file ]
438
444
compile_inputs = depset (build_env_files , transitive = [compile_inputs ])
@@ -477,7 +483,7 @@ def construct_arguments(
477
483
rust_flags (list): Additional flags to pass to rustc
478
484
out_dir (str): The path to the output directory for the target Crate.
479
485
build_env_files (list): Files containing rustc environment variables, for instance from `cargo_build_script` actions.
480
- build_flags_files (list ): The output files of a `cargo_build_script` actions containing rustc build flags
486
+ build_flags_files (depset ): The output files of a `cargo_build_script` actions containing rustc build flags
481
487
emit (list): Values for the --emit flag to rustc.
482
488
force_all_deps_direct (bool, optional): Whether to pass the transitive rlibs with --extern
483
489
to the commandline as opposed to -L.
@@ -925,18 +931,19 @@ def add_edition_flags(args, crate):
925
931
if crate .edition != "2015" :
926
932
args .add ("--edition={}" .format (crate .edition ))
927
933
928
- def _create_extra_input_args (build_info ):
934
+ def _create_extra_input_args (build_info , dep_info ):
929
935
"""Gather additional input arguments from transitive dependencies
930
936
931
937
Args:
932
938
build_info (BuildInfo): The BuildInfo provider from the target Crate's set of inputs.
939
+ dep_info (DepInfo): The Depinfo provider form the target Crate's set of inputs.
933
940
934
941
Returns:
935
942
tuple: A tuple of the following items:
936
- - (list ): A list of all build info `OUT_DIR` File objects
943
+ - (depset[File] ): A list of all build info `OUT_DIR` File objects
937
944
- (str): The `OUT_DIR` of the current build info
938
945
- (File): An optional generated environment file from a `cargo_build_script` target
939
- - (list ): All direct and transitive build flags from the current build info.
946
+ - (depset[File] ): All direct and transitive build flag files from the current build info.
940
947
"""
941
948
input_files = []
942
949
@@ -949,12 +956,17 @@ def _create_extra_input_args(build_info):
949
956
if build_info :
950
957
out_dir = build_info .out_dir .path
951
958
build_env_file = build_info .rustc_env
952
- build_flags_files .append (build_info .flags . path )
953
- build_flags_files .append (build_info .link_flags . path )
959
+ build_flags_files .append (build_info .flags )
960
+ build_flags_files .append (build_info .link_flags )
954
961
input_files .append (build_info .out_dir )
955
962
input_files .append (build_info .link_flags )
956
963
957
- return input_files , out_dir , build_env_file , build_flags_files
964
+ return (
965
+ depset (input_files , transitive = [dep_info .link_search_path_files ]),
966
+ out_dir ,
967
+ build_env_file ,
968
+ depset (build_flags_files , transitive = [dep_info .link_search_path_files ]),
969
+ )
958
970
959
971
def _compute_rpaths (toolchain , output_dir , dep_info ):
960
972
"""Determine the artifact's rpaths relative to the bazel root for runtime linking of shared libraries.
0 commit comments