1- load ("@bazel_skylib//rules:diff_test.bzl" , "diff_test" )
21load ("//cargo:defs.bzl" , "cargo_toml_env_vars" )
3- load ("//rust:defs.bzl" , "rust_binary" )
2+ load ("//rust:defs.bzl" , "rust_binary" , "rust_test" )
3+
4+ # TODO: This target currently fails on windows.
5+ NOT_WINDOWS = select ({
6+ "@platforms//os:windows" : ["@platforms//:incompatible" ],
7+ "//conditions:default" : [],
8+ })
49
510genrule (
611 name = "gen_empty_cargo_output" ,
7- srcs = glob (["empty/**" ]),
12+ srcs = glob ([
13+ "empty/**/*.toml" ,
14+ "empty/**/*.rs" ,
15+ ]),
816 outs = ["empty_cargo_output" ],
9- cmd = "RUSTC=$(location //tools/upstream_wrapper:rustc) $(location //tools/upstream_wrapper:cargo) run --manifest-path=cargo/cargo_toml_variable_extractor/testdata/empty/Cargo.toml > $@" ,
17+ cmd = "RUSTC=$(execpath //tools/upstream_wrapper:rustc) $(execpath //tools/upstream_wrapper:cargo) run --manifest-path=cargo/cargo_toml_variable_extractor/testdata/empty/Cargo.toml > $@" ,
18+ cmd_bat = "set RUSTC=$(execpath //tools/upstream_wrapper:rustc) && $(execpath //tools/upstream_wrapper:cargo) run --manifest-path=cargo\\ cargo_toml_variable_extractor\\ testdata\\ empty\\ Cargo.toml > $@" ,
19+ target_compatible_with = NOT_WINDOWS ,
1020 tools = [
1121 "//tools/upstream_wrapper:cargo" ,
1222 "//tools/upstream_wrapper:rustc" ,
@@ -28,21 +38,38 @@ rust_binary(
2838genrule (
2939 name = "gen_empty_bazel_output" ,
3040 outs = ["empty_bazel_output" ],
31- cmd = "$(location :empty_bin) > $@" ,
41+ cmd = "$(execpath :empty_bin) > $@" ,
42+ cmd_bat = "$(execpath :empty_bin) > $@" ,
3243 tools = [":empty_bin" ],
3344)
3445
35- diff_test (
46+ rust_test (
3647 name = "empty_diff_test" ,
37- file1 = ":empty_cargo_output" ,
38- file2 = ":empty_bazel_output" ,
48+ srcs = ["diff_test.rs" ],
49+ data = [
50+ ":empty_bazel_output" ,
51+ ":empty_cargo_output" ,
52+ ],
53+ edition = "2021" ,
54+ env = {
55+ "FILE_1" : "$(rlocationpath :empty_cargo_output)" ,
56+ "FILE_2" : "$(rlocationpath :empty_bazel_output)" ,
57+ },
58+ deps = [
59+ "//rust/runfiles" ,
60+ ],
3961)
4062
4163genrule (
4264 name = "gen_standalone_cargo_output" ,
43- srcs = glob (["standalone/**" ]),
65+ srcs = glob ([
66+ "standalone/**/*.toml" ,
67+ "standalone/**/*.rs" ,
68+ ]),
4469 outs = ["standalone_cargo_output" ],
45- cmd = "RUSTC=$(location //tools/upstream_wrapper:rustc) $(location //tools/upstream_wrapper:cargo) run --manifest-path=cargo/cargo_toml_variable_extractor/testdata/standalone/Cargo.toml > $@" ,
70+ cmd = "RUSTC=$(execpath //tools/upstream_wrapper:rustc) $(execpath //tools/upstream_wrapper:cargo) run --manifest-path=cargo/cargo_toml_variable_extractor/testdata/standalone/Cargo.toml > $@" ,
71+ cmd_bat = "set RUSTC=$(execpath //tools/upstream_wrapper:rustc) && $(execpath //tools/upstream_wrapper:cargo) run --manifest-path=cargo\\ cargo_toml_variable_extractor\\ testdata\\ standalone\\ Cargo.toml > $@" ,
72+ target_compatible_with = NOT_WINDOWS ,
4673 tools = [
4774 "//rust/toolchain:current_rust_stdlib_files" ,
4875 "//tools/upstream_wrapper:cargo" ,
@@ -65,24 +92,42 @@ rust_binary(
6592genrule (
6693 name = "gen_standalone_bazel_output" ,
6794 outs = ["standalone_bazel_output" ],
68- cmd = "$(location :standalone_bin) > $@" ,
95+ cmd = "$(execpath :standalone_bin) > $@" ,
96+ cmd_bat = "$(execpath :standalone_bin) > $@" ,
6997 tools = [":standalone_bin" ],
7098)
7199
72- diff_test (
100+ rust_test (
73101 name = "standalone_diff_test" ,
74- file1 = ":standalone_cargo_output" ,
75- file2 = ":standalone_bazel_output" ,
102+ srcs = ["diff_test.rs" ],
103+ data = [
104+ ":standalone_bazel_output" ,
105+ ":standalone_cargo_output" ,
106+ ],
107+ edition = "2021" ,
108+ env = {
109+ "FILE_1" : "$(rlocationpath :standalone_cargo_output)" ,
110+ "FILE_2" : "$(rlocationpath :standalone_bazel_output)" ,
111+ },
112+ deps = [
113+ "//rust/runfiles" ,
114+ ],
76115)
77116
78117genrule (
79118 name = "gen_workspace_subcrate_cargo_output" ,
80119 srcs = glob (
81- ["workspace/**" ],
120+ include = [
121+ "workspace/**/*.toml" ,
122+ "workspace/**/*.rs" ,
123+ "workspace/**/.gitignore" ,
124+ ],
82125 exclude = ["workspace/target/**" ],
83126 ),
84127 outs = ["workspace_subcrate_cargo_output" ],
85- cmd = "RUSTC=$(location //tools/upstream_wrapper:rustc) $(location //tools/upstream_wrapper:cargo) run --quiet --manifest-path=cargo/cargo_toml_variable_extractor/testdata/workspace/subcrate/Cargo.toml > $@" ,
128+ cmd = "RUSTC=$(execpath //tools/upstream_wrapper:rustc) $(execpath //tools/upstream_wrapper:cargo) run --quiet --manifest-path=cargo/cargo_toml_variable_extractor/testdata/workspace/subcrate/Cargo.toml > $@" ,
129+ cmd_bat = "set RUSTC=$(execpath //tools/upstream_wrapper:rustc) && $(execpath //tools/upstream_wrapper:cargo) run --quiet --manifest-path=cargo\\ cargo_toml_variable_extractor\\ testdata\\ workspace\\ subcrate\\ Cargo.toml > $@" ,
130+ target_compatible_with = NOT_WINDOWS ,
86131 tools = [
87132 "//rust/toolchain:current_rust_stdlib_files" ,
88133 "//tools/upstream_wrapper:cargo" ,
@@ -106,12 +151,24 @@ rust_binary(
106151genrule (
107152 name = "gen_workspace_subcrate_bazel_output" ,
108153 outs = ["workspace_subcrate_bazel_output" ],
109- cmd = "$(location :workspace_subcrate_bin) > $@" ,
154+ cmd = "$(execpath :workspace_subcrate_bin) > $@" ,
155+ cmd_bat = "$(execpath :workspace_subcrate_bin) > $@" ,
110156 tools = [":workspace_subcrate_bin" ],
111157)
112158
113- diff_test (
159+ rust_test (
114160 name = "workspace_subcrate_diff_test" ,
115- file1 = ":workspace_subcrate_cargo_output" ,
116- file2 = ":workspace_subcrate_bazel_output" ,
161+ srcs = ["diff_test.rs" ],
162+ data = [
163+ ":workspace_subcrate_bazel_output" ,
164+ ":workspace_subcrate_cargo_output" ,
165+ ],
166+ edition = "2021" ,
167+ env = {
168+ "FILE_1" : "$(rlocationpath :workspace_subcrate_cargo_output)" ,
169+ "FILE_2" : "$(rlocationpath :workspace_subcrate_bazel_output)" ,
170+ },
171+ deps = [
172+ "//rust/runfiles" ,
173+ ],
117174)
0 commit comments