Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: update cargo build profile (#3332)

Nathan.fooo790580eea493
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index d86c3e5b66..74b3af4376 100644
--- a/frontend/Makefile.toml
+++ b/frontend/Makefile.toml
@@ -20,6 +20,7 @@ run_task = { name = ["restore-crate-type"] }
[env]
RUST_LOG = "info"
+CARGO_PROFILE = "dev"
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
@@ -75,6 +76,7 @@ BUILD_ACTIVE_ARCHS_ONLY = true
CRATE_TYPE = "staticlib"
[env.production-mac-arm64]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "macos"
RUST_COMPILE_TARGET = "aarch64-apple-darwin"
@@ -86,6 +88,7 @@ BUILD_ACTIVE_ARCHS_ONLY = false
CRATE_TYPE = "staticlib"
[env.production-mac-x86_64]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "macos"
RUST_COMPILE_TARGET = "x86_64-apple-darwin"
@@ -97,6 +100,7 @@ BUILD_ACTIVE_ARCHS_ONLY = false
CRATE_TYPE = "staticlib"
[env.production-mac-universal]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "macos"
FLUTTER_OUTPUT_DIR = "Release"
@@ -114,6 +118,7 @@ CRATE_TYPE = "cdylib"
LIB_EXT = "dll"
[env.production-windows-x86]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "windows"
RUST_COMPILE_TARGET = "x86_64-pc-windows-msvc"
@@ -133,6 +138,7 @@ LIB_EXT = "so"
LINUX_ARCH = "x64"
[env.production-linux-x86_64]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "linux"
RUST_COMPILE_TARGET = "x86_64-unknown-linux-gnu"
@@ -153,6 +159,7 @@ LINUX_ARCH = "arm64"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
[env.production-linux-aarch64]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "linux"
RUST_COMPILE_TARGET = "aarch64-unknown-linux-gnu"
@@ -202,6 +209,7 @@ FLUTTER_OUTPUT_DIR = "Debug"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite,openssl_vendored"
[env.production-android]
+CARGO_PROFILE = "release"
BUILD_FLAG = "release"
TARGET_OS = "android"
CRATE_TYPE = "cdylib"
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 149d15b8b0..6f1952866c 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -27,11 +27,20 @@ members = [
[profile.dev]
opt-level = 0
-#https://doc.rust-lang.org/rustc/codegen-options/index.html#debug-assertions
-#split-debuginfo = "unpacked"
+lto = false
+codegen-units = 16
[profile.release]
+lto = true
opt-level = 3
+codegen-units = 1
+
+[profile.profiling]
+inherits = "release"
+debug = true
+codegen-units = 16
+lto = false
+
## debuginfo — it makes ./target much bigger, which again harms caching. Depending on your preferred workflow,
## you might consider disabling debuginfo unconditionally, this brings some benefits for local builds as well.
#strip = "debuginfo"
diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml
index e7784f6594..59d8d50ce4 100644
--- a/frontend/scripts/makefile/desktop.toml
+++ b/frontend/scripts/makefile/desktop.toml
@@ -20,7 +20,7 @@ category = "Build"
dependencies = ["env_check"]
run_task = { name = [
"setup-crate-type",
- "sdk-build",
+ "sdk-dev-build",
"post-desktop",
"restore-crate-type",
] }
@@ -30,7 +30,7 @@ category = "Build"
dependencies = ["env_check"]
run_task = { name = [
"setup-crate-type",
- "sdk-build",
+ "sdk-dev-build",
"post-desktop",
"restore-crate-type",
] }
@@ -40,13 +40,13 @@ category = "Build"
dependencies = ["env_check"]
run_task = { name = [
"setup-crate-type",
- "sdk-build",
+ "sdk-dev-build",
"post-desktop",
"restore-crate-type",
] }
#
-[tasks.sdk-build]
+[tasks.sdk-dev-build]
private = true
script = [
"""
@@ -59,7 +59,7 @@ script = [
]
script_runner = "@shell"
-[tasks.sdk-build.mac]
+[tasks.sdk-dev-build.mac]
private = true
script = [
"""
@@ -72,7 +72,7 @@ script = [
]
script_runner = "@shell"
-[tasks.sdk-build-android]
+[tasks.sdk-dev-build-android]
private = true
script = [
"""
@@ -98,7 +98,7 @@ script = [
]
script_runner = "@shell"
-[tasks.sdk-build.windows]
+[tasks.sdk-dev-build.windows]
private = true
script = [
"""
@@ -126,7 +126,7 @@ run_task = { name = [
script = [
"""
cd rust-lib/
- cargo build --${BUILD_FLAG} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
+ cargo build --profile ${CARGO_PROFILE} --${BUILD_FLAG} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
cd ../
""",
]