update flutter_rust_bridge to latest

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-01-19 21:21:28 +08:00
parent b7844d1175
commit ee0e84be37
10 changed files with 122 additions and 103 deletions

View File

@ -70,12 +70,7 @@ jobs:
- name: Install flutter rust bridge deps
run: |
dart pub global activate ffigen --version 5.0.1
$exists = Test-Path ~/.cargo/bin/flutter_rust_bridge_codegen.exe
Push-Location ..
git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1
Push-Location flutter_rust_bridge/frb_codegen ; cargo install --path . ; Pop-Location
Pop-Location
cargo install flutter_rust_bridge_codegen
Push-Location flutter ; flutter pub get ; Pop-Location
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
@ -134,14 +129,7 @@ jobs:
- name: Install flutter rust bridge deps
shell: bash
run: |
dart pub global activate ffigen --version 5.0.1
# flutter_rust_bridge
pushd /tmp
wget https://github.com/Kingtous/flutter_rust_bridge/releases/download/1.32.0-rustdesk/flutter_rust_bridge_codegen-x86_64-darwin.tgz
tar -zxvf flutter_rust_bridge_codegen-x86_64-darwin.tgz
mkdir -p ~/.cargo/bin
mv flutter_rust_bridge_codegen ~/.cargo/bin; chmod +x ~/.cargo/bin/flutter_rust_bridge_codegen
popd
cargo install flutter_rust_bridge_codegen
pushd flutter && flutter pub get && popd
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
@ -307,15 +295,10 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Install ffigen
run: |
dart pub global activate ffigen --version 5.0.1
- name: Install flutter rust bridge deps
shell: bash
run: |
pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 || true && popd
pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . && popd
cargo install flutter_rust_bridge_codegen
pushd flutter && flutter pub get && popd
- name: Run flutter rust bridge
@ -328,6 +311,7 @@ jobs:
name: bridge-artifact
path: |
./src/bridge_generated.rs
./src/bridge_generated.io.rs
./flutter/lib/generated_bridge.dart
./flutter/lib/generated_bridge.freezed.dart

View File

@ -72,12 +72,7 @@ jobs:
- name: Install flutter rust bridge deps
run: |
dart pub global activate ffigen --version 5.0.1
$exists = Test-Path ~/.cargo/bin/flutter_rust_bridge_codegen.exe
Push-Location ..
git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1
Push-Location flutter_rust_bridge/frb_codegen ; cargo install --path . ; Pop-Location
Pop-Location
cargo install flutter_rust_bridge_codegen
Push-Location flutter ; flutter pub get ; Pop-Location
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
@ -213,14 +208,7 @@ jobs:
- name: Install flutter rust bridge deps
shell: bash
run: |
dart pub global activate ffigen --version 5.0.1
# flutter_rust_bridge
pushd /tmp
wget https://github.com/Kingtous/flutter_rust_bridge/releases/download/1.32.0-rustdesk/flutter_rust_bridge_codegen-x86_64-darwin.tgz
tar -zxvf flutter_rust_bridge_codegen-x86_64-darwin.tgz
mkdir -p ~/.cargo/bin
mv flutter_rust_bridge_codegen ~/.cargo/bin; chmod +x ~/.cargo/bin/flutter_rust_bridge_codegen
popd
cargo install flutter_rust_bridge_codegen
pushd flutter && flutter pub get && popd
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
@ -414,15 +402,10 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Install ffigen
run: |
dart pub global activate ffigen --version 5.0.1
- name: Install flutter rust bridge deps
shell: bash
run: |
pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 || true && popd
pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . && popd
cargo install flutter_rust_bridge_codegen
pushd flutter && flutter pub get && popd
- name: Run flutter rust bridge
@ -435,6 +418,7 @@ jobs:
name: bridge-artifact
path: |
./src/bridge_generated.rs
./src/bridge_generated.io.rs
./flutter/lib/generated_bridge.dart
./flutter/lib/generated_bridge.freezed.dart

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ cert.pfx
sciter.dll
**pdb
src/bridge_generated.rs
src/bridge_generated.io.rs
*deb
rustdesk
*.cache

121
Cargo.lock generated
View File

@ -45,11 +45,13 @@ dependencies = [
[[package]]
name = "allo-isolate"
version = "0.1.13"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb993621e6bf1b67591005b0adad126159a0ab31af379743906158aed5330d0"
checksum = "8ed55848be9f41d44c79df6045b680a74a78bc579e0813f7f196cd7928e22fb1"
dependencies = [
"anyhow",
"atomic",
"chrono",
]
[[package]]
@ -471,6 +473,12 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "build-target"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b"
[[package]]
name = "bumpalo"
version = "3.11.1"
@ -565,9 +573,9 @@ dependencies = [
[[package]]
name = "cbindgen"
version = "0.23.0"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b6d248e3ca02f3fbfabcb9284464c596baec223a26d91bbf44a5a62ddb0d900"
checksum = "a6358dedf60f4d9b8db43ad187391afe959746101346fe51bb978126bec61dfb"
dependencies = [
"clap 3.2.23",
"heck 0.4.0",
@ -838,6 +846,16 @@ dependencies = [
"toml",
]
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen",
]
[[package]]
name = "convert_case"
version = "0.5.0"
@ -1335,6 +1353,17 @@ dependencies = [
"byteorder",
]
[[package]]
name = "delegate"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "082a24a9967533dc5d743c602157637116fc1b52806d694a5a45e6f32567fcdd"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "derivative"
version = "2.2.0"
@ -1672,6 +1701,18 @@ version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "extend"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5216e387a76eebaaf11f6d871ec8a4aae0b25f05456ee21f228e024b1b3610"
dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "failure"
version = "0.1.8"
@ -1744,28 +1785,44 @@ dependencies = [
[[package]]
name = "flutter_rust_bridge"
version = "1.32.0"
source = "git+https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge#e5adce55eea0b74d3680e66a2c5252edf17b07e1"
version = "1.61.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8079119bbe8fb63d7ebb731fa2aa68c6c8375f4ac95ca26d5868e64c0f4b9244"
dependencies = [
"allo-isolate",
"anyhow",
"build-target",
"bytemuck",
"cc",
"chrono",
"console_error_panic_hook",
"flutter_rust_bridge_macros",
"js-sys",
"lazy_static",
"libc",
"log",
"parking_lot 0.12.1",
"threadpool",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "flutter_rust_bridge_codegen"
version = "1.32.0"
source = "git+https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge#e5adce55eea0b74d3680e66a2c5252edf17b07e1"
version = "1.61.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd7396bc479eae8aa24243e4c0e3d3dbda1909134f8de6bde4f080d262c9a0d"
dependencies = [
"anyhow",
"cargo_metadata",
"cbindgen",
"clap 3.2.23",
"convert_case",
"delegate",
"enum_dispatch",
"env_logger 0.9.3",
"extend",
"itertools 0.10.5",
"lazy_static",
"log",
"pathdiff",
@ -1773,17 +1830,18 @@ dependencies = [
"regex",
"serde 1.0.149",
"serde_yaml",
"structopt",
"syn",
"tempfile",
"thiserror",
"toml",
"topological-sort",
]
[[package]]
name = "flutter_rust_bridge_macros"
version = "1.32.0"
source = "git+https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge#e5adce55eea0b74d3680e66a2c5252edf17b07e1"
version = "1.61.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d5cd827645690ef378be57a890d0581e17c28d07b712872af7d744f454fd27d"
[[package]]
name = "fnv"
@ -2164,7 +2222,7 @@ checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039"
dependencies = [
"anyhow",
"heck 0.3.3",
"itertools",
"itertools 0.9.0",
"proc-macro-crate 0.1.5",
"proc-macro-error",
"proc-macro2",
@ -2798,6 +2856,15 @@ dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.3.4"
@ -5150,30 +5217,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "structopt"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
dependencies = [
"clap 2.34.0",
"lazy_static",
"structopt-derive",
]
[[package]]
name = "structopt-derive"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [
"heck 0.3.3",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "strum"
version = "0.18.0"
@ -5564,6 +5607,12 @@ dependencies = [
"serde 1.0.149",
]
[[package]]
name = "topological-sort"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d"
[[package]]
name = "tower-service"
version = "0.3.2"

View File

@ -61,7 +61,7 @@ num_cpus = "1.13"
bytes = { version = "1.2", features = ["serde"] }
default-net = { git = "https://github.com/Kingtous/default-net" }
wol-rs = "0.9.1"
flutter_rust_bridge = { git = "https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge", optional = true }
flutter_rust_bridge = { version = "1.61.1", optional = true }
errno = "0.2.8"
rdev = { git = "https://github.com/fufesou/rdev" }
url = { version = "2.1", features = ["serde"] }
@ -126,7 +126,7 @@ android_logger = "0.11"
jni = "0.19"
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
flutter_rust_bridge = { git = "https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge" }
flutter_rust_bridge = "1.61.1"
[workspace]
members = ["libs/scrap", "libs/hbb_common", "libs/enigo", "libs/clipboard", "libs/virtual_display", "libs/virtual_display/dylib", "libs/simple_rc", "libs/portable"]
@ -144,7 +144,7 @@ winapi = { version = "0.3", features = [ "winnt" ] }
cc = "1.0"
hbb_common = { path = "libs/hbb_common" }
simple_rc = { path = "libs/simple_rc", optional = true }
flutter_rust_bridge_codegen = { git = "https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge" }
flutter_rust_bridge_codegen = "1.61.1"
[dev-dependencies]
hound = "3.5"

View File

@ -85,26 +85,35 @@ fn install_oboe() {
#[cfg(feature = "flutter")]
fn gen_flutter_rust_bridge() {
use lib_flutter_rust_bridge_codegen::{
config_parse, frb_codegen, get_symbols_if_no_duplicates, RawOpts,
};
let llvm_path = match std::env::var("LLVM_HOME") {
Ok(path) => Some(vec![path]),
Err(_) => None,
};
// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo:rerun-if-changed=src/flutter_ffi.rs");
// settings for fbr_codegen
let opts = lib_flutter_rust_bridge_codegen::Opts {
// Options for frb_codegen
let raw_opts = RawOpts {
// Path of input Rust code
rust_input: "src/flutter_ffi.rs".to_string(),
rust_input: vec!["src/flutter_ffi.rs".to_string()],
// Path of output generated Dart code
dart_output: "flutter/lib/generated_bridge.dart".to_string(),
dart_output: vec!["flutter/lib/generated_bridge.dart".to_string()],
// Path of output generated C header
c_output: Some(vec!["flutter/macos/Runner/bridge_generated.h".to_string()]),
// for other options lets use default
/// Path to the installed LLVM
llvm_path,
// for other options use defaults
..Default::default()
};
// run fbr_codegen
lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap();
// get opts from raw opts
let configs = config_parse(raw_opts);
// generation of rust api for ffi
let all_symbols = get_symbols_if_no_duplicates(&configs).unwrap();
for config in configs.iter() {
frb_codegen(config, &all_symbols).unwrap();
}
}
fn main() {

View File

@ -1614,15 +1614,6 @@ Widget dialogButton(String text,
}
}
int get_version_num(String version) {
final list = version.split('.');
var n = 0;
for (var i = 0; i < list.length; i++) {
n = n * 1000 + (int.tryParse(list[i]) ?? 0);
}
return n;
}
int version_cmp(String v1, String v2) {
return get_version_num(v1) - get_version_num(v2);
return bind.versionToNumber(v: v1) - bind.versionToNumber(v: v2);
}

View File

@ -1316,14 +1316,14 @@ class FFI {
final cb = ffiModel.startEventListener(id);
() async {
await for (final message in stream) {
if (message is Event) {
if (message is EventToUI_Event) {
try {
Map<String, dynamic> event = json.decode(message.field0);
await cb(event);
} catch (e) {
debugPrint('json.decode fail1(): $e, ${message.field0}');
}
} else if (message is Rgba) {
} else if (message is EventToUI_Rgba) {
imageModel.onRgba(message.field0);
}
}

View File

@ -51,11 +51,7 @@ dependencies:
image_picker: ^0.8.5
image: ^3.1.3
back_button_interceptor: ^6.0.1
flutter_rust_bridge:
git:
url: https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge
ref: master
path: frb_dart
flutter_rust_bridge: ^1.61.1
window_manager:
git:
url: https://github.com/Kingtous/rustdesk_window_manager
@ -103,6 +99,7 @@ dev_dependencies:
build_runner: ^2.1.11
freezed: ^2.0.3
flutter_lints: ^2.0.0
ffigen: ^7.2.4
# rerun: flutter pub run flutter_launcher_icons:main
icons_launcher:

View File

@ -1119,6 +1119,10 @@ pub fn query_onlines(ids: Vec<String>) {
crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines)
}
pub fn version_to_number(v: String) -> SyncReturn<i64> {
SyncReturn(hbb_common::get_version_number(&v))
}
pub fn option_synced() -> bool {
crate::ui_interface::option_synced()
}