forked from samcrow/xplm-sys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
37 lines (34 loc) · 1.34 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
use std::env;
use std::path::PathBuf;
fn main() {
link_libraries();
}
/// On Mac OS and Windows targets, links the XPLM libraries
fn link_libraries() {
// Get the absolute path to this crate, so that linking will work when done in another folder
let crate_path = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let target = env::var("TARGET").unwrap();
if target.contains("-apple-") {
let library_path = crate_path.join("SDK/Libraries/Mac");
println!(
"cargo:rustc-link-search=framework={}",
library_path.to_str().unwrap()
);
println!("cargo:rustc-link-lib=framework=XPLM");
println!("cargo:rustc-link-lib=framework=XPWidgets");
} else if target.contains("-linux-") {
// Do nothing for Linux
} else if target.contains("-windows-") {
let library_path = crate_path.join("SDK/Libraries/Win");
println!("cargo:rustc-link-search={}", library_path.to_str().unwrap());
if target.contains("x86_64") {
println!("cargo:rustc-link-lib=XPLM_64");
println!("cargo:rustc-link-lib=XPWidgets_64");
} else {
println!("cargo:rustc-link-lib=XPLM");
println!("cargo:rustc-link-lib=XPWidgets");
}
} else {
panic!("Target operating system not Mac OS, Linux, or Windows")
}
}