Skip to content

Commit cd1e096

Browse files
authored
Use tools to generate bindings for library crates (#3102)
1 parent 7f1a7ff commit cd1e096

File tree

24 files changed

+43
-115
lines changed

24 files changed

+43
-115
lines changed

.github/workflows/clippy.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,18 @@ jobs:
258258
run: cargo clippy -p test_window_long
259259
- name: Clippy test_winrt
260260
run: cargo clippy -p test_winrt
261+
- name: Clippy tool_bindings
262+
run: cargo clippy -p tool_bindings
261263
- name: Clippy tool_gnu
262264
run: cargo clippy -p tool_gnu
263265
- name: Clippy tool_lib
264266
run: cargo clippy -p tool_lib
265267
- name: Clippy tool_license
266268
run: cargo clippy -p tool_license
267-
- name: Clippy tool_metadata
268-
run: cargo clippy -p tool_metadata
269269
- name: Clippy tool_msvc
270270
run: cargo clippy -p tool_msvc
271271
- name: Clippy tool_standalone
272272
run: cargo clippy -p tool_standalone
273-
- name: Clippy tool_sys
274-
run: cargo clippy -p tool_sys
275-
- name: Clippy tool_windows
276-
run: cargo clippy -p tool_windows
277273
- name: Clippy tool_yml
278274
run: cargo clippy -p tool_yml
279275
- name: Clippy windows

.github/workflows/gen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
tool: [windows, sys, yml, license, metadata, standalone]
20+
tool: [bindings, yml, license, standalone]
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,18 @@ jobs:
286286
run: cargo test -p test_window_long --target ${{ matrix.target }} ${{ matrix.etc }}
287287
- name: Test test_winrt
288288
run: cargo test -p test_winrt --target ${{ matrix.target }} ${{ matrix.etc }}
289+
- name: Test tool_bindings
290+
run: cargo test -p tool_bindings --target ${{ matrix.target }} ${{ matrix.etc }}
289291
- name: Test tool_gnu
290292
run: cargo test -p tool_gnu --target ${{ matrix.target }} ${{ matrix.etc }}
291293
- name: Test tool_lib
292294
run: cargo test -p tool_lib --target ${{ matrix.target }} ${{ matrix.etc }}
293295
- name: Test tool_license
294296
run: cargo test -p tool_license --target ${{ matrix.target }} ${{ matrix.etc }}
295-
- name: Test tool_metadata
296-
run: cargo test -p tool_metadata --target ${{ matrix.target }} ${{ matrix.etc }}
297297
- name: Test tool_msvc
298298
run: cargo test -p tool_msvc --target ${{ matrix.target }} ${{ matrix.etc }}
299299
- name: Test tool_standalone
300300
run: cargo test -p tool_standalone --target ${{ matrix.target }} ${{ matrix.etc }}
301-
- name: Test tool_sys
302-
run: cargo test -p tool_sys --target ${{ matrix.target }} ${{ matrix.etc }}
303-
- name: Test tool_windows
304-
run: cargo test -p tool_windows --target ${{ matrix.target }} ${{ matrix.etc }}
305301
- name: Test tool_yml
306302
run: cargo test -p tool_yml --target ${{ matrix.target }} ${{ matrix.etc }}
307303
- name: Test windows

crates/libs/core/tests/bindings.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

crates/libs/registry/tests/bindings.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

crates/libs/result/tests/bindings.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

crates/libs/version/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@ targets = []
2020
[dependencies.windows-targets]
2121
version = "0.52.5"
2222
path = "../targets"
23-
24-
[dev-dependencies.windows-bindgen]
25-
version = "0.57.0"
26-
path = "../bindgen"

crates/libs/version/src/lib.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,4 @@ mod test {
116116
assert!(OsVersion::current() >= OsVersion::new(10, 100, 1_000, 10_000));
117117
assert!(!(OsVersion::current() >= OsVersion::new(10, 100, 1_000, 10_001)));
118118
}
119-
120-
#[test]
121-
fn bindgen() {
122-
let args = [
123-
"--out",
124-
"src/bindings.rs",
125-
"--config",
126-
"flatten",
127-
"sys",
128-
"no-bindgen-comment",
129-
"--filter",
130-
"Windows.Wdk.System.SystemServices.RtlGetVersion",
131-
"Windows.Win32.System.SystemInformation.OSVERSIONINFOEXW",
132-
"Windows.Win32.System.SystemServices.VER_NT_WORKSTATION",
133-
];
134-
135-
windows_bindgen::bindgen(args).unwrap();
136-
}
137119
}

crates/tools/bindings/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "tool_bindings"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
windows-bindgen = { path = "../../libs/bindgen" }

crates/libs/core/tests/bindings.txt renamed to crates/tools/bindings/src/core.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// These will use `windows-sys` style bindings.
22

3-
--out src/imp/bindings.rs
3+
--out crates/libs/core/src/imp/bindings.rs
44
--config flatten sys minimal no-bindgen-comment
55

66
--filter

crates/libs/core/tests/com_bindings.txt renamed to crates/tools/bindings/src/core_com.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// These will use `windows` style bindings and include COM APIs.
22

3-
--out src/imp/com_bindings.rs
3+
--out crates/libs/core/src/imp/com_bindings.rs
44
--config flatten minimal no-bindgen-comment
55

66
--filter

crates/tools/bindings/src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use windows_bindgen::*;
2+
3+
fn main() -> Result<()> {
4+
run("crates/tools/bindings/src/core_com.txt")?;
5+
run("crates/tools/bindings/src/core.txt")?;
6+
run("crates/tools/bindings/src/metadata.txt")?;
7+
run("crates/tools/bindings/src/registry.txt")?;
8+
run("crates/tools/bindings/src/result.txt")?;
9+
run("crates/tools/bindings/src/sys.txt")?;
10+
run("crates/tools/bindings/src/version.txt")?;
11+
run("crates/tools/bindings/src/windows.txt")?;
12+
Ok(())
13+
}
14+
15+
fn run(path: &str) -> Result<()> {
16+
println!("{path}");
17+
bindgen(["--etc", path])?;
18+
Ok(())
19+
}

crates/tools/metadata/bindings.txt renamed to crates/tools/bindings/src/metadata.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
--in crates/libs/bindgen/default
21
--out crates/libs/metadata/src/bindings.rs
32
--config flatten sys minimal no-bindgen-comment
43

crates/libs/registry/tests/bindings.txt renamed to crates/tools/bindings/src/registry.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--out src/bindings.rs
1+
--out crates/libs/registry/src/bindings.rs
22
--config flatten sys minimal no-bindgen-comment
33

44
--filter

crates/libs/result/tests/bindings.txt renamed to crates/tools/bindings/src/result.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--out src/bindings.rs
1+
--out crates/libs/result/src/bindings.rs
22
--config flatten sys minimal vtbl no-bindgen-comment
33

44
--filter

crates/tools/sys/bindings.txt renamed to crates/tools/bindings/src/sys.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
--in crates/libs/bindgen/default
21
--out crates/libs/sys/src/lib.rs
32
--config package sys no-bindgen-comment
43
--config rustfmt-config=max_width=800,newline_style=Unix

crates/tools/bindings/src/version.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--out crates/libs/version/src/bindings.rs
2+
--config flatten sys no-bindgen-comment
3+
4+
--filter
5+
Windows.Wdk.System.SystemServices.RtlGetVersion
6+
Windows.Win32.System.SystemInformation.OSVERSIONINFOEXW
7+
Windows.Win32.System.SystemServices.VER_NT_WORKSTATION

crates/tools/windows/bindings.txt renamed to crates/tools/bindings/src/windows.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
--in crates/libs/bindgen/default
21
--out crates/libs/windows/src/lib.rs
32
--config package no-bindgen-comment
43
--config prepend:Windows.Win32.Foundation.WIN32_ERROR=#[must_use]

crates/tools/metadata/Cargo.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

crates/tools/metadata/src/main.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

crates/tools/sys/Cargo.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

crates/tools/sys/src/main.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

crates/tools/windows/Cargo.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

crates/tools/windows/src/main.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)