|
@@ -2,6 +2,52 @@
|
|
|
[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
|
|
|
+export PATH="$HOME/.pub-cache/bin:$PATH"
|
|
|
+
|
|
|
+cargo install --version 2.22.1 protobuf-codegen
|
|
|
+"""
|
|
|
+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 = [
|
|
|
"""
|