diff --git a/Cargo.lock b/Cargo.lock
index beb1474b..45ffc1ab 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -77,6 +77,15 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "allo-isolate"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31644a919a9e4b0188e4569e55bbf5a78b5588ea645acffc15c29240407261bc"
+dependencies = [
+ "atomic",
+]
+
[[package]]
name = "alloc_counter"
version = "0.0.4"
@@ -121,6 +130,9 @@ name = "anyhow"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
+dependencies = [
+ "backtrace",
+]
[[package]]
name = "arraydeque"
@@ -355,6 +367,15 @@ dependencies = [
"rustc_version",
]
+[[package]]
+name = "atomic"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c"
+dependencies = [
+ "autocfg",
+]
+
[[package]]
name = "atomic-waker"
version = "1.0.0"
@@ -1393,6 +1414,26 @@ dependencies = [
"yansi",
]
+[[package]]
+name = "flutter_rust_bridge"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39ad509fe9fd3ac5a4d10a30a7de9224b74192c65c22338cc958ab0f93f0c834"
+dependencies = [
+ "allo-isolate",
+ "anyhow",
+ "flutter_rust_bridge_macros",
+ "lazy_static",
+ "parking_lot 0.11.2",
+ "threadpool",
+]
+
+[[package]]
+name = "flutter_rust_bridge_macros"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99a2555456c9c12c5982543c61d79267327d522eaa1490ef4914f5ed87b16fe1"
+
[[package]]
name = "fnv"
version = "1.0.7"
@@ -3583,6 +3624,15 @@ dependencies = [
"syn",
]
+[[package]]
+name = "threadpool"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
+dependencies = [
+ "num_cpus",
+]
+
[[package]]
name = "time"
version = "0.1.43"
@@ -3910,6 +3960,19 @@ dependencies = [
"x25519-dalek-ng",
]
+[[package]]
+name = "veilid-flutter"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "async-std",
+ "cfg-if 1.0.0",
+ "flutter_rust_bridge",
+ "log",
+ "parking_lot 0.12.0",
+ "veilid-core",
+]
+
[[package]]
name = "veilid-server"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index 2bf74cb6..d02c3aaf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,10 +3,11 @@
members = [
"veilid-core",
"veilid-server",
- "veilid-cli"
+ "veilid-cli",
+ "veilid-flutter/rust"
]
-exclude = [ "./external/keyring-rs", "./external/netlink", "./external/cursive", "./veilid-flutter" ]
+exclude = [ "./external/keyring-rs", "./external/netlink", "./external/cursive" ]
[patch.crates-io]
cursive = { path = "./external/cursive/cursive" }
diff --git a/external/keyring-manager b/external/keyring-manager
index 1295d708..935ca957 160000
--- a/external/keyring-manager
+++ b/external/keyring-manager
@@ -1 +1 @@
-Subproject commit 1295d708ec42542f076a13db69eadc448a94f985
+Subproject commit 935ca957d7e223ef560a0b20b656730a325e0ba7
diff --git a/veilid-flutter/android/.gitignore b/veilid-flutter/android/.gitignore
index c6cbe562..161bdcda 100644
--- a/veilid-flutter/android/.gitignore
+++ b/veilid-flutter/android/.gitignore
@@ -6,3 +6,4 @@
.DS_Store
/build
/captures
+.cxx
diff --git a/veilid-flutter/android/CMakeLists.txt b/veilid-flutter/android/CMakeLists.txt
new file mode 100644
index 00000000..57518a5d
--- /dev/null
+++ b/veilid-flutter/android/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(cpplink CXX)
+add_library(cpplink cpplink.cpp)
\ No newline at end of file
diff --git a/veilid-flutter/android/build.gradle b/veilid-flutter/android/build.gradle
index c2c667e9..8e787d30 100644
--- a/veilid-flutter/android/build.gradle
+++ b/veilid-flutter/android/build.gradle
@@ -1,6 +1,3 @@
-group 'com.veilid.veilid'
-version '1.0-SNAPSHOT'
-
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
@@ -14,6 +11,13 @@ buildscript {
}
}
+plugins {
+ id "org.mozilla.rust-android-gradle.rust-android" version "0.9.0"
+}
+
+group 'com.veilid.veilid'
+version '1.0-SNAPSHOT'
+
rootProject.allprojects {
repositories {
google()
@@ -41,10 +45,60 @@ android {
}
defaultConfig {
- minSdkVersion 16
+ minSdkVersion 24
+ targetSdkVersion 30
+ versionCode 1
+ versionName "1.0"
+
+ ndk {
+ abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
+ }
+
+ // Required to copy libc++_shared.so
+ externalNativeBuild {
+ cmake {
+ arguments "-DANDROID_STL=c++_shared"
+ targets "cpplink"
+ }
+ }
+ }
+
+ ndkVersion '22.0.7026061'
+
+ // Required to copy libc++_shared.so
+ externalNativeBuild {
+ cmake {
+ path file('CMakeLists.txt')
+ }
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
+
+apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
+
+cargo {
+ module = "../rust"
+ libname = "veilid_flutter"
+ targets = ["arm", "arm64", "x86", "x86_64"]
+ targetDirectory = "../../target"
+ prebuiltToolchains = true
+ profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
+ // features {
+ // defaultAnd("android_tests")
+ // }
+}
+
+afterEvaluate {
+ // The `cargoBuild` task isn't available until after evaluation.
+ android.libraryVariants.all { variant ->
+ def productFlavor = ""
+ variant.productFlavors.each {
+ productFlavor += "${it.name.capitalize()}"
+ }
+ def buildType = "${variant.buildType.name.capitalize()}"
+ tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
+ }
+}
diff --git a/veilid-flutter/android/cpplink.cpp b/veilid-flutter/android/cpplink.cpp
new file mode 100644
index 00000000..e69de29b
diff --git a/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt b/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt
index c60d5535..013a15a7 100644
--- a/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt
+++ b/veilid-flutter/android/src/main/kotlin/com/veilid/veilid/VeilidPlugin.kt
@@ -14,22 +14,22 @@ class VeilidPlugin: FlutterPlugin, MethodCallHandler {
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
- private lateinit var channel : MethodChannel
+ // private lateinit var channel : MethodChannel
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
- channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
- channel.setMethodCallHandler(this)
+ // channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
+ // channel.setMethodCallHandler(this)
}
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
- if (call.method == "getPlatformVersion") {
- result.success("Android ${android.os.Build.VERSION.RELEASE}")
- } else {
- result.notImplemented()
- }
+ // if (call.method == "getPlatformVersion") {
+ // result.success("Android ${android.os.Build.VERSION.RELEASE}")
+ // } else {
+ result.notImplemented()
+ // }
}
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
- channel.setMethodCallHandler(null)
+ // channel.setMethodCallHandler(null)
}
}
diff --git a/veilid-flutter/example/android/app/build.gradle b/veilid-flutter/example/android/app/build.gradle
index 067ef0b9..bc4e186f 100644
--- a/veilid-flutter/example/android/app/build.gradle
+++ b/veilid-flutter/example/android/app/build.gradle
@@ -44,8 +44,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.veilid.veilid_example"
- minSdkVersion flutter.minSdkVersion
- targetSdkVersion flutter.targetSdkVersion
+ minSdkVersion Math.max(flutter.minSdkVersion, 24)
+ targetSdkVersion Math.max(flutter.targetSdkVersion, 30)
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
diff --git a/veilid-flutter/example/android/app/src/main/AndroidManifest.xml b/veilid-flutter/example/android/app/src/main/AndroidManifest.xml
index f5e02aef..35cc88c9 100644
--- a/veilid-flutter/example/android/app/src/main/AndroidManifest.xml
+++ b/veilid-flutter/example/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
@@ -31,4 +31,9 @@
android:name="flutterEmbedding"
android:value="2" />
+
+
+
+
+
diff --git a/veilid-flutter/rust/build.rs b/veilid-flutter/rust/build.rs
index 7b912c24..9f5a4f8d 100644
--- a/veilid-flutter/rust/build.rs
+++ b/veilid-flutter/rust/build.rs
@@ -14,7 +14,7 @@ fn resolve_llvm_path() -> Option {
// find clang
let d = paths.iter().find_map(|p| {
if p.join("clang").exists() {
- if let Ok(real_clang_path) = fs::canonicalize(p.join("clang")) {
+ if let Ok(real_clang_path) = std::fs::canonicalize(p.join("clang")) {
if let Some(llvmbindir) = real_clang_path.parent() {
if let Some(llvmdir) = llvmbindir.parent() {
return Some(llvmdir.to_owned());