polyhorn_cli/android/tasks/
link_native_libraries.rs1use std::fs::create_dir_all;
2
3use super::{AndroidContext, AndroidError};
4use crate::android::Target;
5use crate::core::{Manager, Task};
6
7pub struct LinkNativeLibraries;
10
11impl Task for LinkNativeLibraries {
12 type Context = AndroidContext;
13 type Error = AndroidError;
14
15 fn verb(&self) -> &str {
16 "Linking"
17 }
18
19 fn message(&self) -> &str {
20 "native libraries"
21 }
22
23 fn detail(&self) -> &str {
24 "for Android"
25 }
26
27 fn run(
28 &self,
29 context: AndroidContext,
30 _manager: &mut Manager,
31 ) -> Result<AndroidContext, AndroidError> {
32 let mut destination_path = context.config.target_dir.clone();
33 destination_path.push("polyhorn-android/app/src/main/jniLibs");
34
35 for target in Target::all().iter() {
36 let source_path = match context.products.get(target.abi) {
37 Some(path) => path,
38 _ => continue,
39 };
40
41 let mut destination_path = destination_path.clone();
42 destination_path.push(target.abi);
43
44 let _ = create_dir_all(&destination_path);
45
46 destination_path.push(format!("lib{}.so", context.config.spec.app.android.library));
47 std::fs::copy(source_path, destination_path).unwrap();
48 }
49
50 Ok(context)
51 }
52}