Przeglądaj źródła

ci: fix dart pb

appflowy 3 lat temu
rodzic
commit
837666d36d

+ 0 - 1
.github/workflows/ci.yaml

@@ -32,7 +32,6 @@ jobs:
         run: |
           cargo install --force cargo-make
           cargo install --force duckscript_cli
-          brew install protobuf
           cargo make flowy_dev
       - name: Build
         working-directory: frontend

+ 1 - 1
frontend/scripts/makefile/desktop.toml

@@ -5,7 +5,7 @@
 # cargo make --profile production-windows-x86 flowy-sdk-dev
 
 [tasks.env_check]
-dependencies = ["echo_env", "install-pb-tool-if-need"]
+dependencies = ["echo_env", "install_protobuf"]
 condition = { env_set = [ "BUILD_FLAG", "RUST_COMPILE_TARGET", "CRATE_TYPE", "TARGET_OS"],  channels = ["stable"] }
 
 [tasks.flowy-sdk-dev]

+ 16 - 10
frontend/scripts/makefile/protobuf.toml

@@ -2,16 +2,14 @@
 [tasks.pb]
 dependencies = ["check_protoc_cmd", "gen_pb_file"]
 
-[tasks.install-pb-tool-if-need]
+[tasks.install_protobuf]
 condition_script = [
     """
-    if [ ! "$(command -v dart)" ]; then
-        echo Please make sure flutter/dart is properly installed and in PATH env var
-        exit 1
+    if [ ! "$(command -v protoc)" ]; then
+        exit 0
     fi
 
     if [ ! "$(command -v protoc-gen-dart)" ]; then
-        # not install
         exit 0
     fi
 
@@ -19,19 +17,27 @@ condition_script = [
     exit 1
     """,
 ]
-run_task = { name = ["install_protobuf"] }
+run_task = { name = ["install_protobuf_compiler"] }
 
-[tasks.install_protobuf]
+[tasks.install_protobuf_compiler]
 script = """
+brew install protobuf
+
 echo "Install protoc_plugin (Dart)"
 dart pub global activate protoc_plugin
-export PATH="$HOME/.pub-cache/bin:$PATH"
+"""
+script_runner = "@shell"
+
+[tasks.install_protobuf_compiler.linux]
+script = """
+sudo apt-get install protobuf-compiler
 
-cargo install --version 2.22.1 protobuf-codegen
+echo "Install protoc_plugin (Dart)"
+dart pub global activate protoc_plugin
 """
 script_runner = "@shell"
 
-[tasks.install_protobuf.windows]
+[tasks.install_protobuf_compiler.windows]
 script = """
 ret = which dart
 if is_empty ${ret}

+ 3 - 4
shared-lib/lib-infra/src/pb_gen.rs

@@ -4,7 +4,6 @@ use std::fs::File;
 use std::io::Write;
 use walkdir::WalkDir;
 
-#[allow(dead_code)]
 pub fn gen(name: &str, root: &str) {
     let mut paths = vec![];
     let mut file_names = vec![];
@@ -21,8 +20,8 @@ pub fn gen(name: &str, root: &str) {
         }
     }
 
-    // #[cfg(feature = "dart")]
-    // gen_pb_for_dart(name, root, &paths, &file_names);
+    #[cfg(feature = "dart")]
+    gen_pb_for_dart(name, root, &paths, &file_names);
 
     protoc_rust::Codegen::new()
         .out_dir("./src/protobuf/model")
@@ -50,7 +49,7 @@ fn gen_pb_for_dart(name: &str, root: &str, paths: &Vec<String>, file_names: &Vec
         }
         .is_err()
         {
-            panic!("Run flutter protoc fail")
+            panic!("Generate pb file failed with: {}", path)
         };
     });