-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
40 lines (36 loc) · 1.43 KB
/
build.rs
File metadata and controls
40 lines (36 loc) · 1.43 KB
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
// build.rs - build script
// Use pkg-config to discover and link libimobiledevice, libplist, libusbmuxd
fn install_hint(lib_name: &str) -> String {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let hint = match target_os.as_str() {
"macos" => format!(
"Cannot find {lib_name}, please make sure it is installed:\n \
macOS: brew install {lib_name}"
),
"windows" => format!(
"Cannot find {lib_name}, please make sure it is installed:\n \
Windows: install via vcpkg or build from source with MSYS2/MinGW"
),
_ => format!(
"Cannot find {lib_name}, please make sure it is installed:\n \
Linux: sudo apt install {lib_name}-dev (or equivalent for your distro)"
),
};
hint
}
fn main() {
// Link libimobiledevice (contains idevice_*, lockdownd_* functions)
pkg_config::Config::new()
.atleast_version("1.0")
.probe("libimobiledevice-1.0")
.expect(&install_hint("libimobiledevice"));
// Link libusbmuxd (contains usbmuxd_* functions)
pkg_config::Config::new()
.atleast_version("2.0")
.probe("libusbmuxd-2.0")
.expect(&install_hint("libusbmuxd"));
// On Windows, link to ws2_32 for socket support
if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" {
println!("cargo:rustc-link-lib=ws2_32");
}
}