-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
56 lines (43 loc) · 1.45 KB
/
build.rs
File metadata and controls
56 lines (43 loc) · 1.45 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::env;
use std::path::PathBuf;
const VAR_AIR_SDK: &str = "AIR_HOME";
const SETUP_GUIDE: &str = "For more information, see: https://airsdk.dev/docs/basics/getting-started\n";
fn main() {
if env::var("DOCS_RS").is_ok() {return;}
let air_sdk = PathBuf::from(
env::var(VAR_AIR_SDK)
.expect(&format!(
"`{VAR_AIR_SDK}` is not set. Set it to the AIR SDK root directory.\n\
{SETUP_GUIDE}",
))
);
let dir = air_sdk.join("lib");
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let dir = match os.as_str() {
"windows" => {
let dir = match arch.as_str() {
"x86" => dir.join("win"),
"x86_64" => dir.join("win64"),
_ => panic!("Unsupported target architecture: {arch}"),
};
check(dir.join("FlashRuntimeExtensions.lib"));
dir
},
//
// TODO: how to do?
//
_ => panic!("Unsupported target operating system: {os}"),
};
println!("cargo:rustc-link-search=native={}", dir.display());
println!("cargo:rustc-link-lib=FlashRuntimeExtensions");
}
fn check (file: PathBuf) {
assert!(
file.is_file(),
"Required file not found: `{}`\n\
Ensure AIR SDK is correctly installed.\n\
{SETUP_GUIDE}",
file.display()
);
}