-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rs
42 lines (35 loc) · 1.4 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::{io::Cursor, fs};
fn main() {
// refuse to build if we're not on windows
if !cfg!(target_os = "windows") {
panic!("This crate only works on Windows!");
}
winresource::WindowsResource::new()
.set_manifest(r#"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
"#)
.compile()
.unwrap();
// create the libs folder if it doesn't exist
let libs = std::path::Path::new("libs");
if !libs.exists() {
fs::create_dir("libs").unwrap();
// download the zip from https://npcap.com/dist/npcap-sdk-1.13.zip
let resp = reqwest::blocking::get("https://npcap.com/dist/npcap-sdk-1.13.zip")
.expect("Failed to download npcap-sdk-1.13.zip");
let zip = resp.bytes().unwrap();
zip_extract::extract(Cursor::new(zip), &libs.join("zip"), false).unwrap();
fs::copy("libs/zip/Lib/x64/wpcap.lib", "libs/wpcap.lib").unwrap();
fs::copy("libs/zip/Lib/x64/Packet.lib", "libs/Packet.lib").unwrap();
fs::remove_dir_all("libs/zip").unwrap();
}
println!(r#"cargo:rustc-env=LIB=libs\"#);
}