@@ -372,28 +372,18 @@ def _cargo_build_script_impl(ctx):
372372 if not workspace_name :
373373 workspace_name = ctx .workspace_name
374374
375- extra_args = []
376- extra_inputs = []
377375 extra_output = []
378376
379377 # Relying on runfiles directories is unreliable when passing data to
380378 # dependent actions. Instead, an explicit directory should be created
381379 # until more reliable functionality is implemented in Bazel:
382380 # https://github.com/bazelbuild/bazel/issues/15486
383- incompatible_runfiles_cargo_manifest_dir = ctx .attr ._incompatible_runfiles_cargo_manifest_dir [BuildSettingInfo ].value
384- if not incompatible_runfiles_cargo_manifest_dir :
385- script_data .append (ctx .attr .script [DefaultInfo ].default_runfiles .files )
386- manifest_dir = "{}.runfiles/{}/{}" .format (script .path , workspace_name , ctx .label .package )
387- else :
388- runfiles_dir , runfiles_inputs , runfiles_args = _create_runfiles_dir (
389- ctx = ctx ,
390- script = ctx .attr .script ,
391- retain_list = ctx .attr ._cargo_manifest_dir_filename_suffixes_to_retain [BuildSettingInfo ].value ,
392- )
393- manifest_dir = "{}/{}/{}" .format (runfiles_dir .path , workspace_name , ctx .label .package )
394- extra_args .append (runfiles_args )
395- extra_inputs .append (runfiles_inputs )
396- extra_output = [runfiles_dir ]
381+ runfiles_dir , runfiles_inputs , runfiles_args = _create_runfiles_dir (
382+ ctx = ctx ,
383+ script = ctx .attr .script ,
384+ retain_list = ctx .attr ._cargo_manifest_dir_filename_suffixes_to_retain [BuildSettingInfo ].value ,
385+ )
386+ manifest_dir = "{}/{}/{}" .format (runfiles_dir .path , workspace_name , ctx .label .package )
397387
398388 pkg_name = ctx .attr .pkg_name
399389 if pkg_name == "" :
@@ -635,17 +625,18 @@ def _cargo_build_script_impl(ctx):
635625
636626 ctx .actions .run (
637627 executable = ctx .executable ._cargo_build_script_runner ,
638- arguments = [args ] + extra_args ,
628+ arguments = [args , runfiles_args ] ,
639629 outputs = [
640630 out_dir ,
641631 env_out ,
642632 flags_out ,
643633 link_flags ,
644634 link_search_paths ,
645635 dep_env_out ,
636+ runfiles_dir ,
646637 ] + extra_output ,
647638 tools = tools ,
648- inputs = depset (build_script_inputs , transitive = extra_inputs ),
639+ inputs = depset (build_script_inputs , transitive = [ runfiles_inputs ] ),
649640 mnemonic = "CargoBuildScriptRun" ,
650641 progress_message = "Running Cargo build script {}" .format (pkg_name ),
651642 env = env ,
@@ -665,7 +656,7 @@ def _cargo_build_script_impl(ctx):
665656 flags = flags_out ,
666657 linker_flags = link_flags ,
667658 link_search_paths = link_search_paths ,
668- compile_data = depset (extra_output , transitive = script_data ),
659+ compile_data = depset ([ runfiles_dir ] + extra_output , transitive = script_data ),
669660 ),
670661 OutputGroupInfo (
671662 ** output_groups
@@ -805,9 +796,6 @@ cargo_build_script = rule(
805796 allow_files = True ,
806797 default = Label ("//cargo/private:no_cxx" ),
807798 ),
808- "_incompatible_runfiles_cargo_manifest_dir" : attr .label (
809- default = Label ("//cargo/settings:incompatible_runfiles_cargo_manifest_dir" ),
810- ),
811799 },
812800 fragments = ["cpp" ],
813801 toolchains = [
0 commit comments