@@ -6,10 +6,10 @@ load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_
6
6
load (
7
7
"//test/unit:common.bzl" ,
8
8
"assert_argv_contains" ,
9
- "assert_argv_contains_not" ,
10
9
"assert_argv_contains_prefix" ,
11
10
"assert_argv_contains_prefix_not" ,
12
11
"assert_argv_contains_prefix_suffix" ,
12
+ "assert_argv_contains_prefix_suffix_not" ,
13
13
"assert_list_contains_adjacent_elements" ,
14
14
)
15
15
@@ -28,8 +28,7 @@ def _rlib_has_no_native_libs_test_impl(ctx):
28
28
tut = analysistest .target_under_test (env )
29
29
action = tut .actions [0 ]
30
30
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" )
33
32
assert_argv_contains_prefix_not (env , action , "--codegen=linker=" )
34
33
return analysistest .end (env )
35
34
@@ -40,17 +39,15 @@ def _cdylib_has_native_libs_test_impl(ctx):
40
39
toolchain = _get_toolchain (ctx )
41
40
compilation_mode = ctx .var ["COMPILATION_MODE" ]
42
41
pic_suffix = _get_pic_suffix (ctx , compilation_mode )
43
- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
44
42
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" )
51
48
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
+
54
51
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
55
52
return analysistest .end (env )
56
53
@@ -59,17 +56,14 @@ def _staticlib_has_native_libs_test_impl(ctx):
59
56
tut = analysistest .target_under_test (env )
60
57
action = tut .actions [0 ]
61
58
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" )
70
64
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
+
73
67
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
74
68
return analysistest .end (env )
75
69
@@ -80,17 +74,15 @@ def _proc_macro_has_native_libs_test_impl(ctx):
80
74
toolchain = _get_toolchain (ctx )
81
75
compilation_mode = ctx .var ["COMPILATION_MODE" ]
82
76
pic_suffix = _get_pic_suffix (ctx , compilation_mode )
83
- assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
84
77
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" )
91
83
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
+
94
86
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
95
87
return analysistest .end (env )
96
88
@@ -99,16 +91,11 @@ def _bin_has_native_libs_test_impl(ctx):
99
91
tut = analysistest .target_under_test (env )
100
92
action = tut .actions [0 ]
101
93
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" )
109
97
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" )
112
99
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
113
100
return analysistest .end (env )
114
101
@@ -144,8 +131,7 @@ def _bin_has_native_dep_and_alwayslink_test_impl(ctx):
144
131
if toolchain .target_os in ["macos" , "darwin" ]:
145
132
darwin_component = _get_darwin_component (link_args [- 1 ])
146
133
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 ),
149
135
"-Wl,-force_load,bazel-out/{}-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (darwin_component , compilation_mode , workspace_prefix ),
150
136
]
151
137
assert_list_contains_adjacent_elements (env , link_args , want )
@@ -158,23 +144,21 @@ def _bin_has_native_dep_and_alwayslink_test_impl(ctx):
158
144
]
159
145
else :
160
146
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 ),
163
148
"-Wl,--whole-archive" ,
164
149
"bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib" .format (compilation_mode , workspace_prefix ),
165
150
"-Wl,--no-whole-archive" ,
166
151
]
167
152
elif toolchain .target_arch == "s390x" :
168
153
want = [
169
- "-lstatic=native_dep" ,
154
+ "bazel-out/s390x-{}/bin/{}test/unit/native_deps/libnative_dep.a" . format ( compilation_mode , workspace_prefix ) ,
170
155
"link-arg=-Wl,--whole-archive" ,
171
156
"link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (compilation_mode , workspace_prefix ),
172
157
"link-arg=-Wl,--no-whole-archive" ,
173
158
]
174
159
else :
175
160
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 ),
178
162
"-Wl,--whole-archive" ,
179
163
"bazel-out/k8-{}/bin/{}test/unit/native_deps/libalwayslink.lo" .format (compilation_mode , workspace_prefix ),
180
164
"-Wl,--no-whole-archive" ,
@@ -198,8 +182,7 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
198
182
if toolchain .target_os in ["macos" , "darwin" ]:
199
183
darwin_component = _get_darwin_component (linker_args [- 1 ])
200
184
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 ),
203
186
"-Wl,-force_load,bazel-out/{}-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (darwin_component , compilation_mode , workspace_prefix , pic_suffix ),
204
187
]
205
188
elif toolchain .target_os == "windows" :
@@ -211,23 +194,21 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
211
194
]
212
195
else :
213
196
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 ),
216
198
"-Wl,--whole-archive" ,
217
199
"bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib" .format (compilation_mode , workspace_prefix ),
218
200
"-Wl,--no-whole-archive" ,
219
201
]
220
202
elif toolchain .target_arch == "s390x" :
221
203
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 ),
223
205
"link-arg=-Wl,--whole-archive" ,
224
206
"link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (compilation_mode , workspace_prefix , pic_suffix ),
225
207
"link-arg=-Wl,--no-whole-archive" ,
226
208
]
227
209
else :
228
210
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 ),
231
212
"-Wl,--whole-archive" ,
232
213
"bazel-out/k8-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo" .format (compilation_mode , workspace_prefix , pic_suffix ),
233
214
"-Wl,--no-whole-archive" ,
0 commit comments