-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate bindings for required symbols only
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#![cfg(windows)] | ||
|
||
use std::fs; | ||
use windows_bindgen::bindgen; | ||
|
||
#[test] | ||
fn gen_bindings() { | ||
let existing = fs::read_to_string(TARGET).unwrap(); | ||
let new = windows_bindgen::bindgen([ | ||
"--out", | ||
TARGET, | ||
"--config", | ||
"flatten", | ||
"--filter", | ||
"Windows.Win32.Foundation.NO_ERROR", | ||
"Windows.Win32.NetworkManagement.IpHelper.FreeMibTable", | ||
"Windows.Win32.NetworkManagement.IpHelper.GetIpInterfaceTable", | ||
"Windows.Win32.NetworkManagement.IpHelper.GetUnicastIpAddressTable", | ||
"Windows.Win32.NetworkManagement.IpHelper.MIB_IPINTERFACE_ROW", | ||
"Windows.Win32.NetworkManagement.IpHelper.MIB_IPINTERFACE_TABLE", | ||
"Windows.Win32.NetworkManagement.IpHelper.MIB_UNICASTIPADDRESS_ROW", | ||
"Windows.Win32.NetworkManagement.IpHelper.MIB_UNICASTIPADDRESS_TABLE", | ||
"Windows.Win32.Networking.WinSock.AF_INET", | ||
"Windows.Win32.Networking.WinSock.AF_INET6", | ||
"Windows.Win32.Networking.WinSock.AF_UNSPEC", | ||
]) | ||
.unwrap(); | ||
|
||
// Check the output is the same as before. | ||
// Depending on the git configuration the file may have been checked out with `\r\n` newlines or | ||
// with `\n`. Compare line-by-line to ignore this difference. | ||
let new = fs::read_to_string(TARGET).unwrap(); | ||
if !new.lines().eq(existing.lines()) { | ||
panic!("generated file `{TARGET}` is changed"); | ||
} | ||
} | ||
|
||
const TARGET: &str = "src/win_bindings.rs"; |