@@ -30,7 +30,8 @@ def _cdylib_has_native_libs_test_impl(ctx):
30
30
assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
31
31
assert_argv_contains (env , action , "--crate-type=cdylib" )
32
32
assert_argv_contains (env , action , "-lstatic=native_dep" )
33
- assert_argv_contains (env , action , "-Clink-arg=-lnative_dep" )
33
+ native_link_arg = "-Clink-arg=native_dep.lib" if ctx .target_platform_has_constraint (ctx .attr ._windows_constraint [platform_common .ConstraintValueInfo ]) else "-Clink-arg=-lnative_dep"
34
+ assert_argv_contains (env , action , native_link_arg )
34
35
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
35
36
return analysistest .end (env )
36
37
@@ -41,7 +42,8 @@ def _staticlib_has_native_libs_test_impl(ctx):
41
42
assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
42
43
assert_argv_contains (env , action , "--crate-type=staticlib" )
43
44
assert_argv_contains (env , action , "-lstatic=native_dep" )
44
- assert_argv_contains (env , action , "-Clink-arg=-lnative_dep" )
45
+ native_link_arg = "-Clink-arg=native_dep.lib" if ctx .target_platform_has_constraint (ctx .attr ._windows_constraint [platform_common .ConstraintValueInfo ]) else "-Clink-arg=-lnative_dep"
46
+ assert_argv_contains (env , action , native_link_arg )
45
47
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
46
48
return analysistest .end (env )
47
49
@@ -53,7 +55,8 @@ def _proc_macro_has_native_libs_test_impl(ctx):
53
55
assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
54
56
assert_argv_contains (env , action , "--crate-type=proc-macro" )
55
57
assert_argv_contains (env , action , "-lstatic=native_dep" )
56
- assert_argv_contains (env , action , "-Clink-arg=-lnative_dep" )
58
+ native_link_arg = "-Clink-arg=native_dep.lib" if ctx .target_platform_has_constraint (ctx .attr ._windows_constraint [platform_common .ConstraintValueInfo ]) else "-Clink-arg=-lnative_dep"
59
+ assert_argv_contains (env , action , native_link_arg )
57
60
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
58
61
return analysistest .end (env )
59
62
@@ -63,7 +66,8 @@ def _bin_has_native_libs_test_impl(ctx):
63
66
action = tut .actions [0 ]
64
67
assert_argv_contains_prefix_suffix (env , action , "-Lnative=" , "/native_deps" )
65
68
assert_argv_contains (env , action , "-lstatic=native_dep" )
66
- assert_argv_contains (env , action , "-Clink-arg=-lnative_dep" )
69
+ native_link_arg = "-Clink-arg=native_dep.lib" if ctx .target_platform_has_constraint (ctx .attr ._windows_constraint [platform_common .ConstraintValueInfo ]) else "-Clink-arg=-lnative_dep"
70
+ assert_argv_contains (env , action , native_link_arg )
67
71
assert_argv_contains_prefix (env , action , "--codegen=linker=" )
68
72
return analysistest .end (env )
69
73
@@ -140,10 +144,18 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
140
144
return analysistest .end (env )
141
145
142
146
rlib_has_no_native_libs_test = analysistest .make (_rlib_has_no_native_libs_test_impl )
143
- staticlib_has_native_libs_test = analysistest .make (_staticlib_has_native_libs_test_impl )
144
- cdylib_has_native_libs_test = analysistest .make (_cdylib_has_native_libs_test_impl )
145
- proc_macro_has_native_libs_test = analysistest .make (_proc_macro_has_native_libs_test_impl )
146
- bin_has_native_libs_test = analysistest .make (_bin_has_native_libs_test_impl )
147
+ staticlib_has_native_libs_test = analysistest .make (_staticlib_has_native_libs_test_impl , attrs = {
148
+ "_windows_constraint" : attr .label (default = Label ("@platforms//os:windows" )),
149
+ })
150
+ cdylib_has_native_libs_test = analysistest .make (_cdylib_has_native_libs_test_impl , attrs = {
151
+ "_windows_constraint" : attr .label (default = Label ("@platforms//os:windows" )),
152
+ })
153
+ proc_macro_has_native_libs_test = analysistest .make (_proc_macro_has_native_libs_test_impl , attrs = {
154
+ "_windows_constraint" : attr .label (default = Label ("@platforms//os:windows" )),
155
+ })
156
+ bin_has_native_libs_test = analysistest .make (_bin_has_native_libs_test_impl , attrs = {
157
+ "_windows_constraint" : attr .label (default = Label ("@platforms//os:windows" )),
158
+ })
147
159
bin_has_native_dep_and_alwayslink_test = analysistest .make (_bin_has_native_dep_and_alwayslink_test_impl , attrs = {
148
160
"_macos_constraint" : attr .label (default = Label ("@platforms//os:macos" )),
149
161
"_windows_constraint" : attr .label (default = Label ("@platforms//os:windows" )),
0 commit comments