@@ -6,10 +6,10 @@ load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_
66load (
77 "//test/unit:common.bzl" ,
88 "assert_argv_contains" ,
9- "assert_argv_contains_not" ,
109 "assert_argv_contains_prefix" ,
1110 "assert_argv_contains_prefix_not" ,
1211 "assert_argv_contains_prefix_suffix" ,
12+ "assert_argv_contains_prefix_suffix_not" ,
1313 "assert_list_contains_adjacent_elements" ,
1414)
1515
@@ -28,8 +28,7 @@ def _rlib_has_no_native_libs_test_impl(ctx):
2828 tut = analysistest .target_under_test (env )
2929 action = tut .actions [0 ]
3030 assert_argv_contains (env , action , "--crate-type=rlib" )
31- assert_argv_contains_not (env , action , "-lstatic=native_dep" )
32- assert_argv_contains_not (env , action , "-ldylib=native_dep" )
31+ assert_argv_contains_prefix_suffix_not (env , action , "-Clink-arg=bazel-out/" , "test/unit/native_deps/libnative_dep.a" )
3332 assert_argv_contains_prefix_not (env , action , "--codegen=linker=" )
3433 return analysistest .end (env )
3534
@@ -40,17 +39,15 @@ def _cdylib_has_native_libs_test_impl(ctx):
4039 toolchain = _get_toolchain (ctx )
4140 compilation_mode = ctx .var ["COMPILATION_MODE" ]
4241 pic_suffix = _get_pic_suffix (ctx , compilation_mode )
43- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
4442 assert_argv_contains (env , action , "--crate-type=cdylib" )
45- assert_argv_contains (env , action , "-lstatic=native_dep{}" .format (pic_suffix ))
46- if toolchain .target_os == "windows" :
47- if toolchain .target_triple .abi == "msvc" :
48- native_link_arg = "-Clink-arg=native_dep.lib"
49- else :
50- native_link_arg = "-Clink-arg=-lnative_dep.lib"
43+
44+ if toolchain .target_os == "windows" and toolchain .target_triple .abi == "msvc" :
45+ assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
46+ assert_argv_contains (env , action , "-lstatic=native_dep{}" .format (pic_suffix ))
47+ assert_argv_contains (env , action , "-Clink-arg=native_dep.lib" )
5148 else :
52- native_link_arg = "-Clink-arg=-lnative_dep{} " .format (pic_suffix )
53- assert_argv_contains ( env , action , native_link_arg )
49+ assert_argv_contains_prefix_suffix ( env , action , "-Clink-arg=bazel-out/" , "test/unit/native_deps/libnative_dep{}.a " .format (pic_suffix ) )
50+
5451 assert_argv_contains_prefix (env , action , "--codegen=linker=" )
5552 return analysistest .end (env )
5653
@@ -59,17 +56,14 @@ def _staticlib_has_native_libs_test_impl(ctx):
5956 tut = analysistest .target_under_test (env )
6057 action = tut .actions [0 ]
6158 toolchain = _get_toolchain (ctx )
62- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
63- assert_argv_contains (env , action , "--crate-type=staticlib" )
64- assert_argv_contains (env , action , "-lstatic=native_dep" )
65- if toolchain .target_os == "windows" :
66- if toolchain .target_triple .abi == "msvc" :
67- native_link_arg = "-Clink-arg=native_dep.lib"
68- else :
69- native_link_arg = "-Clink-arg=-lnative_dep.lib"
59+
60+ if toolchain .target_os == "windows" and toolchain .target_triple .abi == "msvc" :
61+ assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
62+ assert_argv_contains (env , action , "-lstatic=native_dep" )
63+ assert_argv_contains (env , action , "-Clink-arg=native_dep.lib" )
7064 else :
71- native_link_arg = "-Clink-arg=-lnative_dep"
72- assert_argv_contains ( env , action , native_link_arg )
65+ assert_argv_contains_prefix_suffix ( env , action , "-Clink-arg=bazel-out/" , "test/unit/native_deps/libnative_dep.a" )
66+
7367 assert_argv_contains_prefix (env , action , "--codegen=linker=" )
7468 return analysistest .end (env )
7569
@@ -80,17 +74,15 @@ def _proc_macro_has_native_libs_test_impl(ctx):
8074 toolchain = _get_toolchain (ctx )
8175 compilation_mode = ctx .var ["COMPILATION_MODE" ]
8276 pic_suffix = _get_pic_suffix (ctx , compilation_mode )
83- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
8477 assert_argv_contains (env , action , "--crate-type=proc-macro" )
85- assert_argv_contains (env , action , "-lstatic=native_dep{}" .format (pic_suffix ))
86- if toolchain .target_os == "windows" :
87- if toolchain .target_triple .abi == "msvc" :
88- native_link_arg = "-Clink-arg=native_dep.lib"
89- else :
90- native_link_arg = "-Clink-arg=-lnative_dep.lib"
78+
79+ if toolchain .target_os == "windows" and toolchain .target_triple .abi == "msvc" :
80+ assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
81+ assert_argv_contains (env , action , "-lstatic=native_dep{}" .format (pic_suffix ))
82+ assert_argv_contains (env , action , "-Clink-arg=native_dep.lib" )
9183 else :
92- native_link_arg = "-Clink-arg=-lnative_dep{} " .format (pic_suffix )
93- assert_argv_contains ( env , action , native_link_arg )
84+ assert_argv_contains_prefix_suffix ( env , action , "-Clink-arg=bazel-out/" , "test/unit/native_deps/libnative_dep{}.a " .format (pic_suffix ) )
85+
9486 assert_argv_contains_prefix (env , action , "--codegen=linker=" )
9587 return analysistest .end (env )
9688
@@ -99,16 +91,11 @@ def _bin_has_native_libs_test_impl(ctx):
9991 tut = analysistest .target_under_test (env )
10092 action = tut .actions [0 ]
10193 toolchain = _get_toolchain (ctx )
102- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
103- assert_argv_contains (env , action , "-lstatic=native_dep" )
104- if toolchain .target_os == "windows" :
105- if toolchain .target_triple .abi == "msvc" :
106- native_link_arg = "-Clink-arg=native_dep.lib"
107- else :
108- native_link_arg = "-Clink-arg=-lnative_dep.lib"
94+ if toolchain .target_os == "windows" and toolchain .target_triple .abi == "msvc" :
95+ assert_argv_contains (env , action , "-lstatic=native_dep" )
96+ assert_argv_contains (env , action , "-Clink-arg=native_dep.lib" )
10997 else :
110- native_link_arg = "-Clink-arg=-lnative_dep"
111- assert_argv_contains (env , action , native_link_arg )
98+ assert_argv_contains_prefix_suffix (env , action , "-Clink-arg=bazel-out/" , "test/unit/native_deps/libnative_dep.a" )
11299 assert_argv_contains_prefix (env , action , "--codegen=linker=" )
113100 return analysistest .end (env )
114101
@@ -144,8 +131,7 @@ def _bin_has_native_dep_and_alwayslink_test_impl(ctx):
144131 if toolchain .target_os in ["macos" , "darwin" ]:
145132 darwin_component = _get_darwin_component (link_args [- 1 ])
146133 want = [
147- "-lstatic=native_dep" ,
148- "-lnative_dep" ,
134+ "bazel-out/{}-{}/bin/{}test/unit/native_deps/libnative_dep.a" .format (darwin_component , compilation_mode , workspace_prefix ),
149135 "-Wl,-force_load,bazel-out/{}-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (darwin_component , compilation_mode , workspace_prefix ),
150136 ]
151137 assert_list_contains_adjacent_elements (env , link_args , want )
@@ -158,23 +144,21 @@ def _bin_has_native_dep_and_alwayslink_test_impl(ctx):
158144 ]
159145 else :
160146 want = [
161- "-lstatic=native_dep" ,
162- "native_dep.lib" ,
147+ "bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/libnative_dep.a" .format (compilation_mode , workspace_prefix ),
163148 "-Wl,--whole-archive" ,
164149 "bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib" .format (compilation_mode , workspace_prefix ),
165150 "-Wl,--no-whole-archive" ,
166151 ]
167152 elif toolchain .target_arch == "s390x" :
168153 want = [
169- "-lstatic=native_dep" ,
154+ "bazel-out/s390x-{}/bin/{}test/unit/native_deps/libnative_dep.a" . format ( compilation_mode , workspace_prefix ) ,
170155 "link-arg=-Wl,--whole-archive" ,
171156 "link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (compilation_mode , workspace_prefix ),
172157 "link-arg=-Wl,--no-whole-archive" ,
173158 ]
174159 else :
175160 want = [
176- "-lstatic=native_dep" ,
177- "-lnative_dep" ,
161+ "bazel-out/k8-{}/bin/{}test/unit/native_deps/libnative_dep.a" .format (compilation_mode , workspace_prefix ),
178162 "-Wl,--whole-archive" ,
179163 "bazel-out/k8-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (compilation_mode , workspace_prefix ),
180164 "-Wl,--no-whole-archive" ,
@@ -198,8 +182,7 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
198182 if toolchain .target_os in ["macos" , "darwin" ]:
199183 darwin_component = _get_darwin_component (linker_args [- 1 ])
200184 want = [
201- "-lstatic=native_dep{}" .format (pic_suffix ),
202- "-lnative_dep{}" .format (pic_suffix ),
185+ "bazel-out/{}-{}/bin/{}test/unit/native_deps/libnative_dep{}.a" .format (darwin_component , compilation_mode , workspace_prefix , pic_suffix ),
203186 "-Wl,-force_load,bazel-out/{}-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (darwin_component , compilation_mode , workspace_prefix , pic_suffix ),
204187 ]
205188 elif toolchain .target_os == "windows" :
@@ -211,23 +194,21 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
211194 ]
212195 else :
213196 want = [
214- "-lstatic=native_dep" ,
215- "native_dep.lib" ,
197+ "bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/libnative_dep{}.a" .format (compilation_mode , workspace_prefix , pic_suffix ),
216198 "-Wl,--whole-archive" ,
217199 "bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib" .format (compilation_mode , workspace_prefix ),
218200 "-Wl,--no-whole-archive" ,
219201 ]
220202 elif toolchain .target_arch == "s390x" :
221203 want = [
222- "-lstatic=native_dep{} " .format (pic_suffix ),
204+ "bazel-out/s390x-{}/bin/{}test/unit/native_deps/libnative_dep{}.a " .format (compilation_mode , workspace_prefix , pic_suffix ),
223205 "link-arg=-Wl,--whole-archive" ,
224206 "link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (compilation_mode , workspace_prefix , pic_suffix ),
225207 "link-arg=-Wl,--no-whole-archive" ,
226208 ]
227209 else :
228210 want = [
229- "-lstatic=native_dep{}" .format (pic_suffix ),
230- "-lnative_dep{}" .format (pic_suffix ),
211+ "bazel-out/k8-{}/bin/{}test/unit/native_deps/libnative_dep{}.a" .format (compilation_mode , workspace_prefix , pic_suffix ),
231212 "-Wl,--whole-archive" ,
232213 "bazel-out/k8-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (compilation_mode , workspace_prefix , pic_suffix ),
233214 "-Wl,--no-whole-archive" ,
0 commit comments