Skip to content

Commit 0f7565a

Browse files
committed
Use raw-dylib for windows-sys
To avoid having to declare `#[link(name = "...")]` Signed-off-by: Jiahao XU <[email protected]>
1 parent 0eebb31 commit 0f7565a

File tree

4 files changed

+1
-29
lines changed

4 files changed

+1
-29
lines changed

dev-tools/gen-windows-sys-binding/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ publish = false
77
[dependencies]
88
windows-bindgen = "0.58"
99
tempfile = "3"
10-
regex = "1"

dev-tools/gen-windows-sys-binding/src/main.rs

-23
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use std::{
66
io::{BufWriter, Write as _},
77
};
88

9-
use regex::Regex;
10-
119
/// This is printed to the file before the rest of the contents.
1210
const PRELUDE: &str = r#"// This file is autogenerated.
1311
//
@@ -60,27 +58,6 @@ fn main() {
6058

6159
write!(&mut f, "{PRELUDE}\n{bindings}\n").unwrap();
6260

63-
let mut dll_names: Vec<&str> = Regex::new(r#"link!\("(.*)\.dll""#)
64-
.unwrap()
65-
.captures_iter(&bindings)
66-
.map(|caps| caps.extract().1)
67-
.map(|[dll_name]| dll_name)
68-
.filter(|dll_name| *dll_name != "kernel32")
69-
.collect();
70-
71-
if !dll_names.is_empty() {
72-
dll_names.sort_unstable();
73-
dll_names.dedup();
74-
75-
for dll_name in dll_names {
76-
write!(&mut f, r#"#[link(name = "{dll_name}")]"#).unwrap();
77-
f.write_all("\n".as_bytes()).unwrap();
78-
}
79-
80-
f.write_all(r#"extern "C" {}"#.as_bytes()).unwrap();
81-
f.write_all("\n".as_bytes()).unwrap();
82-
}
83-
8461
f.write_all(r#"use super::windows_targets;"#.as_bytes())
8562
.unwrap();
8663
f.write_all("\n".as_bytes()).unwrap();

src/windows/windows_sys.rs

-4
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,4 @@ pub const WAIT_OBJECT_0: WAIT_EVENT = 0u32;
114114
pub const WAIT_TIMEOUT: WAIT_EVENT = 258u32;
115115
pub type WIN32_ERROR = u32;
116116

117-
#[link(name = "advapi32")]
118-
#[link(name = "ole32")]
119-
#[link(name = "oleaut32")]
120-
extern "C" {}
121117
use super::windows_targets;

src/windows/windows_targets.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro_rules! link_macro {
99
// have in this repo. So instead we always link kernel32.lib and add the rest of the import
1010
// libraries below by using an empty extern block. This works because extern blocks are not
1111
// connected to the library given in the #[link] attribute.
12-
#[link(name = "kernel32")]
12+
#[link(name = "kernel32", kind = "raw-dylib")]
1313
extern $abi {
1414
$(#[link_name=$link_name])?
1515
pub fn $($function)*;

0 commit comments

Comments
 (0)