[rust]: update script

This commit is contained in:
appflowy 2021-11-04 22:13:05 +08:00
parent f700f69ac2
commit 8edc25168e
6 changed files with 49 additions and 37 deletions

View File

@ -10,61 +10,67 @@ extend = [
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
VERSION = "0.0.1"
#crate_type: https://doc.rust-lang.org/reference/linkage.html
#CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html
[env.development-mac]
DEV = true
PROD = false
TARGET_OS = "macos"
DESKTOP_TARGET = "x86_64-apple-darwin"
crate_type = "cdylib"
CRATE_TYPE = "cdylib"
BUILD_FLAG = "debug"
CROSS_PLATFORM = "macos"
FLUTTER_PLATFORM = "macos"
FLUTTER_OUTPUT_DIR = "Debug"
PRODUCT_NAME = "app_flowy.app"
[env.production-mac]
DEV = false
PROD = true
TARGET_OS = "macos"
DESKTOP_TARGET = "x86_64-apple-darwin"
crate_type = "cdylib"
CRATE_TYPE = "cdylib"
BUILD_FLAG = "release"
CROSS_PLATFORM = "macos"
FLUTTER_PLATFORM = "macos"
FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_NAME = "app_flowy.app"
[env.production-ios]
DEV = false
PROD = true
TARGET_OS = "ios"
crate_type = "staticlib"
CRATE_TYPE = "staticlib"
BUILD_FLAG = "release"
CROSS_PLATFORM = "ios"
FLUTTER_PLATFORM = "ios"
FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_NAME = "app_flowy.ipa"
[env.production-android]
DEV = false
PROD = true
TARGET_OS = "android"
crate_type = "cdylib"
CRATE_TYPE = "cdylib"
BUILD_FLAG = "release"
CROSS_PLATFORM = "apk"
FLUTTER_PLATFORM = "apk"
FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_NAME = "app_flowy.apk"
[env.production-win]
DEV = false
PROD = true
TARGET_OS = "windows"
crate_type = "cdylib"
CRATE_TYPE = "cdylib"
BUILD_FLAG = "release"
CROSS_PLATFORM = "apk"
FLUTTER_PLATFORM = "apk"
FLUTTER_OUTPUT_DIR = "Release"
PRODUCT_NAME = "app_flowy.exe"
[tasks.setup-crate-type]
private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} "rlib" ${crate_type}
val = replace ${toml} "rlib" ${CRATE_TYPE}
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",
@ -76,7 +82,7 @@ private = true
script = [
"""
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
val = replace ${toml} ${crate_type} "rlib"
val = replace ${toml} ${CRATE_TYPE} "rlib"
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
assert ${result}
""",

View File

@ -48,5 +48,5 @@ app.*.map.json
/packages/flowy_protobuf
/packages/flutter-quill
product/Release
product/Debug
product/**/Release
product/**/Debug

View File

@ -35,7 +35,7 @@ flowy-net = {path = "../flowy-net"}
[features]
observable = ["flowy-dart-notify/dart"]
flutter = ["flowy-dart-notify/dart"]
http_server = ["flowy-sdk/http_server", "flowy-sdk/use_bunyan"]
#use_serde = ["bincode"]
#use_protobuf= ["protobuf"]

View File

@ -8,7 +8,7 @@ use async_stream::stream;
use dashmap::DashMap;
use flowy_database::ConnectionPool;
use flowy_infra::future::ResultFuture;
use flowy_ot::core::{Delta, OperationTransformable};
use flowy_ot::core::{Delta, Operation, OperationTransformable};
use futures::stream::StreamExt;
use std::{collections::VecDeque, sync::Arc, time::Duration};
use tokio::{
@ -200,6 +200,16 @@ async fn fetch_from_local(doc_id: &str, persistence: Arc<Persistence>) -> DocRes
},
}
}
match delta.ops.last() {
None => {},
Some(op) => {
let data = op.get_data();
if !data.ends_with("\n") {
log::error!("The op must end with newline");
}
},
}
Result::<Doc, DocError>::Ok(Doc {
id: doc_id,
data: delta.to_json(),

View File

@ -8,19 +8,25 @@ run_task = { name = ["copy-to-sys-tmpdir"] }
[tasks.flowy-sdk-build]
condition = { channels = ["nightly"] }
run_task = { name = ["setup-crate-type","sdk_build", "post-desktop", "restore-crate-type"] }
run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type"] }
[tasks.sdk_build]
[tasks.sdk-build]
condition = { platforms = ["mac"] }
description = "Build desktop targets."
script = [
"""
cd rust-lib/
cargo build --${BUILD_FLAG} --package=dart-ffi --target ${DESKTOP_TARGET} --features="observable","http_server"
if [ ${PROD} == true ]
then
cargo build --${BUILD_FLAG} --package=dart-ffi --target ${DESKTOP_TARGET} --features="flutter","http_server"
else
cargo build --package=dart-ffi --target ${DESKTOP_TARGET} --features="flutter","http_server"
fi
cd ../
""",
]
[tasks.post-desktop]
private = true
condition = { platforms = ["mac"] }
@ -50,11 +56,3 @@ script = [
]
script_runner = "@duckscript"
#[tasks.export-env]
#script = [
# """
# export MACOSX_DEPLOYMENT_TARGET=10.11
# """,
#]
#script_runner = "@shell"

View File

@ -8,9 +8,9 @@ script_runner = "@shell"
script = [
"""
cd app_flowy/
# flutter clean
# flutter pub get
# flutter build ${CROSS_PLATFORM} --${BUILD_FLAG}
flutter clean
flutter pub get
flutter build ${FLUTTER_PLATFORM} --${BUILD_FLAG} --build-name=${VERSION}
""",
]
script_runner = "@shell"
@ -19,17 +19,15 @@ script_runner = "@shell"
[tasks.copy-to-product]
script = [
"""
product_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/product
product_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/product/${VERSION}
output_path=${product_path}/${FLUTTER_OUTPUT_DIR}
if [ -d "${output_path}" ]; then
rm -rf ${output_path}/
fi
mkdir -p ${output_path}
cd ${product_path}
mkdir ${FLUTTER_OUTPUT_DIR}
cp -R ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/build/${CROSS_PLATFORM}/Build/Products/${FLUTTER_OUTPUT_DIR}/app_flowy.app \
${output_path}/app_flowy.app
cp -R ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/build/${FLUTTER_PLATFORM}/Build/Products/${FLUTTER_OUTPUT_DIR}/${PRODUCT_NAME} \
${output_path}/${PRODUCT_NAME}
""",
]
script_runner = "@shell"