mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[rust]: config build script
This commit is contained in:
parent
fac470be99
commit
64fdee588e
@ -9,35 +9,50 @@ extend = [
|
||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
|
||||
CARGO_MAKE_CRATE_NAME = "dart-ffi"
|
||||
|
||||
#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"
|
||||
LIB_OUT_DIR = "debug"
|
||||
RELEASE = false
|
||||
#TARGET_OS = "unknown"
|
||||
|
||||
[env.production-mac]
|
||||
DEV = false
|
||||
PROD = true
|
||||
TARGET_OS = "macos"
|
||||
DESKTOP_TARGET = "x86_64-apple-darwin"
|
||||
crate_type = "cdylib"
|
||||
LIB_OUT_DIR = "release"
|
||||
|
||||
[env.production-ios]
|
||||
DEV = false
|
||||
PROD = true
|
||||
TARGET_OS = "ios"
|
||||
crate_type = "staticlib"
|
||||
LIB_OUT_DIR = "release"
|
||||
|
||||
[env.production-android]
|
||||
DEV = false
|
||||
PROD = true
|
||||
TARGET_OS = "android"
|
||||
crate_type = "cdylib"
|
||||
LIB_OUT_DIR = "release"
|
||||
|
||||
[env.production-win]
|
||||
DEV = false
|
||||
PROD = true
|
||||
TARGET_OS = "windows"
|
||||
crate_type = "cdylib"
|
||||
LIB_OUT_DIR = "release"
|
||||
|
||||
[tasks.setup-crate-type]
|
||||
private = true
|
||||
script = [
|
||||
"""
|
||||
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
|
||||
crate_type = set ""
|
||||
os = get_env TARGET_OS
|
||||
is_android = eq ${os} "android"
|
||||
is_ios = eq ${os} "ios"
|
||||
is_macos = eq ${os} "macos"
|
||||
is_pad = eq ${os} "pad"
|
||||
|
||||
if ${is_android}
|
||||
crate_type = set "cdylib"
|
||||
elseif ${is_ios}
|
||||
crate_type = set "staticlib"
|
||||
elseif ${is_macos}
|
||||
crate_type = set "cdylib"
|
||||
elseif ${is_pad}
|
||||
crate_type = set "cdylib"
|
||||
else
|
||||
crate_type = set "rlib"
|
||||
end
|
||||
|
||||
val = replace ${toml} "rlib" ${crate_type}
|
||||
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
|
||||
assert ${result}
|
||||
@ -45,31 +60,11 @@ script = [
|
||||
]
|
||||
script_runner = "@duckscript"
|
||||
|
||||
|
||||
[tasks.restore-crate-type]
|
||||
private = true
|
||||
script = [
|
||||
"""
|
||||
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
|
||||
crate_type = set ""
|
||||
os = get_env TARGET_OS
|
||||
is_android = eq ${os} "android"
|
||||
is_ios = eq ${os} "ios"
|
||||
is_macos = eq ${os} "macos"
|
||||
is_pad = eq ${os} "pad"
|
||||
|
||||
if ${is_android}
|
||||
crate_type = set "cdylib"
|
||||
elseif ${is_ios}
|
||||
crate_type = set "staticlib"
|
||||
elseif ${is_macos}
|
||||
crate_type = set "cdylib"
|
||||
elseif ${is_pad}
|
||||
crate_type = set "cdylib"
|
||||
else
|
||||
crate_type = set "rlib"
|
||||
end
|
||||
|
||||
val = replace ${toml} ${crate_type} "rlib"
|
||||
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
|
||||
assert ${result}
|
||||
|
@ -1,2 +1,5 @@
|
||||
#[build]
|
||||
#target-dir = "./bin"
|
||||
#target-dir = "./bin"
|
||||
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags=["-C", "link-arg=-mmacosx-version-min=10.11"]
|
@ -1,26 +1,17 @@
|
||||
# cargo make --profile production task
|
||||
|
||||
[tasks.desktop]
|
||||
category = "Build"
|
||||
dependencies = ["desktop-debug", "desktop-release", "post-desktop"]
|
||||
description = "Build desktop targets"
|
||||
|
||||
[tasks.desktop-debug]
|
||||
condition = { env_true = ["DEV"] }
|
||||
env = { DESKTOP_TARGET = "x86_64-apple-darwin" }
|
||||
private = true
|
||||
run_task = { name = ["desktop-build", "post-desktop-dylib-to-system"] }
|
||||
|
||||
condition = { profiles = [ "development-mac" ], channels = ["nightly"] }
|
||||
run_task = { name = ["setup-crate-type","desktop-build", "post-desktop", "restore-crate-type"] }
|
||||
|
||||
[tasks.desktop-release]
|
||||
condition = { env_true = ["RELEASE"] }
|
||||
env = { DESKTOP_TARGET = "x86_64-apple-darwin" }
|
||||
private = true
|
||||
condition = { channels = ["nightly"] }
|
||||
run_task = "desktop-build"
|
||||
|
||||
[tasks.desktop-build]
|
||||
category = "Build"
|
||||
condition = { platforms = ["mac"], env_true = ["DEV"] }
|
||||
dependencies = ["export-env", "setup-crate-type-macos"]
|
||||
description = "Build desktop targets."
|
||||
script = [
|
||||
"""
|
||||
@ -32,7 +23,6 @@ script = [
|
||||
|
||||
[tasks.post-desktop]
|
||||
condition = { platforms = ["mac"] }
|
||||
dependencies = ["restore-crate-type"]
|
||||
script = [
|
||||
"""
|
||||
echo "🚀 🚀 🚀 Flowy-SDK build success"
|
||||
@ -43,42 +33,20 @@ script = [
|
||||
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.setup-crate-type-macos]
|
||||
env = { TARGET_OS = "macos" }
|
||||
private = true
|
||||
run_task = "setup-crate-type"
|
||||
|
||||
[tasks.export-env]
|
||||
script = [
|
||||
"""
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.11
|
||||
""",
|
||||
]
|
||||
script_runner = "@shell"
|
||||
|
||||
[tasks.post-desktop-dylib-to-system]
|
||||
condition = { platforms = ["mac"] }
|
||||
script = [
|
||||
"""
|
||||
target_path = set ${TMPDIR}/appflowy_client/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
|
||||
# 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}
|
||||
# echo "🚀 🚀 🚀 Copy Flowy-SDK to system"
|
||||
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}
|
||||
""",
|
||||
]
|
||||
script_runner = "@duckscript"
|
||||
|
||||
[tasks.clean-flowy-sdk]
|
||||
condition = { platforms = ["mac"] }
|
||||
script = [
|
||||
"""
|
||||
cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_sdk
|
||||
flutter clean
|
||||
""",
|
||||
]
|
||||
script_runner = "@shell"
|
||||
|
||||
#[tasks.export-env]
|
||||
#script = [
|
||||
# """
|
||||
# export MACOSX_DEPLOYMENT_TARGET=10.11
|
||||
# """,
|
||||
#]
|
||||
#script_runner = "@shell"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user