Skip to content

Commit e704df5

Browse files
committed
ref: jni_library publish bin executable
1 parent 5a51c01 commit e704df5

File tree

1 file changed

+63
-28
lines changed

1 file changed

+63
-28
lines changed

rust-library/cryptor_jni/src/bin/publish.rs

+63-28
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,74 @@ use std::path::MAIN_SEPARATOR_STR;
1010

1111
use cryptor_global::{console, io};
1212

13+
///
14+
/// Returns the directory path where the release
15+
/// version of this crate is placed.
16+
///
17+
/// ## Example
18+
///
19+
/// `$ rust-library/target`
20+
///
21+
fn release_target_dir_path() -> String {
22+
let current_dir_path = env::current_dir().expect(
23+
"Cannot read current directory"
24+
);
25+
let target_dir_path = current_dir_path.parent().expect(
26+
"Cannot find/read 'target' directory"
27+
);
28+
29+
target_dir_path.as_os_str().to_str().expect(
30+
"Cannot validate 'target' directory"
31+
).to_owned()
32+
}
1333

14-
fn main() {
15-
let current_dir = env::current_dir().expect("Cannot read current directory");
16-
let target_dir = current_dir.parent().expect("Cannot find/read 'target' directory");
17-
let target_dir_str = target_dir.as_os_str().to_str().expect("Cannot validate 'target' directory");
18-
19-
for android_target in build::ANDROID_TARGETS_CONFIG.keys() {
20-
let mut current_target_lib_file_path =
21-
34+
///
35+
/// Returns the jni directory path in the android project
36+
/// where the release version of this crate should be
37+
/// placed.
38+
///
39+
/// ## Example
40+
///
41+
/// `$ android-sample/app/src/main/jniLibs`
42+
///
43+
fn android_jni_libs_dir_path() -> String {
44+
"".to_owned()
45+
}
2246

23-
// fn dotfiles_dir(&self) -> Result<String, DotyError> {
24-
// let mut dotfiles_dir = env::var(USSER_HOME_ENV)
25-
// .map_err(|_| DotyError::DotfilesInvalidDir)?;
26-
27-
// dotfiles_dir.push_str(MAIN_SEPARATOR_STR);
28-
// dotfiles_dir.push_str(DOTFILES_DIR_NAME);
29-
30-
// metadata(&dotfiles_dir)
31-
// .map_err(|_| DotyError::DotfilesInvalidDir)?;
32-
33-
// Ok(dotfiles_dir)
34-
// }
47+
///
48+
/// Returns the file path where the
49+
/// release version of this crate
50+
/// is placed ('libcryptor_jni.so').
51+
///
52+
/// ## Example
53+
///
54+
/// `$ rust-library/target/x86_64-linux-android/release/libcryptor_jni.so`
55+
///
56+
fn crate_file_path_for_target(android_target: &str) -> String {
57+
"".to_owned()
58+
}
3559

60+
fn main() {
61+
let release_target_path = release_target_dir_path();
3662

37-
// let current_target_lib_file = PathBuf::from(
38-
// format!("{crate_dir}/target/{target}/release/libcryptor_jni.so", crate_dir = target_dir_str, target = android_target)
39-
// );
63+
for android_target in build::ANDROID_TARGETS_CONFIG.keys() {
64+
let mut crate_lib_file_path = release_target_path.to_owned();
4065

41-
// // console::out(&current_target_lib_file.into_os_string().to_str().unwrap());
66+
crate_lib_file_path.push_str(MAIN_SEPARATOR_STR);
67+
crate_lib_file_path.push_str("target");
68+
crate_lib_file_path.push_str(MAIN_SEPARATOR_STR);
69+
crate_lib_file_path.push_str(&android_target);
70+
crate_lib_file_path.push_str(MAIN_SEPARATOR_STR);
71+
crate_lib_file_path.push_str("release");
72+
crate_lib_file_path.push_str(MAIN_SEPARATOR_STR);
73+
crate_lib_file_path.push_str("libcryptor_jni.so");
4274

43-
// if current_target_lib_file.exists() {
44-
// console::out("it exists!!!");
45-
// console::print(format!("Android Target {} succesfully copied!!!", &android_target));
46-
// }
75+
if PathBuf::from(&crate_lib_file_path).exists() {
76+
console::out("it exists!!!");
77+
console::print(format!("Android Target {} succesfully copied!!!", &android_target));
78+
console::print(format!("File: {}", &crate_lib_file_path));
79+
} else {
80+
println!("ERROR!!!");
81+
}
4782
}
4883
}

0 commit comments

Comments
 (0)