Browse Source

Merge branch 'AppFlowy-IO:main' into main

Hari07 3 years ago
parent
commit
5c5f0f6a1e

+ 40 - 7
.github/workflows/ci.yaml

@@ -5,17 +5,47 @@ on:
   pull_request:
   pull_request:
     branches: [main]
     branches: [main]
 jobs:
 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:
   build-macos:
     runs-on: macOS-latest
     runs-on: macOS-latest
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@v2
         uses: actions/checkout@v2
       - name: Env install
       - 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:
   build-ubuntu:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     steps:
     steps:
@@ -35,7 +65,7 @@ jobs:
           rustup default nightly
           rustup default nightly
       - name: Flutter
       - name: Flutter
         run: |
         run: |
-          git clone https://github.com/flutter/flutter.git
+          git clone --depth 1 -b dev https://github.com/flutter/flutter.git
           cd flutter
           cd flutter
           echo `pwd`"/bin" >> $GITHUB_PATH
           echo `pwd`"/bin" >> $GITHUB_PATH
           export PATH="$PATH:`pwd`/bin"
           export PATH="$PATH:`pwd`/bin"
@@ -48,4 +78,7 @@ jobs:
           cargo install --force cargo-make
           cargo install --force cargo-make
           cargo install --force duckscript_cli
           cargo install --force duckscript_cli
           cargo make flowy_dev
           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

+ 1 - 1
.gitignore

@@ -12,4 +12,4 @@ Cargo.lock
 **/*.db
 **/*.db
 .idea/
 .idea/
 /flowy-test/
 /flowy-test/
-.ruby-version
+.ruby-version

+ 4 - 4
doc/BUILD_ON_WINDOWS.md

@@ -52,16 +52,16 @@ cargo make -p development-windows pb
 10. Build flowy-sdk (dart-ffi)
 10. Build flowy-sdk (dart-ffi)
 ```shell
 ```shell
 # for development
 # for development
-cargo make --profile development-desktop-windows-x86 flowy-sdk-dev
+cargo make --profile development-windows-x86 flowy-sdk-dev
 # for production
 # 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
 11. Build app_flowy
 ```shell
 ```shell
 # for development
 # for development
-cargo make -p development-desktop-windows-x86 appflowy-windows-dev
+cargo make -p development-windows-x86 appflowy-windows-dev
 # for production
 # 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)
 ## Step 3: Build Server side application (optional if you don't need to host web service locally)

+ 12 - 5
frontend/Makefile.toml

@@ -27,14 +27,14 @@ BUILD_FLAG = "debug"
 FLUTTER_OUTPUT_DIR = "Debug"
 FLUTTER_OUTPUT_DIR = "Debug"
 PRODUCT_EXT = "app"
 PRODUCT_EXT = "app"
 
 
-[env.production-desktop-mac-aarch64]
+[env.production-mac-aarch64]
 BUILD_FLAG = "release"
 BUILD_FLAG = "release"
 TARGET_OS = "macos"
 TARGET_OS = "macos"
 RUST_COMPILE_TARGET = "aarch64-apple-darwin"
 RUST_COMPILE_TARGET = "aarch64-apple-darwin"
 FLUTTER_OUTPUT_DIR = "Release"
 FLUTTER_OUTPUT_DIR = "Release"
 PRODUCT_EXT = "app"
 PRODUCT_EXT = "app"
 
 
-[env.production-desktop-mac-x86]
+[env.production-mac-x86]
 BUILD_FLAG = "release"
 BUILD_FLAG = "release"
 TARGET_OS = "macos"
 TARGET_OS = "macos"
 RUST_COMPILE_TARGET = "x86_64-apple-darwin"
 RUST_COMPILE_TARGET = "x86_64-apple-darwin"
@@ -42,7 +42,7 @@ FLUTTER_OUTPUT_DIR = "Release"
 PRODUCT_EXT = "app"
 PRODUCT_EXT = "app"
 
 
 
 
-[env.development-desktop-windows-x86]
+[env.development-windows-x86]
 TARGET_OS = "windows"
 TARGET_OS = "windows"
 RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
 RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
 BUILD_FLAG = "debug"
 BUILD_FLAG = "debug"
@@ -51,7 +51,7 @@ PRODUCT_EXT = "exe"
 CRATE_TYPE = "cdylib"
 CRATE_TYPE = "cdylib"
 SDK_EXT = "dll"
 SDK_EXT = "dll"
 
 
-[env.production-desktop-windows-x86]
+[env.production-windows-x86]
 BUILD_FLAG = "release"
 BUILD_FLAG = "release"
 TARGET_OS = "windows"
 TARGET_OS = "windows"
 RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
 RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
@@ -99,6 +99,7 @@ LINUX_ARCH = "arm64"
 [tasks.echo_env]
 [tasks.echo_env]
 script = [
 script = [
     '''
     '''
+    echo "-------- Env Parameters --------"
     echo CRATE_TYPE: ${CRATE_TYPE}
     echo CRATE_TYPE: ${CRATE_TYPE}
     echo BUILD_FLAG: ${BUILD_FLAG}
     echo BUILD_FLAG: ${BUILD_FLAG}
     echo TARGET_OS: ${TARGET_OS}
     echo TARGET_OS: ${TARGET_OS}
@@ -106,9 +107,15 @@ script = [
     echo FEATURES: ${FEATURES}
     echo FEATURES: ${FEATURES}
     echo PRODUCT_EXT: ${PRODUCT_EXT}
     echo PRODUCT_EXT: ${PRODUCT_EXT}
     echo ${platforms}
     echo ${platforms}
+
+    echo "-------- Flutter --------"
+    flutter doctor
+
+    echo "-------- Rust --------"
+    rustup show
     '''
     '''
 ]
 ]
-script_runner = "@duckscript"
+script_runner = "@shell"
 
 
 [env.production-ios]
 [env.production-ios]
 BUILD_FLAG = "release"
 BUILD_FLAG = "release"

+ 4 - 0
frontend/app_flowy/windows/.gitignore

@@ -15,3 +15,7 @@ x86/
 *.[Cc]ache
 *.[Cc]ache
 # but keep track of directories ending in .cache
 # but keep track of directories ending in .cache
 !*.[Cc]ache/
 !*.[Cc]ache/
+
+flutter/generated_plugin_registrant.cc
+flutter/generated_plugin_registrant.h
+flutter/generated_plugins.cmake

+ 0 - 26
frontend/app_flowy/windows/flutter/generated_plugin_registrant.cc

@@ -1,26 +0,0 @@
-//
-//  Generated file. Do not edit.
-//
-
-// clang-format off
-
-#include "generated_plugin_registrant.h"
-
-#include <flowy_editor/flowy_editor_plugin.h>
-#include <flowy_infra_ui/flowy_infra_u_i_plugin.h>
-#include <flowy_sdk/flowy_sdk_plugin.h>
-#include <url_launcher_windows/url_launcher_windows.h>
-#include <window_size/window_size_plugin.h>
-
-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"));
-}

+ 0 - 15
frontend/app_flowy/windows/flutter/generated_plugin_registrant.h

@@ -1,15 +0,0 @@
-//
-//  Generated file. Do not edit.
-//
-
-// clang-format off
-
-#ifndef GENERATED_PLUGIN_REGISTRANT_
-#define GENERATED_PLUGIN_REGISTRANT_
-
-#include <flutter/plugin_registry.h>
-
-// Registers Flutter plugins.
-void RegisterPlugins(flutter::PluginRegistry* registry);
-
-#endif  // GENERATED_PLUGIN_REGISTRANT_

+ 0 - 20
frontend/app_flowy/windows/flutter/generated_plugins.cmake

@@ -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 $<TARGET_FILE:${plugin}_plugin>)
-  list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
-endforeach(plugin)

+ 1 - 0
frontend/rust-lib/flowy-sdk/src/lib.rs

@@ -59,6 +59,7 @@ fn crate_log_filter(level: Option<String>) -> String {
 
 
 #[derive(Clone)]
 #[derive(Clone)]
 pub struct FlowySDK {
 pub struct FlowySDK {
+    #[allow(dead_code)]
     config: FlowySDKConfig,
     config: FlowySDKConfig,
     pub user_session: Arc<UserSession>,
     pub user_session: Arc<UserSession>,
     pub flowy_document: Arc<FlowyDocument>,
     pub flowy_document: Arc<FlowyDocument>,

+ 1 - 0
frontend/rust-lib/lib-dispatch/src/request/request.rs

@@ -17,6 +17,7 @@ use std::{
 
 
 #[derive(Clone, Debug, Derivative)]
 #[derive(Clone, Debug, Derivative)]
 pub struct EventRequest {
 pub struct EventRequest {
+    #[allow(dead_code)]
     pub(crate) id: String,
     pub(crate) id: String,
     pub(crate) event: Event,
     pub(crate) event: Event,
     #[derivative(Debug = "ignore")]
     #[derivative(Debug = "ignore")]

+ 1 - 0
frontend/rust-lib/lib-sqlite/src/pool.rs

@@ -101,6 +101,7 @@ pub struct DatabaseCustomizerConfig {
     pub(crate) journal_mode: SQLiteJournalMode,
     pub(crate) journal_mode: SQLiteJournalMode,
     pub(crate) synchronous: SQLiteSynchronous,
     pub(crate) synchronous: SQLiteSynchronous,
     pub(crate) busy_timeout: i32,
     pub(crate) busy_timeout: i32,
+    #[allow(dead_code)]
     pub(crate) secure_delete: bool,
     pub(crate) secure_delete: bool,
 }
 }
 
 

+ 1 - 1
frontend/scripts/build_sdk.cmd

@@ -1,3 +1,3 @@
 echo "Start building rust sdk"
 echo "Start building rust sdk"
 rustup show
 rustup show
-cargo make --profile development-desktop-windows-x86 flowy-sdk-dev
+cargo make --profile development-windows-x86 flowy-sdk-dev

+ 1 - 1
frontend/scripts/makefile/desktop.toml

@@ -2,7 +2,7 @@
 
 
 # Run the task with profile, e.g.
 # Run the task with profile, e.g.
 # cargo make --profile development-mac flowy-sdk-dev
 # 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]
 [tasks.env_check]
 dependencies = ["echo_env"]
 dependencies = ["echo_env"]

+ 4 - 2
frontend/scripts/makefile/env.toml

@@ -1,5 +1,5 @@
 [tasks.flowy_dev]
 [tasks.flowy_dev]
-run_task = { name = ["install_prerequests","install_diesel", "install_protobuf"] }
+run_task = { name = ["install_prerequests","install_diesel"] }
 
 
 [tasks.install_windows_deps.windows]
 [tasks.install_windows_deps.windows]
 dependencies=["check_duckscript_installation", "check_visual_studio_installation", "check_vcpkg", "install_vcpkg_sqlite", "install_rust_vcpkg_cli"]
 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]
 [tasks.install_targets]
 script = """
 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-ios
 rustup target add x86_64-apple-darwin
 rustup target add x86_64-apple-darwin
 rustup target add aarch64-apple-ios
 rustup target add aarch64-apple-ios
@@ -90,7 +92,7 @@ script = """
 #https://pub.dev/packages/protoc_plugin
 #https://pub.dev/packages/protoc_plugin
 dart pub global activate 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]
 [tasks.install_protobuf.windows]

+ 4 - 0
shared-lib/flowy-document-infra/src/core/history.rs

@@ -4,7 +4,10 @@ const MAX_UNDOS: usize = 20;
 
 
 #[derive(Debug, Clone)]
 #[derive(Debug, Clone)]
 pub struct UndoResult {
 pub struct UndoResult {
+    #[allow(dead_code)]
     success: bool,
     success: bool,
+
+    #[allow(dead_code)]
     len: usize,
     len: usize,
 }
 }
 
 
@@ -16,6 +19,7 @@ impl UndoResult {
 
 
 #[derive(Debug, Clone)]
 #[derive(Debug, Clone)]
 pub struct History {
 pub struct History {
+    #[allow(dead_code)]
     cur_undo: usize,
     cur_undo: usize,
     undos: Vec<Delta>,
     undos: Vec<Delta>,
     redoes: Vec<Delta>,
     redoes: Vec<Delta>,