android flutter plugin
This commit is contained in:
parent
32908dd719
commit
a5e4e5c908
63
Cargo.lock
generated
63
Cargo.lock
generated
@ -77,6 +77,15 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "allo-isolate"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "31644a919a9e4b0188e4569e55bbf5a78b5588ea645acffc15c29240407261bc"
|
||||||
|
dependencies = [
|
||||||
|
"atomic",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alloc_counter"
|
name = "alloc_counter"
|
||||||
version = "0.0.4"
|
version = "0.0.4"
|
||||||
@ -121,6 +130,9 @@ name = "anyhow"
|
|||||||
version = "1.0.53"
|
version = "1.0.53"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
|
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
|
||||||
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arraydeque"
|
name = "arraydeque"
|
||||||
@ -355,6 +367,15 @@ dependencies = [
|
|||||||
"rustc_version",
|
"rustc_version",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic-waker"
|
name = "atomic-waker"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -1393,6 +1414,26 @@ dependencies = [
|
|||||||
"yansi",
|
"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]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
@ -3583,6 +3624,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "threadpool"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||||
|
dependencies = [
|
||||||
|
"num_cpus",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.43"
|
version = "0.1.43"
|
||||||
@ -3910,6 +3960,19 @@ dependencies = [
|
|||||||
"x25519-dalek-ng",
|
"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]]
|
[[package]]
|
||||||
name = "veilid-server"
|
name = "veilid-server"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
members = [
|
members = [
|
||||||
"veilid-core",
|
"veilid-core",
|
||||||
"veilid-server",
|
"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]
|
[patch.crates-io]
|
||||||
cursive = { path = "./external/cursive/cursive" }
|
cursive = { path = "./external/cursive/cursive" }
|
||||||
|
2
external/keyring-manager
vendored
2
external/keyring-manager
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 1295d708ec42542f076a13db69eadc448a94f985
|
Subproject commit 935ca957d7e223ef560a0b20b656730a325e0ba7
|
1
veilid-flutter/android/.gitignore
vendored
1
veilid-flutter/android/.gitignore
vendored
@ -6,3 +6,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
.cxx
|
||||||
|
3
veilid-flutter/android/CMakeLists.txt
Normal file
3
veilid-flutter/android/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
project(cpplink CXX)
|
||||||
|
add_library(cpplink cpplink.cpp)
|
@ -1,6 +1,3 @@
|
|||||||
group 'com.veilid.veilid'
|
|
||||||
version '1.0-SNAPSHOT'
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.50'
|
ext.kotlin_version = '1.3.50'
|
||||||
repositories {
|
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 {
|
rootProject.allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@ -41,10 +45,60 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
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 {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
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"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0
veilid-flutter/android/cpplink.cpp
Normal file
0
veilid-flutter/android/cpplink.cpp
Normal file
@ -14,22 +14,22 @@ class VeilidPlugin: FlutterPlugin, MethodCallHandler {
|
|||||||
///
|
///
|
||||||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
||||||
/// when the Flutter Engine is detached from the Activity
|
/// 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) {
|
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
|
// channel = MethodChannel(flutterPluginBinding.binaryMessenger, "veilid")
|
||||||
channel.setMethodCallHandler(this)
|
// channel.setMethodCallHandler(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
||||||
if (call.method == "getPlatformVersion") {
|
// if (call.method == "getPlatformVersion") {
|
||||||
result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
// result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
||||||
} else {
|
// } else {
|
||||||
result.notImplemented()
|
result.notImplemented()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
channel.setMethodCallHandler(null)
|
// channel.setMethodCallHandler(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.veilid.veilid_example"
|
applicationId "com.veilid.veilid_example"
|
||||||
minSdkVersion flutter.minSdkVersion
|
minSdkVersion Math.max(flutter.minSdkVersion, 24)
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion Math.max(flutter.targetSdkVersion, 30)
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.veilid.veilid_example">
|
package="com.veilid.veilid_example">
|
||||||
<application
|
<application
|
||||||
android:label="veilid_example"
|
android:label="veilid_example"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
@ -31,4 +31,9 @@
|
|||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -14,7 +14,7 @@ fn resolve_llvm_path() -> Option<PathBuf> {
|
|||||||
// find clang
|
// find clang
|
||||||
let d = paths.iter().find_map(|p| {
|
let d = paths.iter().find_map(|p| {
|
||||||
if p.join("clang").exists() {
|
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(llvmbindir) = real_clang_path.parent() {
|
||||||
if let Some(llvmdir) = llvmbindir.parent() {
|
if let Some(llvmdir) = llvmbindir.parent() {
|
||||||
return Some(llvmdir.to_owned());
|
return Some(llvmdir.to_owned());
|
||||||
|
Loading…
Reference in New Issue
Block a user