Skip to content

Commit ae22551

Browse files
authored
Enables experimental support for raw-dylib (#977)
1 parent d29314d commit ae22551

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ targets = ["x86_64-pc-windows-msvc"]
3131
[features]
3232
default = ["macros"]
3333
macros = ["gen", "windows_macros"]
34+
raw_dylib = ["gen/raw_dylib"] # TODO: remove feature once raw-dylib has stablized

crates/gen/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ license = "MIT OR Apache-2.0"
77
description = "Code generation for the windows crate"
88

99
[dependencies]
10+
11+
[features]
12+
raw_dylib = []

crates/gen/src/types/function.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ impl Function {
2929
let args = signature.params.iter().map(|p| p.gen_win32_abi_arg());
3030
let mut link = def.impl_map().expect("Function").scope().name();
3131

32-
// TODO: workaround for https://github.com/microsoft/windows-rs/issues/463
33-
if link.contains("-ms-win-") || link == "D3DCOMPILER_47" || link == "SspiCli" {
34-
link = "onecoreuap";
32+
let raw_dylib = cfg!(feature = "raw_dylib");
33+
34+
// TODO: remove this whole block once raw-dylib has stabilized as the workarounds
35+
// will no longer be necessary.
36+
if !raw_dylib {
37+
if link.contains("-ms-win-") || link == "D3DCOMPILER_47" || link == "SspiCli" {
38+
link = "onecoreuap";
39+
}
3540
}
3641

3742
let static_lib = def
@@ -41,9 +46,17 @@ impl Function {
4146
_ => None,
4247
})
4348
.next();
49+
4450
let link_attr = match static_lib {
4551
Some(link) => quote! { #[link(name = #link, kind = "static")] },
46-
None => quote! { #[link(name = #link)] },
52+
None => {
53+
// TODO: switch to always using raw-dylib once it has stabilized
54+
if raw_dylib {
55+
quote! { #[link(name = #link, kind="raw-dylib")] }
56+
} else {
57+
quote! { #[link(name = #link)] }
58+
}
59+
}
4760
};
4861

4962
if signature.has_query_interface() {

0 commit comments

Comments
 (0)