-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.rs
33 lines (29 loc) · 967 Bytes
/
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
use std::{env, path::{Path, PathBuf}};
fn main() {
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
android();
}
}
fn android() {
println!("cargo:rustc-link-lib=c++_shared");
if let Ok(output_path) = env::var("CARGO_NDK_OUTPUT_PATH") {
let sysroot_libs_path =
PathBuf::from(env::var_os("CARGO_NDK_SYSROOT_LIBS_PATH").unwrap());
let lib_path = sysroot_libs_path.join("libc++_shared.so");
std::fs::copy(
lib_path,
Path::new(&output_path)
.join(&env::var("CARGO_NDK_ANDROID_TARGET").unwrap())
.join("libc++_shared.so"),
)
.unwrap();
let lib_path2 = sysroot_libs_path.join("liblogger.so");
std::fs::copy(
lib_path2,
Path::new(&output_path)
.join(&env::var("CARGO_NDK_ANDROID_TARGET").unwrap())
.join("liblogger.so"),
)
.unwrap();
}
}