From 3081df429ed355972d60769d91c8ebea07048f4b Mon Sep 17 00:00:00 2001 From: SoLongAndThanksForAllThePizza <103753680+SoLongAndThanksForAllThePizza@users.noreply.github.com> Date: Wed, 25 May 2022 17:20:35 +0800 Subject: [PATCH 1/3] remove flutter generated files --- flutter/.gitignore | 11 ++++++++- .../flutter/generated_plugin_registrant.cc | 15 ------------ .../flutter/generated_plugin_registrant.h | 15 ------------ flutter/linux/flutter/generated_plugins.cmake | 24 ------------------- .../Flutter/GeneratedPluginRegistrant.swift | 24 ------------------- .../flutter/generated_plugin_registrant.cc | 14 ----------- .../flutter/generated_plugin_registrant.h | 15 ------------ .../windows/flutter/generated_plugins.cmake | 24 ------------------- 8 files changed, 10 insertions(+), 132 deletions(-) delete mode 100644 flutter/linux/flutter/generated_plugin_registrant.cc delete mode 100644 flutter/linux/flutter/generated_plugin_registrant.h delete mode 100644 flutter/linux/flutter/generated_plugins.cmake delete mode 100644 flutter/macos/Flutter/GeneratedPluginRegistrant.swift delete mode 100644 flutter/windows/flutter/generated_plugin_registrant.cc delete mode 100644 flutter/windows/flutter/generated_plugin_registrant.h delete mode 100644 flutter/windows/flutter/generated_plugins.cmake diff --git a/flutter/.gitignore b/flutter/.gitignore index ab9a85d6c..7dc95a613 100644 --- a/flutter/.gitignore +++ b/flutter/.gitignore @@ -44,4 +44,13 @@ jniLibs .vscode # flutter rust bridge -lib/generated_bridge.dart \ No newline at end of file +lib/generated_bridge.dart + +# Flutter Generated Files +linux/flutter/generated_plugin_registrant.cc +linux/flutter/generated_plugin_registrant.h +linux/flutter/generated_plugins.cmake +macos/Flutter/GeneratedPluginRegistrant.swift +windows/flutter/generated_plugin_registrant.cc +windows/flutter/generated_plugin_registrant.h +windows/flutter/generated_plugins.cmake \ No newline at end of file diff --git a/flutter/linux/flutter/generated_plugin_registrant.cc b/flutter/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index f6f23bfe9..000000000 --- a/flutter/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); - url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); -} diff --git a/flutter/linux/flutter/generated_plugin_registrant.h b/flutter/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc..000000000 --- a/flutter/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/flutter/linux/flutter/generated_plugins.cmake b/flutter/linux/flutter/generated_plugins.cmake deleted file mode 100644 index f16b4c342..000000000 --- a/flutter/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - url_launcher_linux -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/flutter/macos/Flutter/GeneratedPluginRegistrant.swift b/flutter/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index a540eabec..000000000 --- a/flutter/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - -import firebase_analytics -import firebase_core -import package_info_plus_macos -import path_provider_macos -import shared_preferences_macos -import url_launcher_macos -import wakelock_macos - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin")) - FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) - UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) - WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin")) -} diff --git a/flutter/windows/flutter/generated_plugin_registrant.cc b/flutter/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 4f7884874..000000000 --- a/flutter/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); -} diff --git a/flutter/windows/flutter/generated_plugin_registrant.h b/flutter/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/flutter/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/flutter/windows/flutter/generated_plugins.cmake b/flutter/windows/flutter/generated_plugins.cmake deleted file mode 100644 index 88b22e5c7..000000000 --- a/flutter/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - url_launcher_windows -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) From 4d324063c52684348c5d1821cafd104cb9073dec Mon Sep 17 00:00:00 2001 From: SoLongAndThanksForAllThePizza <103753680+SoLongAndThanksForAllThePizza@users.noreply.github.com> Date: Wed, 25 May 2022 20:23:02 +0800 Subject: [PATCH 2/3] add flutter feature and rename mobile to flutter --- Cargo.toml | 6 ++++-- src/{mobile.rs => flutter.rs} | 0 src/{mobile_ffi.rs => flutter_ffi.rs} | 0 src/lib.rs | 10 +++++----- 4 files changed, 9 insertions(+), 7 deletions(-) rename src/{mobile.rs => flutter.rs} (100%) rename src/{mobile_ffi.rs => flutter_ffi.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index a3e2a66e1..2b707a688 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,8 @@ cli = [] use_samplerate = ["samplerate"] use_rubato = ["rubato"] use_dasp = ["dasp"] -default = ["use_dasp"] +flutter = ["flutter_rust_bridge"] +default = ["use_dasp","flutter"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -52,6 +53,7 @@ rpassword = "6.0" base64 = "0.13" sysinfo = "0.23" num_cpus = "1.13" +flutter_rust_bridge = { version = "1.30.0", optional = true } [target.'cfg(not(target_os = "linux"))'.dependencies] reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features=false } @@ -99,7 +101,7 @@ async-process = "1.3" android_logger = "0.11" jni = "0.19.0" -[target.'cfg(any(target_os = "android", target_os = "ios", target_os = "linux"))'.dependencies] +[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] flutter_rust_bridge = "1.30.0" [workspace] diff --git a/src/mobile.rs b/src/flutter.rs similarity index 100% rename from src/mobile.rs rename to src/flutter.rs diff --git a/src/mobile_ffi.rs b/src/flutter_ffi.rs similarity index 100% rename from src/mobile_ffi.rs rename to src/flutter_ffi.rs diff --git a/src/lib.rs b/src/lib.rs index 556d22594..84d9af8e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,12 +21,12 @@ pub mod ipc; pub mod ui; mod version; pub use version::*; -// #[cfg(any(target_os = "android", target_os = "ios"))] +#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] mod bridge_generated; -// #[cfg(any(target_os = "android", target_os = "ios"))] -pub mod mobile; -// #[cfg(any(target_os = "android", target_os = "ios"))] -pub mod mobile_ffi; +#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] +pub mod flutter; +#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] +pub mod flutter_ffi; use common::*; #[cfg(feature = "cli")] pub mod cli; From 52d4b4226ecafdeb4ea4d2f8a7a564dacc3912b6 Mon Sep 17 00:00:00 2001 From: SoLongAndThanksForAllThePizza <103753680+SoLongAndThanksForAllThePizza@users.noreply.github.com> Date: Wed, 25 May 2022 20:26:46 +0800 Subject: [PATCH 3/3] fix flutter compile on windows --- flutter/windows/runner/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/flutter/windows/runner/CMakeLists.txt b/flutter/windows/runner/CMakeLists.txt index b9e550fba..bcaa06d73 100644 --- a/flutter/windows/runner/CMakeLists.txt +++ b/flutter/windows/runner/CMakeLists.txt @@ -16,6 +16,25 @@ add_executable(${BINARY_NAME} WIN32 "runner.exe.manifest" ) +# flutter_rust_bridge with Corrosion +find_package(Corrosion REQUIRED) + +corrosion_import_crate(MANIFEST_PATH ../../../Cargo.toml + # Equivalent to --all-features passed to cargo build +# [ALL_FEATURES] + # Equivalent to --no-default-features passed to cargo build +# [NO_DEFAULT_FEATURES] + # Disable linking of standard libraries (required for no_std crates). +# [NO_STD] + # Specify cargo build profile (e.g. release or a custom profile) +# [PROFILE ] + # Only import the specified crates from a workspace +# [CRATES ... ] + # Enable the specified features +# [FEATURES ... ] +) +target_link_libraries(${BINARY_NAME} PRIVATE librustdesk) + # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME})