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.

feat: install protoc-gen-dart if not installed

appflowyf55de1fd1725
diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml
index cab4dcba60..157b1a4b92 100644
--- a/frontend/scripts/makefile/desktop.toml
+++ b/frontend/scripts/makefile/desktop.toml
@@ -5,7 +5,7 @@
# cargo make --profile production-windows-x86 flowy-sdk-dev
[tasks.env_check]
-dependencies = ["echo_env"]
+dependencies = ["echo_env", "install-pb-tool-if-need"]
condition = { env_set = [ "BUILD_FLAG", "RUST_COMPILE_TARGET", "CRATE_TYPE", "TARGET_OS"], channels = ["stable"] }
[tasks.flowy-sdk-dev]
@@ -142,3 +142,16 @@ script = [
""",
]
script_runner = "@duckscript"
+
+[tasks.check_protoc_cmd]
+script = [
+ """
+ ret = which protoc
+ if is_empty ${ret}
+ echo Please make sure <protoc_installation_folder>/bin/ is in PATH env var
+ echo See BUILD_ON_{LINUX|WINDOWS}.md for how to get protoc
+ exit -1
+ end
+ """,
+]
+script_runner = "@duckscript"
diff --git a/frontend/scripts/makefile/env.toml b/frontend/scripts/makefile/env.toml
index 4bf1122e02..8e4d130a61 100644
--- a/frontend/scripts/makefile/env.toml
+++ b/frontend/scripts/makefile/env.toml
@@ -1,5 +1,5 @@
[tasks.flowy_dev]
-run_task = { name = ["install_prerequests","install_diesel", "install_protobuf"] }
+run_task = { name = ["install_prerequests","install_diesel"] }
[tasks.install_windows_deps.windows]
dependencies=["check_duckscript_installation", "check_visual_studio_installation", "check_vcpkg", "install_vcpkg_sqlite", "install_rust_vcpkg_cli"]
@@ -95,30 +95,6 @@ dependencies=["install_targets"]
[tasks.install_prerequests.windows]
dependencies=["install_targets", "install_windows_deps"]
-[tasks.install_protobuf]
-script = """
-dart pub global activate protoc_plugin
-cargo install --version 2.22.1 protobuf-codegen
-"""
-
-[tasks.install_protobuf.windows]
-script = """
-ret = which dart
-if is_empty ${ret}
- echo Please make sure flutter/dart is properly installed and in PATH env var
- exit -1
-end
-ret = which protoc-gen-dart
-if is_empty ${ret}
- exec cmd.exe /c dart pub global activate protoc_plugin
- home_dir = get_home_dir
- echo Please add '${home_dir}\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\bin' into PATH env var
- exit -1
-end
-exec cargo install --version 2.22.1 protobuf-codegen
-"""
-script_runner = "@duckscript"
-
[tasks.install_tools]
script = """
rustup component add rustfmt
diff --git a/frontend/scripts/makefile/protobuf.toml b/frontend/scripts/makefile/protobuf.toml
index 6cef4512d2..b1a0beacfb 100644
--- a/frontend/scripts/makefile/protobuf.toml
+++ b/frontend/scripts/makefile/protobuf.toml
@@ -2,6 +2,49 @@
[tasks.pb]
dependencies = ["check_protoc_cmd", "gen_pb_file"]
+[tasks.install-pb-tool-if-need]
+condition_script = [
+ """
+ if [ ! "$(command -v dart)" ]; then
+ echo Please make sure flutter/dart is properly installed and in PATH env var
+ exit 1
+ fi
+
+ if [ ! "$(command -v protoc-gen-dart)" ]; then
+ # not install
+ exit 0
+ fi
+
+ # installed
+ exit 1
+ """,
+]
+run_task = { name = ["install_protobuf"] }
+
+[tasks.install_protobuf]
+script = """
+echo "Install protoc_plugin (Dart)"
+dart pub global activate protoc_plugin
+"""
+script_runner = "@shell"
+
+[tasks.install_protobuf.windows]
+script = """
+ret = which dart
+if is_empty ${ret}
+ echo Please make sure flutter/dart is properly installed and in PATH env var
+ exit -1
+end
+ret = which protoc-gen-dart
+if is_empty ${ret}
+ exec cmd.exe /c dart pub global activate protoc_plugin
+ home_dir = get_home_dir
+ echo Please add '${home_dir}\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\bin' into PATH env var
+ exit -1
+end
+"""
+script_runner = "@duckscript"
+
[tasks.check_protoc_cmd]
script = [
"""