diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index 34df46ad3e..7ccb8ae3fe 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -14,9 +14,9 @@ "type": "shell", "dependsOrder": "sequence", "dependsOn": [ - "AF: Clean", - "AF: build_flowy_sdk", + "AF: Rust Clean", "AF: Flutter Clean", + "AF: build_flowy_sdk", "AF: Flutter Pub Get", "AF: Flutter Package Get", "AF: Generate Language Files", @@ -139,21 +139,9 @@ } }, { - "label": "AF: Clean", + "label": "AF: Rust Clean", "type": "shell", - "command": "sh ./scripts/clean.sh", - "windows": { - "options": { - "shell": { - "executable": "cmd.exe", - "args": [ - "/d", - "/c", - ".\\scripts\\clean.cmd" - ] - } - } - }, + "command": "cargo make flowy_clean", "group": "build", "options": { "cwd": "${workspaceFolder}" diff --git a/frontend/scripts/clean.cmd b/frontend/scripts/clean.cmd deleted file mode 100644 index 46cf54e69c..0000000000 --- a/frontend/scripts/clean.cmd +++ /dev/null @@ -1,8 +0,0 @@ -cd rust-lib -cargo clean - -cd ../../shared-lib - -if exist "lib-infra/.cache" ( - rmdir /s/q "lib-infra/.cache" -) \ No newline at end of file diff --git a/frontend/scripts/clean.sh b/frontend/scripts/clean.sh deleted file mode 100644 index 619853e2fb..0000000000 --- a/frontend/scripts/clean.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -#!/usr/bin/env fish - -cd rust-lib -cargo clean - -cd ../../shared-lib -cargo clean - -CACHE_FILE=lib-infra/.cache -if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE -fi - - diff --git a/frontend/scripts/makefile/tool.toml b/frontend/scripts/makefile/tool.toml index fcd1d41763..dc840272d5 100644 --- a/frontend/scripts/makefile/tool.toml +++ b/frontend/scripts/makefile/tool.toml @@ -1,29 +1,92 @@ -[tasks.rust_clean] +[tasks.flowy_clean] +run_task = { name = ["cargo_clean","rm_macro_build_cache", "rm_rust_generated_files", "rm_dart_generated_files"] } + +[tasks.cargo_clean] script = [ """ cd rust-lib - cargo clean + cargo clean -q cd ../../shared-lib - cargo clean - - CACHE_FILE=lib-infra/.cache - if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE - fi + cargo clean -q """, ] script_runner = "@shell" -[tasks.rust_clean.windows] + +[tasks.rm_macro_build_cache] script = [ """ - cd rust-lib - cargo clean + path = canonicalize ../shared-lib/lib-infra/.cache + if is_path_exists ${path} + rm -rf ${path} + end + """, +] +script_runner = "@duckscript" + +#Rust Clean +[tasks.rm_rust_generated_files] +run_task = { name = ["rm_rust_lib_generated_protobuf_files", "rm_shared_lib_generated_protobuf_files"] } + +[tasks.rm_rust_lib_generated_protobuf_files] +private = true +env = { "rm_proto_path" = "./rust-lib/**/resources/proto", "rm_protobuf_path" = "./rust-lib/**/protobuf" } +run_task = { name = "remove_files_with_pattern" } + +[tasks.rm_shared_lib_generated_protobuf_files] +private = true +env = { "rm_proto_path" = "./shared-lib/**/resources/proto", "rm_protobuf_path" = "./shared-lib/**/protobuf" } +run_task = { name = "remove_files_with_pattern" } + + +#Dart Clean +[tasks.rm_dart_generated_files] +env = { "dart_flowy_sdk_path" = "./app_flowy/packages/flowy_sdk/" } +run_task = { name = ["rm_dart_generated_protobuf_files"] } + +[tasks.rm_dart_generated_protobuf_files] +private = true +script = [ + """ + protobuf_file_paths = glob_array ${dart_flowy_sdk_path}/lib/protobuf + + if not array_is_empty ${protobuf_file_paths} + echo Remove generated protobuf files: + for path in ${protobuf_file_paths} + echo remove ${path} + rm -rf ${path} + end + end + """, +] +script_runner = "@duckscript" + + +[tasks.remove_files_with_pattern] +private = true +script = [ + """ + proto_file_paths = glob_array ${rm_proto_path} + is_proto_file_paths_empty = array_is_empty ${proto_file_paths} + if not ${is_proto_file_paths_empty} + echo Remove generated proto files: + for path in ${proto_file_paths} + echo remove ${path} + rm -rf ${path} + end + end + + protobuf_file_paths = glob_array ${rm_protobuf_path} + is_protobuf_file_paths_empty = array_is_empty ${protobuf_file_paths} + if not ${is_protobuf_file_paths_empty} + echo Remove generated protobuf files: + for path in ${protobuf_file_paths} + echo remove ${path} + rm -rf ${path} + end + end - cd ../../shared-lib - rmdir /s/q "lib-infra/.cache" """, ] script_runner = "@duckscript" \ No newline at end of file