From ceb39a4fd9f7c569bb26e4c25df0c0d0d0df5fa9 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Tue, 17 Jan 2023 21:54:25 +0800 Subject: [PATCH] chore: add tauri build config (#1717) Co-authored-by: nathan --- frontend/.vscode/launch.json | 94 +++++++++++-------- frontend/.vscode/tasks.json | 14 ++- frontend/appflowy_tauri/src-tauri/src/main.rs | 3 +- .../date_type_option/date_tests.rs | 2 +- frontend/scripts/makefile/desktop.toml | 2 +- 5 files changed, 69 insertions(+), 46 deletions(-) diff --git a/frontend/.vscode/launch.json b/frontend/.vscode/launch.json index f40b4c713e..e089da32ae 100644 --- a/frontend/.vscode/launch.json +++ b/frontend/.vscode/launch.json @@ -4,9 +4,20 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + // This task only builds the Dart code of AppFlowy. + "name": "AF-desktop: Build Dart Only", + "request": "launch", + "program": "./lib/main.dart", + "type": "dart", + "env": { + "RUST_LOG": "debug" + }, + "cwd": "${workspaceRoot}/app_flowy" + }, { // This task builds the Rust and Dart code of AppFlowy. - "name": "AF: Build All", + "name": "AF-desktop: Build All", "request": "launch", "program": "./lib/main.dart", "type": "dart", @@ -17,31 +28,13 @@ "cwd": "${workspaceRoot}/app_flowy" }, { - // This task builds the Rust and Dart code of AppFlowy for android. - "name": "AF: Run Android", + "name": "AF-desktop: Build All (rustlog: trace)", "request": "launch", "program": "./lib/main.dart", "type": "dart", - "preLaunchTask": "AF: build_mobile_sdk", + "preLaunchTask": "AF: build_flowy_sdk", "env": { - "RUST_LOG": "info" - }, - "cwd": "${workspaceRoot}/app_flowy" - }, - { - "name": "AF: Debug Rust", - "request": "attach", - "type": "lldb", - "pid": "${command:pickMyProcess}" - }, - { - // This task only builds the Dart code of AppFlowy. - "name": "AF: Build Dart Only", - "request": "launch", - "program": "./lib/main.dart", - "type": "dart", - "env": { - "RUST_LOG": "debug" + "RUST_LOG": "trace" }, "cwd": "${workspaceRoot}/app_flowy" }, @@ -50,7 +43,7 @@ // - call the clean task, // - rebuild all the generated Files (including freeze and language files) // - rebuild the the Rust and Dart code of AppFlowy. - "name": "AF: Clean + Rebuild All", + "name": "AF-desktop: Clean + Rebuild All", "request": "launch", "program": "./lib/main.dart", "type": "dart", @@ -60,12 +53,35 @@ }, "cwd": "${workspaceRoot}/app_flowy" }, + { + // This task builds the Rust and Dart code of AppFlowy for android. + "name": "AF-android: Build All", + "request": "launch", + "program": "./lib/main.dart", + "type": "dart", + "preLaunchTask": "AF: build_mobile_sdk", + "env": { + "RUST_LOG": "info" + }, + "cwd": "${workspaceRoot}/app_flowy" + }, + { + "name": "AF-android: Build All (rustlog: trace)", + "request": "launch", + "program": "./lib/main.dart", + "type": "dart", + "preLaunchTask": "AF: build_mobile_sdk", + "env": { + "RUST_LOG": "trace" + }, + "cwd": "${workspaceRoot}/app_flowy" + }, { // This task builds will: // - call the clean task, // - rebuild all the generated Files (including freeze and language files) // - rebuild the the Rust and Dart code of AppFlowy. - "name": "AF: Clean + Rebuild All (Android)", + "name": "AF-android: Clean + Rebuild All", "request": "launch", "program": "./lib/main.dart", "type": "dart", @@ -76,26 +92,24 @@ "cwd": "${workspaceRoot}/app_flowy" }, { - "name": "AF: Build All (rustlog: trace)", + "type": "lldb", "request": "launch", - "program": "./lib/main.dart", - "type": "dart", - "preLaunchTask": "AF: build_flowy_sdk", - "env": { - "RUST_LOG": "trace" + "name": "AF: Tauri dev", + "cargo": { + "args": [ + "build", + "--manifest-path=./appflowy_tauri/src-tauri/Cargo.toml", + "--no-default-features" + ] }, - "cwd": "${workspaceRoot}/app_flowy" + "preLaunchTask": "tauri:dev", + "cwd": "${workspaceRoot}/appflowy_tauri/" }, { - "name": "AF: Build All Android (rustlog: trace)", - "request": "launch", - "program": "./lib/main.dart", - "type": "dart", - "preLaunchTask": "AF: build_mobile_sdk", - "env": { - "RUST_LOG": "trace" - }, - "cwd": "${workspaceRoot}/app_flowy" + "name": "AF: Debug Rust", + "request": "attach", + "type": "lldb", + "pid": "${command:pickMyProcess}" }, { "name": "AF: app_flowy (profile mode)", diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index 7e2154ced3..9b3236bcd7 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -168,7 +168,7 @@ { "label": "AF: Rust Clean", "type": "shell", - "command": "cargo make af_dart_clean", + "command": "cargo make dart_clean", "group": "build", "options": { "cwd": "${workspaceFolder}" @@ -185,6 +185,16 @@ "group": "build", "problemMatcher": [], "detail": "app_flowy" - } + }, + { + "label": "tauri:dev", + "type": "shell", + "isBackground": true, + "command": "npm run dev", + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/appflowy_tauri" + } + }, ] } \ No newline at end of file diff --git a/frontend/appflowy_tauri/src-tauri/src/main.rs b/frontend/appflowy_tauri/src-tauri/src/main.rs index 0e0ddeb948..5981ec712b 100644 --- a/frontend/appflowy_tauri/src-tauri/src/main.rs +++ b/frontend/appflowy_tauri/src-tauri/src/main.rs @@ -8,10 +8,9 @@ mod init; mod request; use event::*; -use flowy_core::FlowySDK; use init::*; use request::*; -use tauri::{Manager, State}; +use tauri::Manager; fn main() { let sdk = init_flowy_core(); diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs index e304bf3ef5..1f13271c82 100644 --- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs +++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/date_type_option/date_tests.rs @@ -120,7 +120,7 @@ mod tests { #[test] fn utc_to_native_test() { let native_timestamp = 1647251762; - let native = NaiveDateTime::from_timestamp(native_timestamp, 0); + let native = NaiveDateTime::from_timestamp_opt(native_timestamp, 0).unwrap(); let utc = chrono::DateTime::::from_utc(native, chrono::Utc); // utc_timestamp doesn't carry timezone diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml index 4ad209e5bf..2c0d0f5cd2 100644 --- a/frontend/scripts/makefile/desktop.toml +++ b/frontend/scripts/makefile/desktop.toml @@ -230,7 +230,7 @@ script = [ cd rust-lib/ rustup show echo cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" - cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" + RUST_LOG=${TEST_RUST_LOG} cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" cd ../ """, ]