Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override set_ method with #[frb(opaque)] struct #2079

Closed
dbsxdbsx opened this issue Jun 14, 2024 · 21 comments
Closed

Override set_ method with #[frb(opaque)] struct #2079

dbsxdbsx opened this issue Jun 14, 2024 · 21 comments

Comments

@dbsxdbsx
Copy link
Contributor

dbsxdbsx commented Jun 14, 2024

Env

Win10, FRB V2 DEV 39, Flutter 3.22.2, Rust 1.79

Issue

For a Rust struct with pub field named a along with #[frb(opaque)], if there is a method called pub fn set_a(&mut self ....), then the generated file frb_generated.rs(along with correspondingly dart file) would be panic because of duplicated implementation.

example screenshot for field content:
image

WorkAround

Currently, if the field and the method is made to be exposed to Dart, a workaround is rename the set_a to another name.

Suggestion

It seems to be related to the auto generated get/set reflection methods for each pub field of a #[frb(opaque)] Rust type. Hopefully, this could be refined by NOT generating corresponding get or set reflection methods correspondingly once FRB detects there is already a manual method in form pub fn set_<field_name>(&mut self,....) or pub fn <field_name>(&self,....)->&a.

I am not sure what I said above is the correct way to refine it. Just intuitionally, it seems that it is related to the reflection field methods.

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Jun 14, 2024

Hmm.... maybe this suggestion is still imperfect. Because if FRB not generate the corresponding get/set reflection code, then user can't get/set the field directly in Dart.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 14, 2024

What about this: Currently,

let rust_method_name = format!("{}_{}", accessor_mode.verb_str(), field.name.rust_style());
generates set_thefieldname as dummy name. However, maybe we can change that single line to something like:

    let rust_method_name = format!("auto_accessor_{}_{}", accessor_mode.verb_str(), field.name.rust_style());

Then there will be no conflict.

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Jun 14, 2024

Yes, I like this prefix solution. Actually, I just come up a similar way with suffix like <field_name>_only_for_dart_reflection(or even make it with a random number suffix, but this way would make the generated file be different after each generation, seems to be not good in practice).

Anyway, as long as the default reflection signature name has little chance to conflict with manual fn signature, then it is ok.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 14, 2024

Feel free to PR for this! Alternatively I will work on it in the next batch.

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jun 14, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 14, 2024

@dbsxdbsx Do you want to PR for this? If not, I will work on it (since quite trivial).

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Jun 15, 2024

@dbsxdbsx Do you want to PR for this? If not, I will work on it (since quite trivial).

Yes, I want to give it a shot.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

Take your time and looking forward to it!

@dbsxdbsx
Copy link
Contributor Author

By the way, I wonder what is the basic routine before pr. I've referred guidance here, but still unclear.

For example, after modifying code in frb_codegen, what local test to do before pr? I noticed frb_internal.bat, and it seems that ./frb_internal precommit --mode slow is the cmd to make sure the local test?
For the default code, this command finally ended with :

 19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: BaseThreadInitThunk
  24: RtlUserThreadStart)
Done!
Pick temporary directory: D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\target\GenerateRunFrbCodegenCommandIntegrate\temp_2024-06-15T100130429485_564399070
Pick temporary directory: D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\target\GenerateRunFrbCodegenCommandIntegrate\temp_2024-06-15T100130432485_255319736
Unhandled exception:
PathAccessException: Rename failed, path = 'D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example/flutter_via_create' (OS Error: 拒绝访问。
, errno = 5)
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _Directory.rename.<anonymous closure> (dart:io/directory_impl.dart:195:7)
<asynchronous suspension>
#2      generateRunFrbCodegenCommandIntegrate.<anonymous closure> (package:flutter_rust_bridge_internal/src/makefile_dart/generate.dart:334:7)
<asynchronous suspension>
#3      wrapMaybeSetExitIfChangedRaw (package:flutter_rust_bridge_internal/src/makefile_dart/generate.dart:411:3)
<asynchronous suspension>
#4      _wrapMaybeSetExitIfChanged (package:flutter_rust_bridge_internal/src/makefile_dart/generate.dart:400:3)
<asynchronous suspension>
#5      generateRunFrbCodegenCommandIntegrate (package:flutter_rust_bridge_internal/src/makefile_dart/generate.dart:317:3)
<asynchronous suspension>
#6      Future.wait.<anonymous closure> (dart:async/future.dart:524:21)
<asynchronous suspension>
#7      precommitIntegrate (package:flutter_rust_bridge_internal/src/makefile_dart/misc.dart:89:3)
<asynchronous suspension>
#8      precommit (package:flutter_rust_bridge_internal/src/makefile_dart/misc.dart:52:5)
<asynchronous suspension>
#9      SimpleConfigCommand.run (package:flutter_rust_bridge_internal/src/utils/makefile_dart_infra.dart:88:31)
<asynchronous suspension>
#10     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#11     main (file:///D:/DATA/BaiduSyncdisk/project/personal/test_repo/flutter_rust_bridge/tools/frb_internal/bin/flutter_rust_bridge_internal.dart:30:3)
<asynchronous suspension>

Is it the correct output before pr?

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

For your scenario, try

./frb_internal precommit-generate

which runs codegen on all projects.

Alternatively, suppose you are in flutter_rust_bridge/frb_example/pure_dart folder, then can run just codegen generate to generate for that single repo.

@dbsxdbsx
Copy link
Contributor Author

After running ./frb_internal precommit-generate for the default code, it has over hundreds of dart file diffs, seems all are due to format difference.
So I guess ./frb_internal precommit-generate is not the final command before pr?

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

It should not have that... Maybe paste the logs, is there any errors?

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Jun 15, 2024

It should not have that... Maybe paste the logs, is there any errors?

Seems no error.
image

By the way, I've eliminated the end of line issue, since I am on win10.

Maybe paste the logs, is there any errors?

@fzyzcjy, for local log, I only found one under frb_example\dart_build_rs\rust\logs, with this:

[2024-06-15T03:37:40.801Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\config\config_parser.rs:45] Found config file ../flutter_rust_bridge.yaml
[2024-06-15T03:37:40.801Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\mod.rs:23] config=Config { base_dir: Some(".."), rust_input: "rust/src/api/**/*.rs", dart_output: "lib/src/rust", c_output: None, duplicated_c_output: None, rust_root: None, rust_output: None, dart_entrypoint_class_name: None, dart_format_line_length: None, dart_preamble: None, rust_preamble: None, dart_enums_style: None, add_mod_to_lib: None, llvm_path: None, llvm_compiler_opts: None, dart_root: None, build_runner: None, extra_headers: None, web: None, deps_check: None, dart3: None, full_dep: None, local: Some(true), default_external_library_loader_web_prefix: None, dart_type_rename: None, stop_on_error: None, dump: None, dump_all: None } meta_config=MetaConfig { watch: false }
[2024-06-15T03:37:40.802Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\config\internal_config_parser\mod.rs:33] InternalConfig.parse base_dir=".."
[2024-06-15T03:37:41.026Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\mod.rs:26] internal_config=InternalConfig { controller: ControllerInternalConfig { watch: false, watching_paths: ["\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src"], exclude_paths: ["\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.rs", "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.io.rs", "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.web.rs"], max_count: None }, preparer: PreparerInternalConfig { dart_root: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs", deps_check: true, needs_ffigen: false }, parser: ParserInternalConfig { hir: ParserHirInternalConfig { rust_input_namespace_pack: RustInputNamespacePack { rust_input_namespace_prefixes: [Namespace { joined_path: "crate::api" }], rust_output_path_namespace: Namespace { joined_path: "crate::frb_generated" } }, rust_crate_dir: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust", third_party_crate_names: [] }, mir: ParserMirInternalConfig { rust_input_namespace_pack: RustInputNamespacePack { rust_input_namespace_prefixes: [Namespace { joined_path: "crate::api" }], rust_output_path_namespace: Namespace { joined_path: "crate::frb_generated" } }, force_codec_mode_pack: Some(CodecModePack { dart2rust: Pde, rust2dart: Pde }), default_stream_sink_codec: Sse, default_rust_opaque_codec: Moi, stop_on_error: false } }, generator: GeneratorInternalConfig { api_dart: GeneratorApiDartInternalConfig { dart_enums_style: true, dart3: true, dart_decl_base_output_path: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust", dart_impl_output_path: TargetOrCommonMap { common: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.dart", io: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.io.dart", web: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.web.dart" }, dart_entrypoint_class_name: "RustLib", dart_preamble: "", dart_type_rename: {} }, wire: GeneratorWireInternalConfig { dart: GeneratorWireDartInternalConfig { has_ffigen: false, web_enabled: true, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"], llvm_compiler_opts: "", dart_root: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs", extra_headers: "", dart_impl_output_path: TargetOrCommonMap { common: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.dart", io: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.io.dart", web: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\lib\\src\\rust\\frb_generated.web.dart" }, dart_output_class_name_pack: DartOutputClassNamePack { entrypoint_class_name: "RustLib", api_class_name: "RustLibApi", api_impl_class_name: "RustLibApiImpl", api_impl_platform_class_name: "RustLibApiImplPlatform", wire_class_name: "RustLibWire", wasm_module_name: "RustLibWasmModule" }, default_external_library_loader: GeneratorWireDartDefaultExternalLibraryLoaderInternalConfig { stem: "frb_example_dart_build_rs", io_directory: "rust/target/release/", web_prefix: "pkg/" }, c_symbol_prefix: "frbgen_frb_example_dart_build_rs_" }, rust: GeneratorWireRustInternalConfig { rust_crate_dir: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust", web_enabled: true, rust_output_path: TargetOrCommonMap { common: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.rs", io: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.web.rs" }, c_symbol_prefix: "frbgen_frb_example_dart_build_rs_", has_ffigen: false, default_stream_sink_codec: Sse, default_rust_opaque_codec: Moi, rust_preamble: "" }, c: GeneratorWireCInternalConfig { enable: false, rust_crate_dir: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust", rust_output_path: TargetOrCommonMap { common: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.rs", io: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.web.rs" }, c_output_path: None, c_symbol_prefix: "frbgen_frb_example_dart_build_rs_" } } }, polisher: PolisherInternalConfig { duplicated_c_output_path: [], dart_format_line_length: 80, add_mod_to_lib: true, build_runner: true, web_enabled: true, dart_root: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs", rust_crate_dir: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust", rust_output_path: TargetOrCommonMap { common: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.rs", io: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\src\\frb_generated.web.rs" }, c_output_path: None, enable_auto_upgrade: false }, dumper: DumperInternalConfig { dump_contents: [], dump_directory: "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust\\target\\frb_dump" } }
[2024-06-15T03:37:41.026Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\utils\dart_repository\dart_repo.rs:22] Guessing toolchain the runner is run into
[2024-06-15T03:37:41.029Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"dart\" \"--version\"" current_dir=None cmd="powershell" "-noprofile" "-command" "& \"dart\" \"--version\""
[2024-06-15T03:37:41.262Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"dart\" \"--version\"" stdout=Dart SDK version: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "windows_x64"
 stderr=
[2024-06-15T03:37:41.262Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\cargo_expand\mod.rs:26] run_cargo_expand manifest_dir=D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example\dart_build_rs\rust rust_crate_dir="\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust"
[2024-06-15T03:37:41.262Z WARN D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\cargo_expand\pseudo.rs:15] Skip cargo-expand on "\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros or complex mods.
[2024-06-15T03:37:41.269Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\cargo_expand\pseudo.rs:56] Skip parsing io since do not know its corresponding file path
[2024-06-15T03:37:41.270Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\cargo_expand\pseudo.rs:56] Skip parsing web since do not know its corresponding file path
[2024-06-15T03:37:41.271Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\parser\mir\parser\function\real\mod.rs:118] parse_function function name: "init_app"
[2024-06-15T03:37:41.271Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\parser\mir\parser\function\real\mod.rs:118] parse_function function name: "minimal_adder"
[2024-06-15T03:37:41.271Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\parser\mir\parser\function\real\mod.rs:118] parse_function function name: "init_app"
[2024-06-15T03:37:41.271Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\codegen\parser\mir\parser\function\real\mod.rs:118] parse_function function name: "minimal_adder"
[2024-06-15T03:37:41.279Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\format_dart.rs:24] execute format_dart paths=["lib\\src\\rust\\frb_generated.dart", "lib\\src\\rust\\api\\minimal.dart", "lib\\src\\rust\\frb_generated.io.dart", "lib\\src\\rust\\frb_generated.web.dart"] line_length=80
[2024-06-15T03:37:41.279Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\api\\\\minimal.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" current_dir=Some("\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs") cmd="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\api\\\\minimal.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\""
[2024-06-15T03:37:41.935Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\api\\\\minimal.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" stdout=Formatted lib\\src\\rust\\frb_generated.dart
Formatted lib\\src\\rust\\api\\minimal.dart
Formatted lib\\src\\rust\\frb_generated.io.dart
Formatted lib\\src\\rust\\frb_generated.web.dart
Formatted 4 files (4 changed) in 0.21 seconds.
 stderr=
[2024-06-15T03:37:41.936Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\format_rust.rs:9] execute format_rust paths=["src\\frb_generated.web.rs", "src\\frb_generated.io.rs", "src\\frb_generated.rs"]
[2024-06-15T03:37:41.936Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.web.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.rs\"" current_dir=Some("\\\\?\\D:\\DATA\\BaiduSyncdisk\\project\\personal\\test_repo\\flutter_rust_bridge\\frb_example\\dart_build_rs\\rust") cmd="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.web.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.rs\""
[2024-06-15T03:37:42.162Z DEBUG D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_codegen\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.web.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.rs\"" stdout= stderr=Warning: can't set `group_imports = One`, unstable features are only available in nightly channel.
Warning: can't set `group_imports = One`, unstable features are only available in nightly channel.
Warning: can't set `group_imports = One`, unstable features are only available in nightly channel.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

That's weird, which looks like Dart formatter is never executed... What if

in flutter_rust_bridge/frb_example/pure_dart folder, then run just codegen generate

@dbsxdbsx
Copy link
Contributor Author

That's weird, which looks like Dart formatter is never executed... What if

in flutter_rust_bridge/frb_example/pure_dart folder, then run just codegen generate

for just codegen generate, it has error:

cd D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example\pure_dart && cargo run --manifest-path D:\DATA\BaTA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge/frb_codegen/Cargo.toml -- generate
error: Recipe `codegen` could not be run because just could not find the shell: program not found

And for the err of ./frb_internal precommit-generate, I've tried in PowerShell and Gith Bash---both occurs the same issue. And the output diff files are only for Dart, the Rust files are ok.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

Hmm, then maybe execute the equivalent of

cd D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example\pure_dart && cargo run --manifest-path D:\DATA\BaTA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge/frb_codegen/Cargo.toml -- generate

Manually?

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Jun 15, 2024

Hmm, then maybe execute the equivalent of

cd D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example\pure_dart && cargo run --manifest-path D:\DATA\BaTA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge/frb_codegen/Cargo.toml -- generate

Manually?

The correct cmd for it should be cd D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge\frb_example\pure_dart ; cargo run --manifest-path D:\DATA\BaiduSyncdisk\project\personal\test_repo\flutter_rust_bridge/frb_codegen/Cargo.toml -- generate using PowerShell on win10, which ends with this:
image

Still, there are lots of dart files diffs.

The same result after running cd D:/DATA/BaiduSyncdisk/project/personal/test_repo/flutter_rust_bridge/frb_example/pure_dart && cargo run --manifest-path D:/DATA/BaiduSyncdisk/project/personal/test_repo/flutter_rust_bridge/frb_codegen/Cargo.toml -- generate in git bash.

@dbsxdbsx
Copy link
Contributor Author

I've also tried to make a ps1 script for powershell based on this section Format and lint everything, but still ran into some issues.

Maybe I should wait until there is refined version for windows developer.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

That's weird. The "run dart formatter" section is already there. Most importantly, CI does check windows codegen and it works well, and nobody using frb did say on windows the formatter is not run...

For that formatter problem, maybe run dart format . on e.g. frb_example/pure_dart, then it should be OK, since frb codegen also just simply call like that.

@dbsxdbsx
Copy link
Contributor Author

I just found that running dart format . after ./frb_internal precommit-generate could fix most format issues,except for those in frb_codegen\test_fixtures\:
image
I think now it is time to pr.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 15, 2024

frb_codegen\test_fixtures\

Those are not formatted at all IIRC, so just leave them untouched (unformatted) and it will not have diff.

I think now it is time to pr.

Looking forward to it!

@fzyzcjy fzyzcjy removed the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jun 21, 2024
Copy link
Contributor

github-actions bot commented Jul 5, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants