veilid-tools work

This commit is contained in:
John Smith 2022-11-29 12:16:28 -05:00
parent c62d21e5cc
commit 273a10f966
18 changed files with 390 additions and 73 deletions

206
Cargo.lock generated
View File

@ -100,6 +100,23 @@ dependencies = [
"syn",
]
[[package]]
name = "android-logd-logger"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53eff4527d2f64c8374a3bbe1d280ce660203e8c83e4a893231037a488639a7b"
dependencies = [
"bytes 1.3.0",
"env_logger 0.8.4",
"lazy_static",
"libc",
"log",
"redox_syscall",
"thiserror",
"time 0.2.27",
"winapi 0.3.9",
]
[[package]]
name = "android_log-sys"
version = "0.2.0"
@ -113,7 +130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e9dd62f37dea550caf48c77591dc50bd1a378ce08855be1a0c42a97b7550fb"
dependencies = [
"android_log-sys",
"env_logger",
"env_logger 0.9.3",
"log",
"once_cell",
]
@ -398,7 +415,7 @@ dependencies = [
"futures-timer",
"futures-util",
"pin-project 1.0.12",
"rustc_version",
"rustc_version 0.4.0",
"tokio 1.22.0",
"wasm-bindgen-futures",
]
@ -411,7 +428,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c"
dependencies = [
"futures",
"pharos",
"rustc_version",
"rustc_version 0.4.0",
]
[[package]]
@ -518,6 +535,12 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base-x"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
[[package]]
name = "base64"
version = "0.12.3"
@ -1059,6 +1082,12 @@ dependencies = [
"web-sys",
]
[[package]]
name = "const_fn"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
[[package]]
name = "constant_time_eq"
version = "0.2.4"
@ -1564,6 +1593,12 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "discard"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "dlv-list"
version = "0.3.0"
@ -1673,6 +1708,16 @@ dependencies = [
"syn",
]
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.9.3"
@ -3630,7 +3675,7 @@ checksum = "57959b91f0a133f89a68be874a5c88ed689c19cd729ecdb5d762ebf16c64d662"
dependencies = [
"once_cell",
"pest",
"sha1",
"sha1 0.10.5",
]
[[package]]
@ -3650,7 +3695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414"
dependencies = [
"futures",
"rustc_version",
"rustc_version 0.4.0",
]
[[package]]
@ -3843,6 +3888,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
version = "1.0.47"
@ -4287,13 +4338,22 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver 0.9.0",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
"semver 1.0.14",
]
[[package]]
@ -4425,12 +4485,27 @@ dependencies = [
"libc",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "send_wrapper"
version = "0.4.0"
@ -4576,6 +4651,15 @@ dependencies = [
"digest 0.10.6",
]
[[package]]
name = "sha1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
dependencies = [
"sha1_smol",
]
[[package]]
name = "sha1"
version = "0.10.5"
@ -4587,6 +4671,12 @@ dependencies = [
"digest 0.10.6",
]
[[package]]
name = "sha1_smol"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "sha2"
version = "0.9.9"
@ -4741,12 +4831,70 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "standback"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff"
dependencies = [
"version_check",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stdweb"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
dependencies = [
"discard",
"rustc_version 0.2.3",
"stdweb-derive",
"stdweb-internal-macros",
"stdweb-internal-runtime",
"wasm-bindgen",
]
[[package]]
name = "stdweb-derive"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_derive",
"syn",
]
[[package]]
name = "stdweb-internal-macros"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
dependencies = [
"base-x",
"proc-macro2",
"quote",
"serde",
"serde_derive",
"serde_json",
"sha1 0.6.1",
"syn",
]
[[package]]
name = "stdweb-internal-runtime"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
[[package]]
name = "stop-token"
version = "0.7.0"
@ -4896,6 +5044,21 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "time"
version = "0.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242"
dependencies = [
"const_fn",
"libc",
"standback",
"stdweb",
"time-macros 0.1.1",
"version_check",
"winapi 0.3.9",
]
[[package]]
name = "time"
version = "0.3.17"
@ -4907,7 +5070,7 @@ dependencies = [
"num_threads",
"serde",
"time-core",
"time-macros",
"time-macros 0.2.6",
]
[[package]]
@ -4916,6 +5079,16 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"
[[package]]
name = "time-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1"
dependencies = [
"proc-macro-hack",
"time-macros-impl",
]
[[package]]
name = "time-macros"
version = "0.2.6"
@ -4925,6 +5098,19 @@ dependencies = [
"time-core",
]
[[package]]
name = "time-macros-impl"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f"
dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote",
"standback",
"syn",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
@ -5737,6 +5923,7 @@ dependencies = [
name = "veilid-tools"
version = "0.1.0"
dependencies = [
"android-logd-logger",
"async-lock",
"async-std",
"async_executors",
@ -5747,12 +5934,13 @@ dependencies = [
"jni",
"jni-sys",
"js-sys",
"lazy_static",
"libc",
"log",
"maplit",
"ndk 0.6.0",
"ndk-glue",
"nix 0.22.3",
"nix 0.25.0",
"once_cell",
"owo-colors",
"parking_lot 0.11.2",
@ -6289,7 +6477,7 @@ dependencies = [
"futures",
"js-sys",
"pharos",
"rustc_version",
"rustc_version 0.4.0",
"send_wrapper 0.5.0",
"thiserror",
"wasm-bindgen",

View File

@ -108,5 +108,5 @@ if [ "$BREW_USER" == "" ]; then
BREW_USER=`whoami`
fi
fi
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf
sudo -H -u $BREW_USER brew install capnp cmake wabt llvm protobuf openjdk@11

View File

@ -6,15 +6,15 @@ edition = "2021"
license = "LGPL-2.0-or-later OR MPL-2.0 OR (MIT AND BSD-3-Clause)"
[lib]
# Staticlib for iOS tests, rlib for everything else
crate-type = [ "staticlib", "rlib" ]
# staticlib for iOS tests, cydlib for android tests, rlib for everything else
crate-type = [ "cdylib", "staticlib", "rlib" ]
[features]
default = []
rt-async-std = [ "async-std", "async_executors/async_std", ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", ]
android_tests = []
android_tests = [ "dep:tracing-android" ]
ios_tests = []
tracking = []
tracing = [ "dep:tracing", "dep:tracing-subscriber" ]
@ -61,7 +61,9 @@ jni = "^0"
jni-sys = "^0"
ndk = { version = "^0", features = ["trace"] }
ndk-glue = { version = "^0", features = ["logger"] }
lazy_static = "^1.4.0"
tracing-android = { version = "^0", optional = true }
android-logd-logger = "0.2.1"
# Dependencies for Windows
# [target.'cfg(target_os = "windows")'.dependencies]

View File

@ -1,11 +1,11 @@
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
CARGO_MANIFEST_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))")
TARGET_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/../target\"))")
CARGO_MANIFEST_PATH=$(python3 -c "import os; import json; print(json.loads(os.popen('cargo locate-project').read())['root'])")
CARGO_WORKSPACE_PATH=$(python3 -c "import os; import json; print(json.loads(os.popen('cargo locate-project --workspace').read())['root'])")
TARGET_PATH=$(python3 -c "import os; print(os.path.realpath(\"$CARGO_WORKSPACE_PATH/../target\"))")
PACKAGE_NAME=$1
shift
# echo CARGO_MANIFEST_PATH: $CARGO_MANIFEST_PATH
if [ "$CONFIGURATION" == "Debug" ]; then
EXTRA_CARGO_OPTIONS="$@"

24
veilid-tools/new_android_sim.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
UNAME_M=`uname -m`
if [[ "$UNAME_M" == "arm64" ]]; then
ANDROID_ABI=arm64-v8a
elif [[ "$UNAME_M" == "x86_64" ]]; then
ANDROID_ABI=x86
else
echo "Unknown platform"
exit 1
fi
AVD_NAME="testavd"
AVD_TAG="google_atd"
AVD_IMAGE="system-images;android-30;$AVD_TAG;$ANDROID_ABI"
AVD_DEVICE="Nexus 10"
# Install AVD image
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "$AVD_IMAGE"
# Make AVD
echo "no" | $ANDROID_SDK_ROOT/tools/bin/avdmanager --verbose create avd --force --name "$AVD_NAME" --package "$AVD_IMAGE" --tag "$AVD_TAG" --abi "$ANDROID_ABI" --device "$AVD_DEVICE"
# Run emulator
$ANDROID_SDK_ROOT/emulator/emulator -avd testavd -no-snapshot -no-boot-anim -no-window &
( trap exit SIGINT ; read -r -d '' _ </dev/tty ) ## wait for Ctrl-C
kill %1
wait

9
veilid-tools/new_ios_sim.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
ID=$(xcrun simctl create test-iphone com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro com.apple.CoreSimulator.SimRuntime.iOS-16-1 2>/dev/null)
xcrun simctl boot $ID
xcrun simctl bootstatus $ID
echo Simulator ID is $ID
( trap exit SIGINT ; read -r -d '' _ </dev/tty ) ## wait for Ctrl-C
xcrun simctl delete $ID

View File

@ -8,15 +8,53 @@ elif [[ "$1" == "ios" ]]; then
SYMROOT=/tmp/testout
APPNAME=veilidtools-tests
BUNDLENAME=com.veilid.veilidtools-tests
ID="$2"
if [[ "$ID" == "" ]]; then
echo "No emulator ID specified"
exit 1
fi
# Build for simulator
xcrun xcodebuild -project src/tests/ios/$APPNAME/$APPNAME.xcodeproj/ -scheme $APPNAME -destination "generic/platform=iOS Simulator" SYMROOT=$SYMROOT
ID=$(xcrun simctl create test-iphone com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro com.apple.CoreSimulator.SimRuntime.iOS-16-1 2>/dev/null)
xcrun simctl boot $ID
xcrun simctl bootstatus $ID
# Run in temporary simulator
xcrun simctl install $ID $SYMROOT/Debug-iphonesimulator/$APPNAME.app
xcrun simctl launch --console $ID $BUNDLENAME
xcrun simctl delete all
# Clean up build output
rm -rf /tmp/testout
elif [[ "$1" == "android" ]]; then
ID="$2"
if [[ "$ID" == "" ]]; then
echo "No emulator ID specified"
exit 1
fi
APPNAME=veilidtools-tests
APPID=com.veilid.veilidtools_tests
ACTIVITYNAME=MainActivity
pushd src/tests/android/$APPNAME >/dev/null
# Build apk
./gradlew assembleDebug
# Wait for boot
adb -s $ID wait-for-device
# Install app
adb -s $ID install -r ./app/build/outputs/apk/debug/app-debug.apk
# Start activity
adb -s $ID shell am start-activity -W $APPID/.$ACTIVITYNAME
# Get the pid of the program
APP_PID=`adb -s $ID shell pidof -s $APPID`
# Print the logcat
adb -s $ID shell logcat -d veilid-tools:V *:S &
# Wait for the pid to be done
while [ "$(adb -s $ID shell pidof -s $APPID)" != "" ]; do
sleep 1
done
# Terminate logcat
kill %1
# Finished
popd >/dev/null
else
cargo test --features=rt-tokio
cargo test --features=rt-async-std

View File

@ -1,13 +1,10 @@
use super::*;
use jni::errors::Result as JniResult;
use jni::{objects::GlobalRef, objects::JObject, objects::JString, JNIEnv, JavaVM};
//use jni::errors::Result as JniResult;
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
use lazy_static::*;
use std::backtrace::Backtrace;
use std::panic;
use tracing::*;
use tracing_subscriber::prelude::*;
use tracing_subscriber::*;
pub struct AndroidGlobals {
pub vm: JavaVM,
@ -35,46 +32,82 @@ pub fn veilid_tools_setup_android_no_log<'a>(env: JNIEnv<'a>, ctx: JObject<'a>)
pub fn veilid_tools_setup<'a>(env: JNIEnv<'a>, ctx: JObject<'a>, log_tag: &'a str) {
cfg_if! {
if #[cfg(feature = "tracing")] {
// Set up subscriber and layers
use tracing::*;
use tracing_subscriber::prelude::*;
use tracing_subscriber::*;
let mut filters = filter::Targets::new();
for ig in DEFAULT_LOG_IGNORE_LIST {
filters = filters.with_target(ig, filter::LevelFilter::OFF);
}
// Set up subscriber and layers
let subscriber = Registry::default();
let mut layers = Vec::new();
let layer = tracing_android::layer(log_tag)
.expect("failed to set up android logging")
.with_filter(LevelFilter::TRACE);
.with_filter(filter::LevelFilter::TRACE)
.with_filter(filters);
layers.push(layer.boxed());
let subscriber = subscriber.with(layers);
subscriber
.try_init()
.expect("failed to init android tracing");
} else {
let mut builder = android_logd_logger::builder();
builder.tag(log_tag);
builder.prepend_module(true);
builder.filter_level(LevelFilter::Trace);
for ig in DEFAULT_LOG_IGNORE_LIST {
builder.filter_module(ig, LevelFilter::Off);
}
builder.init();
}
}
// Set up panic hook for backtraces
panic::set_hook(Box::new(|panic_info| {
let bt = Backtrace::capture();
if let Some(location) = panic_info.location() {
error!(
"panic occurred in file '{}' at line {}",
location.file(),
location.line(),
);
} else {
error!("panic occurred but can't get location information...");
}
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
error!("panic payload: {:?}", s);
} else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
error!("panic payload: {:?}", s);
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
error!("panic payload: {:?}", a);
} else {
error!("no panic payload");
}
error!("Backtrace:\n{:?}", bt);
}));
veilid_core_setup_android_no_log(env, ctx);
veilid_tools_setup_android_no_log(env, ctx);
}
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_as_daemon().unwrap();
let vm = env.get_java_vm().unwrap();
let ctx = globals.ctx.clone();
(vm, ctx)
}
// 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_as_daemon().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>,
{
env.push_local_frame(s)?;
let out = f();
env.pop_local_frame(JObject::null())?;
out
}
// pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult<T>
// where
// F: FnOnce() -> JniResult<T>,
// {
// env.push_local_frame(s)?;
// let out = f();
// env.pop_local_frame(JObject::null())?;
// out
// }

View File

@ -1 +1 @@
Veilid Tools Tests
Veilid-Tools Tests

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
</component>
</project>

View File

@ -3,13 +3,13 @@ plugins {
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 33
buildToolsVersion "33.0.1"
defaultConfig {
applicationId "com.veilid.veilidtools.veilidtools_android_tests"
applicationId "com.veilid.veilidtools_tests"
minSdkVersion 24
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName "1.0"
@ -38,33 +38,53 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
ndkVersion '22.0.7026061'
ndkVersion '25.1.8937393'
// Required to copy libc++_shared.so
externalNativeBuild {
cmake {
version '3.22.1'
path file('CMakeLists.txt')
}
}
namespace 'com.veilid.veilidtools_tests'
testOptions {
managedDevices {
devices {
pixel2api30 (com.android.build.api.dsl.ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// ATD currently support only API level 30.
apiLevel = 30
// You can also specify "google-atd" if you require Google
// Play Services.
systemImageSource = "aosp-atd"
// Whether the image must be a 64 bit image.
require64Bit = false
}
}
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.security:security-crypto:1.1.0-alpha04'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation 'androidx.test:runner:1.5.1'
androidTestImplementation 'androidx.test:rules:1.5.0'
}
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
cargo {
module = "../../../../../veilid-tools"
module = "../../../../../"
libname = "veilid_tools"
targets = ["arm", "arm64", "x86", "x86_64"]
targetDirectory = "../../../../../target"
targetDirectory = "../../../../../../target"
prebuiltToolchains = true
profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
pythonCommand = "python3"
@ -84,4 +104,3 @@ afterEvaluate {
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.veilid.veilidtools.veilidtools_android_tests">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -13,7 +12,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.VeilidToolsTests">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -1,4 +1,4 @@
package com.veilid.veilidtools.veilidtools_android_tests;
package com.veilid.veilidtools_tests;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
@ -23,6 +23,8 @@ public class MainActivity extends AppCompatActivity {
public void run() {
run_tests(this.context);
((MainActivity)this.context).finish();
System.exit(0);
}
}

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath 'com.android.tools.build:gradle:7.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@ -13,7 +13,7 @@ buildscript {
}
plugins {
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.0"
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.3"
}
allprojects {
@ -25,4 +25,4 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
}

View File

@ -1,6 +1,6 @@
#Mon Jun 21 14:26:26 PDT 2021
#Mon Nov 28 22:38:53 EST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME

View File

@ -1,2 +1,2 @@
include ':app'
rootProject.name = "Veilid Tools Tests"
rootProject.name = "Veilid-Tools Tests"

View File

@ -11,7 +11,7 @@ use jni::{objects::JClass, objects::JObject, JNIEnv};
#[cfg(all(target_os = "android", feature = "android_tests"))]
#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_com_veilid_veilidtools_veilidtools_1android_1tests_MainActivity_run_1tests(
pub extern "system" fn Java_com_veilid_veilidtools_1tests_MainActivity_run_1tests(
env: JNIEnv,
_class: JClass,
ctx: JObject,

View File

@ -22,6 +22,8 @@ pub fn setup() -> () {
builder.set_max_level(Level::TRACE);
builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithConsoleColor);
tracing_wasm::set_as_global_default_with_config(builder.build());
} else {
wasm_logger::init(wasm_logger::Config::default());
}
}
});