Last commit

This commit is contained in:
KoalaSat
2024-04-28 14:17:25 +02:00
parent 26009f376c
commit 9b43c7c7ef
6 changed files with 16 additions and 99 deletions

8
Cargo.lock generated
View File

@ -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"

View File

@ -2,8 +2,7 @@
members = [
"robohash",
"robonames",
"robo-identities-wasm",
"robo-identities-java"
"robo-identities-wasm"
]
[profile.release]

View File

@ -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: .

View File

@ -1,2 +0,0 @@
/target
Cargo.lock

View File

@ -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" }

View File

@ -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!(),
}
}
}