File tree Expand file tree Collapse file tree 5 files changed +22
-2
lines changed
Expand file tree Collapse file tree 5 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 9393rust_test (
9494 name = "unit_test" ,
9595 aliases = aliases (),
96+ compile_data = glob (["test_data/**" ]),
9697 crate = ":cargo_bazel" ,
9798 data = glob (["test_data/**" ]) + [
9899 "//crate_universe/test_data/serialized_configs" ,
Original file line number Diff line number Diff line change @@ -715,8 +715,14 @@ def collect_inputs(
715715 if build_info .flags :
716716 build_info_inputs .append (build_info .flags )
717717
718+ # The old default behavior was to include data files at compile time.
719+ # This flag controls whether to include data files in compile_data.
720+ data_included_in_inputs = []
721+ if not toolchain ._incompatible_do_not_include_data_in_compile_data :
722+ data_included_in_inputs = getattr (files , "data" , [])
723+
718724 nolinkstamp_compile_inputs = depset (
719- getattr ( files , "data" , []) +
725+ data_included_in_inputs +
720726 build_info_inputs +
721727 ([toolchain .target_json ] if toolchain .target_json else []) +
722728 ([] if linker_script == None else [linker_script ]),
Original file line number Diff line number Diff line change @@ -253,3 +253,11 @@ per_crate_rustc_flag(
253253 build_setting_default = [],
254254 visibility = ["//visibility:public" ],
255255)
256+
257+ # A flag to control whether to include data files in compile_data.
258+ incompatible_flag (
259+ name = "incompatible_do_not_include_data_in_compile_data" ,
260+ build_setting_default = False ,
261+ issue = "https://github.com/bazelbuild/rules_rust/issues/2977" ,
262+ visibility = ["//visibility:public" ],
263+ )
Original file line number Diff line number Diff line change @@ -699,6 +699,7 @@ def _rust_toolchain_impl(ctx):
699699 _experimental_use_coverage_metadata_files = ctx .attr ._experimental_use_coverage_metadata_files [BuildSettingInfo ].value ,
700700 _incompatible_change_rust_test_compilation_output_directory = ctx .attr ._incompatible_change_rust_test_compilation_output_directory [IncompatibleFlagInfo ].enabled ,
701701 _toolchain_generated_sysroot = ctx .attr ._toolchain_generated_sysroot [BuildSettingInfo ].value ,
702+ _incompatible_do_not_include_data_in_compile_data = ctx .attr ._incompatible_do_not_include_data_in_compile_data [IncompatibleFlagInfo ].enabled ,
702703 _no_std = no_std ,
703704 )
704705 return [
@@ -905,6 +906,10 @@ rust_toolchain = rule(
905906 "This flag is only relevant when used together with --@rules_rust//rust/settings:toolchain_generated_sysroot."
906907 ),
907908 ),
909+ "_incompatible_do_not_include_data_in_compile_data" : attr .label (
910+ default = Label ("//rust/settings:incompatible_do_not_include_data_in_compile_data" ),
911+ doc = "Label to a boolean build setting that controls whether to include data files in compile_data." ,
912+ ),
908913 },
909914 toolchains = [
910915 "@bazel_tools//tools/cpp:toolchain_type" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ package(default_visibility = ["//visibility:public"])
99rust_test (
1010 name = "conflicting_deps_test" ,
1111 srcs = ["tests/manifest_dir.rs" ],
12- data = ["src/manifest_dir_file.txt" ],
12+ compile_data = ["src/manifest_dir_file.txt" ],
1313 edition = "2018" ,
1414)
1515
You can’t perform that action at this time.
0 commit comments