diff --git a/Cargo.lock b/Cargo.lock index 5a9a9e1..715c123 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,14 +964,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "robo-identities-java" -version = "0.1.0" -dependencies = [ - "jni", - "robonames", -] - [[package]] name = "robo-identities-wasm" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 9cd628f..aa86cb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,7 @@ members = [ "robohash", "robonames", - "robo-identities-wasm", - "robo-identities-java" + "robo-identities-wasm" ] [profile.release] diff --git a/docker-compose.yml b/docker-compose.yml index 3999138..25e513c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,21 @@ version: '3.4' services: - # rust_wasm: - # build: - # context: . - # dockerfile: ./robo-identities-wasm/Dockerfile - # volumes: - # - ./builds/wasm/:/app/robo-identities-wasm/pkg/:rw - # command: wasm-pack build - # rust_java_robonames: - # build: - # context: . - # dockerfile: ./Dockerfile - # target: robonames - # volumes: - # - ./builds/java/robonames:/root/target/:rw - # command: cargo ndk -t armeabi-v7a -t arm64-v8a -o ./target build --release + rust_wasm: + build: + context: . + dockerfile: ./robo-identities-wasm/Dockerfile + volumes: + - ./builds/wasm/:/app/robo-identities-wasm/pkg/:rw + command: wasm-pack build + rust_java_robonames: + build: + context: . + dockerfile: ./Dockerfile + target: robonames + volumes: + - ./builds/java/robonames:/root/target/:rw + command: cargo ndk -t armeabi-v7a -t arm64-v8a -o ./target build --release rust_java_robohash: build: context: . diff --git a/robo-identities-java/.gitignore b/robo-identities-java/.gitignore deleted file mode 100644 index 96ef6c0..0000000 --- a/robo-identities-java/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -Cargo.lock diff --git a/robo-identities-java/Cargo.toml b/robo-identities-java/Cargo.toml deleted file mode 100644 index b8720d1..0000000 --- a/robo-identities-java/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "robo-identities-java" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["rlib", "dylib"] - -[dependencies] -jni = "0.21.1" -robonames = { path = "../robonames" } diff --git a/robo-identities-java/src/lib.rs b/robo-identities-java/src/lib.rs deleted file mode 100644 index be7355e..0000000 --- a/robo-identities-java/src/lib.rs +++ /dev/null @@ -1,61 +0,0 @@ -#[allow(non_snake_case)] -pub mod android { - use jni::JNIEnv; - use jni::objects::{JClass, JString}; - use jni::sys::jstring; - - use robonames::generate_short_nickname; - - #[no_mangle] - pub extern "system" fn Java_com_robosats_RoboIdentities_nativeHello<'local>(mut env: JNIEnv<'local>, - // This is the class that owns our static method. It's not going to be used, - // but still must be present to match the expected signature of a static - // native method. - _class: JClass<'local>, - input: JString<'local>) - -> jstring { - // First, we have to get the string out of Java. Check jstring `strings` - // module for more info on how this works. - let input: String = - env.get_string(&input).expect("Couldn't get java string!").into(); - - // Then we have to create a new Java string to return. Again, more info - // in the `strings` module. - let output = env.new_string(format!("Hello, {}!", input)) - .expect("Couldn't create java string!"); - - // Finally, extract the raw pointer to return. - output.into_raw() - } - - #[no_mangle] - pub extern "system" fn Java_com_robosats_RoboIdentities_nativeGenerateRoboname<'local>(mut env: JNIEnv<'local>, - // This is the class that owns our static method. It's not going to be used, - // but still must be present to match the expected signature of a static - // native method. - _class: JClass<'local>, - initial_string: JString<'local>) - -> jstring { - - let initial_string: String = - env.get_string(&initial_string).expect("Couldn't get java string!").into(); - - - match initial_string.split_once(';') { - Some((_initial_string, size)) => { - // Generate Robot Nickname synchronousl. Returns a nickname string. - let nickname = generate_short_nickname(initial_string); - match nickname { - Ok(nick) => { - let output = env.new_string(nickname) - .expect("Couldn't create java string!"); - // Finally, extract the raw pointer to return. - output.into_raw() - }, - Err(_) => todo!(), - } - } - None => todo!(), - } - } -} \ No newline at end of file