[rust]: config build flowy-macos build scripts

This commit is contained in:
appflowy 2021-11-04 18:03:36 +08:00
parent 9e0033f4ed
commit f700f69ac2
6 changed files with 68 additions and 25 deletions

View File

@ -3,6 +3,7 @@ extend = [
{ path = "scripts/makefile/protobuf.toml" },
{ path = "scripts/makefile/tests.toml" },
{ path = "scripts/makefile/docker.toml" },
{ path = "scripts/makefile/flutter.toml" },
]
[env]
@ -17,8 +18,9 @@ PROD = false
TARGET_OS = "macos"
DESKTOP_TARGET = "x86_64-apple-darwin"
crate_type = "cdylib"
LIB_OUT_DIR = "debug"
FLUTTER_OUTPUT = "macos"
BUILD_FLAG = "debug"
CROSS_PLATFORM = "macos"
FLUTTER_OUTPUT_DIR = "Debug"
[env.production-mac]
DEV = false
@ -26,32 +28,36 @@ PROD = true
TARGET_OS = "macos"
DESKTOP_TARGET = "x86_64-apple-darwin"
crate_type = "cdylib"
LIB_OUT_DIR = "release"
FLUTTER_OUTPUT = "macos"
BUILD_FLAG = "release"
CROSS_PLATFORM = "macos"
FLUTTER_OUTPUT_DIR = "Release"
[env.production-ios]
DEV = false
PROD = true
TARGET_OS = "ios"
crate_type = "staticlib"
LIB_OUT_DIR = "release"
FLUTTER_OUTPUT = "ios"
BUILD_FLAG = "release"
CROSS_PLATFORM = "ios"
FLUTTER_OUTPUT_DIR = "Release"
[env.production-android]
DEV = false
PROD = true
TARGET_OS = "android"
crate_type = "cdylib"
LIB_OUT_DIR = "release"
FLUTTER_OUTPUT = "apk"
BUILD_FLAG = "release"
CROSS_PLATFORM = "apk"
FLUTTER_OUTPUT_DIR = "Release"
[env.production-win]
DEV = false
PROD = true
TARGET_OS = "windows"
crate_type = "cdylib"
LIB_OUT_DIR = "release"
FLUTTER_OUTPUT = "apk"
BUILD_FLAG = "release"
CROSS_PLATFORM = "apk"
FLUTTER_OUTPUT_DIR = "Release"
[tasks.setup-crate-type]
private = true

View File

@ -46,4 +46,7 @@ app.*.map.json
/android/app/release
/packages/flowy_protobuf
/packages/flutter-quill
/packages/flutter-quill
product/Release
product/Debug

View File

View File

@ -12,5 +12,5 @@ rustup show
# 2. ~/.bashrc
# 3. ~/.profile
# 4. ~/.zshrc
cargo make desktop
cargo make --profile development-mac flowy-sdk
#cargo make gen_dart_event

View File

@ -3,40 +3,49 @@
[tasks.flowy-sdk]
category = "Build"
condition = { profiles = [ "development-mac" ], channels = ["nightly"] }
dependencies = ["flowy-sdk-build"]
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"] }
[tasks.flowy-sdk-release]
condition = { channels = ["nightly"] }
run_task = "sdk_build"
[tasks.sdk_build]
condition = { platforms = ["mac"], env_true = ["DEV"] }
condition = { platforms = ["mac"] }
description = "Build desktop targets."
script = [
"""
cd rust-lib/
cargo build --package=dart-ffi --target ${DESKTOP_TARGET} --features="observable","http_server"
cargo build --${BUILD_FLAG} --package=dart-ffi --target ${DESKTOP_TARGET} --features="observable","http_server"
cd ../
""",
]
[tasks.post-desktop]
private = true
condition = { platforms = ["mac"] }
script = [
"""
echo "🚀 🚀 🚀 Flowy-SDK build success"
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
""",
"""
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/Classes/binding.h
""",
]
script_runner = "@duckscript"
[tasks.copy-to-sys-tmpdir]
private = true
condition = { platforms = ["mac"] }
script = [
"""
# post the dylib target_path that use for flutter unit test
target_path = set ${TMPDIR}/appflowy_client/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
rm ${target_path}
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${target_path}
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${target_path}
""",
]
script_runner = "@duckscript"

View File

@ -1,15 +1,40 @@
[tasks.flowy-macos-ui]
[tasks.flowy-macos]
dependencies = ["flowy-sdk-build"]
run_task = { name = ["flutter-build", "copy-to-product"] }
script_runner = "@shell"
[tasks.flutter-build]
script = [
"""
flutter clean
flutter pub get
flutter build macos --release
flowy-sdk-release
cd app_flowy/
# flutter clean
# flutter pub get
# flutter build ${CROSS_PLATFORM} --${BUILD_FLAG}
""",
]
script_runner = "@shell"
[tasks.copy-to-product]
script = [
"""
product_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/product
output_path=${product_path}/${FLUTTER_OUTPUT_DIR}
if [ -d "${output_path}" ]; then
rm -rf ${output_path}/
fi
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
""",
]
script_runner = "@shell"
[tasks.freeze_setup]
script = [
"""