make android unit tests and earthly build work
This commit is contained in:
parent
02c0d065ef
commit
d979f7f504
@ -1,7 +1,11 @@
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
# ar = "aarch64-linux-gnu-ar"
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[target.aarch64-linux-android]
|
||||
#ar = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar"
|
||||
linker = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-clang"
|
||||
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang"
|
||||
[target.armv7-linux-androideabi]
|
||||
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang"
|
||||
[target.x86_64-linux-android]
|
||||
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang"
|
||||
[target.i686-linux-android]
|
||||
linker = "/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android30-clang"
|
33
Earthfile
33
Earthfile
@ -43,15 +43,23 @@ deps-rust:
|
||||
# WASM
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
|
||||
# Install cross-platform tooling
|
||||
# Install Linux cross-platform tooling
|
||||
deps-cross:
|
||||
FROM +deps-rust
|
||||
RUN apt-get install -y gcc-aarch64-linux-gnu
|
||||
|
||||
RUN apt-get install -y gcc-aarch64-linux-gnu curl unzip
|
||||
|
||||
# Install android tooling
|
||||
deps-android:
|
||||
FROM +deps-cross
|
||||
RUN apt-get install -y openjdk-9-jdk-headless
|
||||
RUN mkdir /Android; mkdir /Android/Sdk
|
||||
RUN curl -o /Android/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
|
||||
RUN cd /Android; unzip /Android/cmdline-tools.zip
|
||||
RUN yes | /Android/cmdline-tools/bin/sdkmanager --sdk_root=/Android/Sdk build-tools\;30.0.3 ndk\;22.0.7026061 cmake\;3.18.1 platform-tools platforms\;android-30
|
||||
|
||||
# Install stub secrets daemon for keyring tests
|
||||
deps-secretsd:
|
||||
FROM +deps-cross
|
||||
FROM +deps-android
|
||||
COPY scripts/earthly/secretsd /secretsd
|
||||
RUN pip install -r /secretsd/requirements.txt
|
||||
RUN pip install keyring
|
||||
@ -64,7 +72,8 @@ deps:
|
||||
|
||||
code:
|
||||
FROM +deps
|
||||
COPY . .
|
||||
COPY --dir .cargo external files scripts veilid-cli veilid-core veilid-server veilid-wasm Cargo.lock Cargo.toml /veilid
|
||||
WORKDIR /veilid
|
||||
|
||||
# Clippy only
|
||||
clippy:
|
||||
@ -82,6 +91,20 @@ build-linux-arm64:
|
||||
RUN cargo build --target aarch64-unknown-linux-gnu --release
|
||||
SAVE ARTIFACT ./target/aarch64-unknown-linux-gnu AS LOCAL ./target/artifacts/aarch64-unknown-linux-gnu
|
||||
|
||||
build-android:
|
||||
FROM +code
|
||||
WORKDIR /veilid/veilid-core
|
||||
ENV PATH=$PATH:/Android/Sdk/ndk/22.0.7026061/toolchains/llvm/prebuilt/linux-x86_64/bin/
|
||||
RUN cargo build --target aarch64-linux-android --release
|
||||
RUN cargo build --target armv7-linux-androideabi --release
|
||||
RUN cargo build --target i686-linux-android --release
|
||||
RUN cargo build --target x86_64-linux-android --release
|
||||
WORKDIR /veilid
|
||||
SAVE ARTIFACT ./target/aarch64-linux-android AS LOCAL ./target/artifacts/aarch64-linux-android
|
||||
SAVE ARTIFACT ./target/armv7-linux-androideabi AS LOCAL ./target/artifacts/armv7-linux-androideabi
|
||||
SAVE ARTIFACT ./target/i686-linux-android AS LOCAL ./target/artifacts/i686-linux-android
|
||||
SAVE ARTIFACT ./target/x86_64-linux-android AS LOCAL ./target/artifacts/x86_64-linux-android
|
||||
|
||||
# Unit tests
|
||||
unit-tests-linux-amd64:
|
||||
FROM +code
|
||||
|
@ -33,7 +33,13 @@ impl ProtectedStore {
|
||||
let c = self.config.get();
|
||||
let mut inner = self.inner.lock();
|
||||
if !c.protected_store.always_use_insecure_storage {
|
||||
inner.keyring_manager = KeyringManager::new_secure(&c.program_name).ok();
|
||||
cfg_if! {
|
||||
if #[cfg(target_os = "android")] {
|
||||
inner.keyring_manager = KeyringManager::new_secure(&c.program_name, intf::native::utils::android::get_android_globals()).ok();
|
||||
} else {
|
||||
inner.keyring_manager = KeyringManager::new_secure(&c.program_name).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c.protected_store.always_use_insecure_storage
|
||||
|| c.protected_store.allow_insecure_fallback)
|
||||
|
@ -6,7 +6,7 @@ pub fn get_files_dir() -> String {
|
||||
let ag = aglock.as_ref().unwrap();
|
||||
let env = ag.vm.attach_current_thread().unwrap();
|
||||
|
||||
with_null_local_frame(env, 64, || {
|
||||
with_null_local_frame(*env, 64, || {
|
||||
// context.getFilesDir().getAbsolutePath()
|
||||
let file = env
|
||||
.call_method(ag.ctx.as_obj(), "getFilesDir", "()Ljava/io/File;", &[])
|
||||
@ -30,7 +30,7 @@ pub fn get_cache_dir() -> String {
|
||||
let ag = aglock.as_ref().unwrap();
|
||||
let env = ag.vm.attach_current_thread().unwrap();
|
||||
|
||||
with_null_local_frame(env, 64, || {
|
||||
with_null_local_frame(*env, 64, || {
|
||||
// context.getCacheDir().getAbsolutePath()
|
||||
let file = env
|
||||
.call_method(ag.ctx.as_obj(), "getCacheDir", "()Ljava/io/File;", &[])
|
||||
@ -44,7 +44,7 @@ pub fn get_cache_dir() -> String {
|
||||
.unwrap();
|
||||
|
||||
let jstrval = env.get_string(JString::from(path)).unwrap();
|
||||
String::from(jstrval.to_string_lossy())
|
||||
Ok(String::from(jstrval.to_string_lossy()))
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -68,6 +68,15 @@ pub fn veilid_core_setup_android<'a>(
|
||||
});
|
||||
}
|
||||
|
||||
pub fn get_android_globals() -> (JavaVM, GlobalRef) {
|
||||
let globals_locked = ANDROID_GLOBALS.lock();
|
||||
let globals = globals_locked.as_ref().unwrap();
|
||||
let env = globals.vm.attach_current_thread().unwrap();
|
||||
let vm = env.get_java_vm().unwrap();
|
||||
let ctx = globals.ctx.clone();
|
||||
(vm, ctx)
|
||||
}
|
||||
|
||||
pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult<T>
|
||||
where
|
||||
F: FnOnce() -> JniResult<T>,
|
||||
|
Loading…
Reference in New Issue
Block a user