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
use std::fs::create_dir_all;
use super::{AndroidContext, AndroidError};
use crate::android::Target;
use crate::core::{Manager, Task};
pub struct LinkNativeLibraries;
impl Task for LinkNativeLibraries {
type Context = AndroidContext;
type Error = AndroidError;
fn verb(&self) -> &str {
"Linking"
}
fn message(&self) -> &str {
"native libraries"
}
fn detail(&self) -> &str {
"for Android"
}
fn run(
&self,
context: AndroidContext,
_manager: &mut Manager,
) -> Result<AndroidContext, AndroidError> {
let mut destination_path = context.config.target_dir.clone();
destination_path.push("polyhorn-android/app/src/main/jniLibs");
for target in Target::all().iter() {
let source_path = match context.products.get(target.abi) {
Some(path) => path,
_ => continue,
};
let mut destination_path = destination_path.clone();
destination_path.push(target.abi);
let _ = create_dir_all(&destination_path);
destination_path.push(format!("lib{}.so", context.config.spec.app.android.library));
std::fs::copy(source_path, destination_path).unwrap();
}
Ok(context)
}
}