diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9faf4070f7..80b6369cbd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,17 +5,47 @@ on: pull_request: branches: [main] jobs: + sdk-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env + rustup toolchain install nightly + rustup default nightly + - name: Frontend tests + run: cd frontend/rust-lib && cargo test + - name: Shared-lib tests + run: cd shared-lib && cargo test build-macos: runs-on: macOS-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Env install - run: cd frontend && make install_rust && make install_cargo_make && cargo make install_targets - - name: Run frontend tests - run: cd frontend/rust-lib && cargo test - - name: Run shared-lib tests - run: cd shared-lib && cargo test + run: cd frontend && make install_rust + - name: Flutter + run: | + git clone --depth 1 -b dev https://github.com/flutter/flutter.git + cd flutter + echo `pwd`"/bin" >> $GITHUB_PATH + export PATH="$PATH:`pwd`/bin" + flutter channel dev + flutter config --enable-macos-desktop + flutter doctor + - name: Deps + run: | + cd frontend + cargo install --force cargo-make + cargo install --force duckscript_cli + cargo make flowy_dev + - name: Build + run: | + cd frontend + cargo make --profile production-mac-x86 appflowy build-ubuntu: runs-on: ubuntu-latest steps: @@ -35,7 +65,7 @@ jobs: rustup default nightly - name: Flutter run: | - git clone https://github.com/flutter/flutter.git + git clone --depth 1 -b dev https://github.com/flutter/flutter.git cd flutter echo `pwd`"/bin" >> $GITHUB_PATH export PATH="$PATH:`pwd`/bin" @@ -48,4 +78,7 @@ jobs: cargo install --force cargo-make cargo install --force duckscript_cli cargo make flowy_dev - cargo make -p development-linux-x86 appflowy-linux-dev + - name: Build + run: | + cd frontend + cargo make --profile production-linux-x86 appflowy diff --git a/.gitignore b/.gitignore index 123bb8854d..59e6eeada1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ Cargo.lock **/*.db .idea/ /flowy-test/ -.ruby-version \ No newline at end of file +.ruby-version diff --git a/doc/BUILD_ON_WINDOWS.md b/doc/BUILD_ON_WINDOWS.md index b10a25bdbc..dfe53b6251 100644 --- a/doc/BUILD_ON_WINDOWS.md +++ b/doc/BUILD_ON_WINDOWS.md @@ -52,16 +52,16 @@ cargo make -p development-windows pb 10. Build flowy-sdk (dart-ffi) ```shell # for development -cargo make --profile development-desktop-windows-x86 flowy-sdk-dev +cargo make --profile development-windows-x86 flowy-sdk-dev # for production -cargo make --profile production-desktop-windows-x86 flowy-sdk-release +cargo make --profile production-windows-x86 flowy-sdk-release ``` 11. Build app_flowy ```shell # for development -cargo make -p development-desktop-windows-x86 appflowy-windows-dev +cargo make -p development-windows-x86 appflowy-windows-dev # for production -cargo make -p production-desktop-windows-x86 appflowy-windows +cargo make -p production-windows-x86 appflowy-windows ``` ## Step 3: Build Server side application (optional if you don't need to host web service locally) diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml index b7b73101c7..181cb51f3e 100644 --- a/frontend/Makefile.toml +++ b/frontend/Makefile.toml @@ -27,14 +27,14 @@ BUILD_FLAG = "debug" FLUTTER_OUTPUT_DIR = "Debug" PRODUCT_EXT = "app" -[env.production-desktop-mac-aarch64] +[env.production-mac-aarch64] BUILD_FLAG = "release" TARGET_OS = "macos" RUST_COMPILE_TARGET = "aarch64-apple-darwin" FLUTTER_OUTPUT_DIR = "Release" PRODUCT_EXT = "app" -[env.production-desktop-mac-x86] +[env.production-mac-x86] BUILD_FLAG = "release" TARGET_OS = "macos" RUST_COMPILE_TARGET = "x86_64-apple-darwin" @@ -42,7 +42,7 @@ FLUTTER_OUTPUT_DIR = "Release" PRODUCT_EXT = "app" -[env.development-desktop-windows-x86] +[env.development-windows-x86] TARGET_OS = "windows" RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc" BUILD_FLAG = "debug" @@ -51,7 +51,7 @@ PRODUCT_EXT = "exe" CRATE_TYPE = "cdylib" SDK_EXT = "dll" -[env.production-desktop-windows-x86] +[env.production-windows-x86] BUILD_FLAG = "release" TARGET_OS = "windows" RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc" @@ -99,6 +99,7 @@ LINUX_ARCH = "arm64" [tasks.echo_env] script = [ ''' + echo "-------- Env Parameters --------" echo CRATE_TYPE: ${CRATE_TYPE} echo BUILD_FLAG: ${BUILD_FLAG} echo TARGET_OS: ${TARGET_OS} @@ -106,9 +107,15 @@ script = [ echo FEATURES: ${FEATURES} echo PRODUCT_EXT: ${PRODUCT_EXT} echo ${platforms} + + echo "-------- Flutter --------" + flutter doctor + + echo "-------- Rust --------" + rustup show ''' ] -script_runner = "@duckscript" +script_runner = "@shell" [env.production-ios] BUILD_FLAG = "release" diff --git a/frontend/app_flowy/windows/.gitignore b/frontend/app_flowy/windows/.gitignore index d492d0d98c..4fe0b7f400 100644 --- a/frontend/app_flowy/windows/.gitignore +++ b/frontend/app_flowy/windows/.gitignore @@ -15,3 +15,7 @@ x86/ *.[Cc]ache # but keep track of directories ending in .cache !*.[Cc]ache/ + +flutter/generated_plugin_registrant.cc +flutter/generated_plugin_registrant.h +flutter/generated_plugins.cmake \ No newline at end of file diff --git a/frontend/app_flowy/windows/flutter/generated_plugin_registrant.cc b/frontend/app_flowy/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index b11b2f204c..0000000000 --- a/frontend/app_flowy/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,26 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - FlowyEditorPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlowyEditorPlugin")); - FlowyInfraUIPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlowyInfraUIPlugin")); - FlowySdkPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlowySdkPlugin")); - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); - WindowSizePluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowSizePlugin")); -} diff --git a/frontend/app_flowy/windows/flutter/generated_plugin_registrant.h b/frontend/app_flowy/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a9..0000000000 --- a/frontend/app_flowy/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/frontend/app_flowy/windows/flutter/generated_plugins.cmake b/frontend/app_flowy/windows/flutter/generated_plugins.cmake deleted file mode 100644 index c8e6921da3..0000000000 --- a/frontend/app_flowy/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - flowy_editor - flowy_infra_ui - flowy_sdk - url_launcher_windows - window_size -) - -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) diff --git a/frontend/rust-lib/flowy-sdk/src/lib.rs b/frontend/rust-lib/flowy-sdk/src/lib.rs index d736d37c54..6df2e4d793 100644 --- a/frontend/rust-lib/flowy-sdk/src/lib.rs +++ b/frontend/rust-lib/flowy-sdk/src/lib.rs @@ -59,6 +59,7 @@ fn crate_log_filter(level: Option) -> String { #[derive(Clone)] pub struct FlowySDK { + #[allow(dead_code)] config: FlowySDKConfig, pub user_session: Arc, pub flowy_document: Arc, diff --git a/frontend/rust-lib/lib-dispatch/src/request/request.rs b/frontend/rust-lib/lib-dispatch/src/request/request.rs index edcfc3fe36..182d3be205 100644 --- a/frontend/rust-lib/lib-dispatch/src/request/request.rs +++ b/frontend/rust-lib/lib-dispatch/src/request/request.rs @@ -17,6 +17,7 @@ use std::{ #[derive(Clone, Debug, Derivative)] pub struct EventRequest { + #[allow(dead_code)] pub(crate) id: String, pub(crate) event: Event, #[derivative(Debug = "ignore")] diff --git a/frontend/rust-lib/lib-sqlite/src/pool.rs b/frontend/rust-lib/lib-sqlite/src/pool.rs index 72b4f95fc6..b0244b58db 100644 --- a/frontend/rust-lib/lib-sqlite/src/pool.rs +++ b/frontend/rust-lib/lib-sqlite/src/pool.rs @@ -101,6 +101,7 @@ pub struct DatabaseCustomizerConfig { pub(crate) journal_mode: SQLiteJournalMode, pub(crate) synchronous: SQLiteSynchronous, pub(crate) busy_timeout: i32, + #[allow(dead_code)] pub(crate) secure_delete: bool, } diff --git a/frontend/scripts/build_sdk.cmd b/frontend/scripts/build_sdk.cmd index e27b4cd3e4..5ddcbd82ab 100644 --- a/frontend/scripts/build_sdk.cmd +++ b/frontend/scripts/build_sdk.cmd @@ -1,3 +1,3 @@ echo "Start building rust sdk" rustup show -cargo make --profile development-desktop-windows-x86 flowy-sdk-dev \ No newline at end of file +cargo make --profile development-windows-x86 flowy-sdk-dev \ No newline at end of file diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml index 981e4a89ce..1f1c16079c 100644 --- a/frontend/scripts/makefile/desktop.toml +++ b/frontend/scripts/makefile/desktop.toml @@ -2,7 +2,7 @@ # Run the task with profile, e.g. # cargo make --profile development-mac flowy-sdk-dev -# cargo make --profile production-desktop-windows-x86 flowy-sdk-dev +# cargo make --profile production-windows-x86 flowy-sdk-dev [tasks.env_check] dependencies = ["echo_env"] diff --git a/frontend/scripts/makefile/env.toml b/frontend/scripts/makefile/env.toml index 5d060231bc..7766130fe6 100644 --- a/frontend/scripts/makefile/env.toml +++ b/frontend/scripts/makefile/env.toml @@ -1,5 +1,5 @@ [tasks.flowy_dev] -run_task = { name = ["install_prerequests","install_diesel", "install_protobuf"] } +run_task = { name = ["install_prerequests","install_diesel"] } [tasks.install_windows_deps.windows] dependencies=["check_duckscript_installation", "check_visual_studio_installation", "check_vcpkg", "install_vcpkg_sqlite", "install_rust_vcpkg_cli"] @@ -66,6 +66,8 @@ dependencies = ["check_vcpkg"] [tasks.install_targets] script = """ +# TODO: download the targets with corresponding platform. For example: +# It's not necessary to download aarch64-apple-ios when compiling the Flowy-SDK on windows. rustup target add x86_64-apple-ios rustup target add x86_64-apple-darwin rustup target add aarch64-apple-ios @@ -90,7 +92,7 @@ script = """ #https://pub.dev/packages/protoc_plugin dart pub global activate protoc_plugin -cargo install --version 2.20.0 protobuf-codegen +cargo install --version 2.22.1 protobuf-codegen """ [tasks.install_protobuf.windows] diff --git a/shared-lib/flowy-document-infra/src/core/history.rs b/shared-lib/flowy-document-infra/src/core/history.rs index 472c574436..d03b8800f4 100644 --- a/shared-lib/flowy-document-infra/src/core/history.rs +++ b/shared-lib/flowy-document-infra/src/core/history.rs @@ -4,7 +4,10 @@ const MAX_UNDOS: usize = 20; #[derive(Debug, Clone)] pub struct UndoResult { + #[allow(dead_code)] success: bool, + + #[allow(dead_code)] len: usize, } @@ -16,6 +19,7 @@ impl UndoResult { #[derive(Debug, Clone)] pub struct History { + #[allow(dead_code)] cur_undo: usize, undos: Vec, redoes: Vec,