From ceaf1ccc211d9ee5412f9198ccf9b36d0e9d8325 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 17 Feb 2022 16:32:10 +0800 Subject: [PATCH] feat: fix windows build erros --- frontend/.vscode/tasks.json | 21 + frontend/app_flowy/.vscode/launch.json | 7 - frontend/app_flowy/.vscode/tasks.json | 7 +- .../dart_event/flowy-folder/dart_event.dart | 410 ------------------ .../dart_event/flowy-net/dart_event.dart | 17 - .../dart_event/flowy-user/dart_event.dart | 138 ------ .../lib/protobuf/dart-ffi/protobuf.dart | 2 +- .../flowy-collaboration/protobuf.dart | 6 +- .../flowy-folder-data-model/protobuf.dart | 4 +- .../lib/protobuf/flowy-net/protobuf.dart | 2 +- .../flowy-user-data-model/protobuf.dart | 2 +- frontend/rust-lib/dart-ffi/Cargo.toml | 4 +- frontend/scripts/clean.cmd | 2 +- frontend/scripts/makefile/protobuf.toml | 36 +- .../src/code_gen/protobuf_file/mod.rs | 51 +-- 15 files changed, 76 insertions(+), 633 deletions(-) diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index e6d25b9352..e902e3dfd5 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -70,6 +70,27 @@ "options": { "cwd": "${workspaceFolder}" }, + }, + { + "label": "Clean", + "type": "shell", + "command": "sh ./scripts/clean.sh", + "windows": { + "options": { + "shell": { + "executable": "cmd.exe", + "args": [ + "/d", + "/c", + ".\\scripts\\clean.cmd" + ] + } + } + }, + "group": "build", + "options": { + "cwd": "${workspaceFolder}" + }, } ] } \ No newline at end of file diff --git a/frontend/app_flowy/.vscode/launch.json b/frontend/app_flowy/.vscode/launch.json index e0d00d7407..c7236062fd 100644 --- a/frontend/app_flowy/.vscode/launch.json +++ b/frontend/app_flowy/.vscode/launch.json @@ -40,12 +40,5 @@ "preLaunchTask": "Generate Language Files", "cwd": "${workspaceRoot}" }, - { - "name": "Clean", - "request": "launch", - "type": "dart", - "preLaunchTask": "Clean", - "cwd": "${workspaceRoot}" - } ] } \ No newline at end of file diff --git a/frontend/app_flowy/.vscode/tasks.json b/frontend/app_flowy/.vscode/tasks.json index 8d012c40e5..fcf7a23250 100644 --- a/frontend/app_flowy/.vscode/tasks.json +++ b/frontend/app_flowy/.vscode/tasks.json @@ -72,7 +72,7 @@ }, }, { - "label": "Clean FlowySDK", + "label": "Clean", "type": "shell", "command": "sh ./scripts/clean.sh", "windows": { @@ -87,7 +87,10 @@ } } }, - "group": "build", + "group": { + "kind": "build", + "isDefault": true, + }, "options": { "cwd": "${workspaceFolder}/../" }, diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart index 21f7f3c598..93aff2384d 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-folder/dart_event.dart @@ -1,413 +1,3 @@ /// Auto generate. Do not edit part of '../../dispatch.dart'; -class FolderEventCreateWorkspace { - CreateWorkspaceRequest request; - FolderEventCreateWorkspace(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.CreateWorkspace.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(Workspace.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadCurWorkspace { - FolderEventReadCurWorkspace(); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadCurWorkspace.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (okBytes) => left(CurrentWorkspaceSetting.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadWorkspaces { - QueryWorkspaceRequest request; - FolderEventReadWorkspaces(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadWorkspaces.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(RepeatedWorkspace.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDeleteWorkspace { - QueryWorkspaceRequest request; - FolderEventDeleteWorkspace(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DeleteWorkspace.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventOpenWorkspace { - QueryWorkspaceRequest request; - FolderEventOpenWorkspace(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.OpenWorkspace.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(Workspace.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadWorkspaceApps { - QueryWorkspaceRequest request; - FolderEventReadWorkspaceApps(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadWorkspaceApps.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(RepeatedApp.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventCreateApp { - CreateAppRequest request; - FolderEventCreateApp(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.CreateApp.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(App.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDeleteApp { - QueryAppRequest request; - FolderEventDeleteApp(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DeleteApp.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadApp { - QueryAppRequest request; - FolderEventReadApp(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadApp.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(App.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventUpdateApp { - UpdateAppRequest request; - FolderEventUpdateApp(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.UpdateApp.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventCreateView { - CreateViewRequest request; - FolderEventCreateView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.CreateView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(View.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadView { - QueryViewRequest request; - FolderEventReadView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(View.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventUpdateView { - UpdateViewRequest request; - FolderEventUpdateView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.UpdateView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(View.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDeleteView { - QueryViewRequest request; - FolderEventDeleteView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DeleteView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDuplicateView { - QueryViewRequest request; - FolderEventDuplicateView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DuplicateView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventCopyLink { - FolderEventCopyLink(); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.CopyLink.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventOpenDocument { - QueryViewRequest request; - FolderEventOpenDocument(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.OpenDocument.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(DocumentDelta.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventCloseView { - QueryViewRequest request; - FolderEventCloseView(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.CloseView.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventReadTrash { - FolderEventReadTrash(); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ReadTrash.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (okBytes) => left(RepeatedTrash.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventPutbackTrash { - TrashId request; - FolderEventPutbackTrash(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.PutbackTrash.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDeleteTrash { - RepeatedTrashId request; - FolderEventDeleteTrash(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DeleteTrash.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventRestoreAllTrash { - FolderEventRestoreAllTrash(); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.RestoreAllTrash.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventDeleteAllTrash { - FolderEventDeleteAllTrash(); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.DeleteAllTrash.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventApplyDocDelta { - DocumentDelta request; - FolderEventApplyDocDelta(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ApplyDocDelta.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(DocumentDelta.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class FolderEventExportDocument { - ExportRequest request; - FolderEventExportDocument(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = FolderEvent.ExportDocument.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(ExportData.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-net/dart_event.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-net/dart_event.dart index 19f1bd0f09..93aff2384d 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-net/dart_event.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-net/dart_event.dart @@ -1,20 +1,3 @@ /// Auto generate. Do not edit part of '../../dispatch.dart'; -class NetworkEventUpdateNetworkType { - NetworkState request; - NetworkEventUpdateNetworkType(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = NetworkEvent.UpdateNetworkType.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-user/dart_event.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-user/dart_event.dart index c40fdd5a02..93aff2384d 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-user/dart_event.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dart_event/flowy-user/dart_event.dart @@ -1,141 +1,3 @@ /// Auto generate. Do not edit part of '../../dispatch.dart'; -class UserEventInitUser { - UserEventInitUser(); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.InitUser.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventSignIn { - SignInRequest request; - UserEventSignIn(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.SignIn.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(UserProfile.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventSignUp { - SignUpRequest request; - UserEventSignUp(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.SignUp.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (okBytes) => left(UserProfile.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventSignOut { - UserEventSignOut(); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.SignOut.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventUpdateUser { - UpdateUserRequest request; - UserEventUpdateUser(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.UpdateUser.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventGetUserProfile { - UserEventGetUserProfile(); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.GetUserProfile.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (okBytes) => left(UserProfile.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventCheckUser { - UserEventCheckUser(); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.CheckUser.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (okBytes) => left(UserProfile.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventSetAppearanceSetting { - AppearanceSettings request; - UserEventSetAppearanceSetting(this.request); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.SetAppearanceSetting.toString() - ..payload = requestToBytes(this.request); - - return Dispatch.asyncRequest(request) - .then((bytesResult) => bytesResult.fold( - (bytes) => left(unit), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - -class UserEventGetAppearanceSetting { - UserEventGetAppearanceSetting(); - - Future> send() { - final request = FFIRequest.create() - ..event = UserEvent.GetAppearanceSetting.toString(); - - return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold( - (okBytes) => left(AppearanceSettings.fromBuffer(okBytes)), - (errBytes) => right(FlowyError.fromBuffer(errBytes)), - )); - } -} - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/dart-ffi/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/dart-ffi/protobuf.dart index e559425581..4fabe735bf 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/dart-ffi/protobuf.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/dart-ffi/protobuf.dart @@ -1,3 +1,3 @@ // Auto-generated, do not edit -export './ffi_response.pb.dart'; export './ffi_request.pb.dart'; +export './ffi_response.pb.dart'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-collaboration/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-collaboration/protobuf.dart index 050f20adc0..70f6f82859 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-collaboration/protobuf.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-collaboration/protobuf.dart @@ -1,5 +1,5 @@ // Auto-generated, do not edit -export './folder_info.pb.dart'; -export './ws_data.pb.dart'; -export './revision.pb.dart'; export './document_info.pb.dart'; +export './folder_info.pb.dart'; +export './revision.pb.dart'; +export './ws_data.pb.dart'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/protobuf.dart index 4a0477e02c..a5c4c9f39e 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/protobuf.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-folder-data-model/protobuf.dart @@ -1,6 +1,6 @@ // Auto-generated, do not edit -export './share.pb.dart'; export './app.pb.dart'; -export './view.pb.dart'; +export './share.pb.dart'; export './trash.pb.dart'; +export './view.pb.dart'; export './workspace.pb.dart'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-net/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-net/protobuf.dart index 20c0bc012d..6540228d2a 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-net/protobuf.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-net/protobuf.dart @@ -1,3 +1,3 @@ // Auto-generated, do not edit -export './network_state.pb.dart'; export './event_map.pb.dart'; +export './network_state.pb.dart'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/protobuf.dart index 61ea505de9..61a500388e 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/protobuf.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/protobuf.dart @@ -1,5 +1,5 @@ // Auto-generated, do not edit +export './auth.pb.dart'; export './errors.pb.dart'; export './user_profile.pb.dart'; -export './auth.pb.dart'; export './user_setting.pb.dart'; diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml index b84944b88f..9c9562bfb6 100644 --- a/frontend/rust-lib/dart-ffi/Cargo.toml +++ b/frontend/rust-lib/dart-ffi/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [lib] name = "dart_ffi" # this value will change depending on the target os -# default staticlib -crate-type = ["staticlib"] +# default cdylib +crate-type = ["cdylib"] [dependencies] diff --git a/frontend/scripts/clean.cmd b/frontend/scripts/clean.cmd index b503f675b9..5ee373268c 100644 --- a/frontend/scripts/clean.cmd +++ b/frontend/scripts/clean.cmd @@ -4,4 +4,4 @@ cargo clean cd ../../shared-lib cargo clean -rmdir /s/q lib-infra/.cache \ No newline at end of file +rmdir /s/q "lib-infra/.cache" \ No newline at end of file diff --git a/frontend/scripts/makefile/protobuf.toml b/frontend/scripts/makefile/protobuf.toml index 4d594b3532..82084bd3e9 100644 --- a/frontend/scripts/makefile/protobuf.toml +++ b/frontend/scripts/makefile/protobuf.toml @@ -1,5 +1,10 @@ [tasks.install_protobuf] +mac_alias = "install-protobuf" +windows_alias = "install-protobuf-windows" +linux_alias = "install-protobuf" + +[tasks.install-protobuf] condition_script = [ """ if ! command -v protoc-gen-dart @@ -13,21 +18,8 @@ condition_script = [ ] run_task = { name = ["install_protobuf_compiler"] } -[tasks.install_protobuf_compiler] -script = """ -echo "Install protoc_plugin (Dart)" -dart pub global activate protoc_plugin -""" -script_runner = "@shell" -[tasks.install_protobuf_compiler.linux] -script = """ -echo "Install protoc_plugin (Dart)" -dart pub global activate protoc_plugin -""" -script_runner = "@shell" - -[tasks.install_protobuf_compiler.windows] +[tasks.install-protobuf-windows] script = """ ret = which dart if is_empty ${ret} @@ -44,6 +36,22 @@ end """ script_runner = "@duckscript" + +[tasks.install_protobuf_compiler] +script = """ +echo "Install protoc_plugin (Dart)" +dart pub global activate protoc_plugin +""" +script_runner = "@shell" + +[tasks.install_protobuf_compiler.linux] +script = """ +echo "Install protoc_plugin (Dart)" +dart pub global activate protoc_plugin +""" +script_runner = "@shell" + + [tasks.check_protoc_cmd] script = [ """ diff --git a/shared-lib/lib-infra/src/code_gen/protobuf_file/mod.rs b/shared-lib/lib-infra/src/code_gen/protobuf_file/mod.rs index f35a46d1f1..d94811a7fb 100644 --- a/shared-lib/lib-infra/src/code_gen/protobuf_file/mod.rs +++ b/shared-lib/lib-infra/src/code_gen/protobuf_file/mod.rs @@ -44,14 +44,7 @@ pub fn gen(crate_name: &str, proto_file_dir: &str) { let protoc_bin_path = protoc_bin_vendored::protoc_bin_path().unwrap(); // 2. generate the protobuf files(Dart) - #[cfg(feature = "dart")] - generate_dart_protobuf_files( - crate_name, - proto_file_dir, - &proto_file_paths, - &file_names, - &protoc_bin_path, - ); + // 3. generate the protobuf files(Rust) generate_rust_protobuf_files(&protoc_bin_path, &proto_file_paths, proto_file_dir); @@ -128,37 +121,27 @@ fn generate_dart_protobuf_files( } } -fn check_pb_compiler() { - assert!(run_command("command -v protoc"), "protoc was not installed correctly"); -} - fn check_pb_dart_plugin() { if cfg!(target_os = "windows") { - if !run_command("command -v protoc-gen-dart") { - panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly.")) - } + //Command::new("cmd") + // .arg("/C") + // .arg(cmd) + // .status() + // .expect("failed to execute process"); + //panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly.")) + } else { - if !run_command("command -v protoc-gen-dart") { + let is_success = Command::new("sh") + .arg("-c") + .arg("command -v protoc-gen-dart") + .status() + .expect("failed to execute process") + .success(); + + if !is_success { panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly. \n✅ You can fix that by adding \"{}\" to your shell's config file.(.bashrc, .bash, etc.)", "dart pub global activate protoc_plugin")) } - }; -} - -fn run_command(cmd: &str) -> bool { - let output = if cfg!(target_os = "windows") { - Command::new("cmd") - .arg("/C") - .arg(cmd) - .status() - .expect("failed to execute process") - } else { - Command::new("sh") - .arg("-c") - .arg(cmd) - .status() - .expect("failed to execute process") - }; - output.success() + } } #[cfg(feature = "proto_gen")]