fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.14k stars 285 forks source link

flutter run with build.rs generates bridge code as if frb marker has no effect #1807

Closed SilverMira closed 6 months ago

SilverMira commented 6 months ago

Describe the bug

After setting up to use build.rs rather than manually running flutter_rust_bridge_codegen generate, I found that the code generated using build.rs was different from running flutter_rust_bridge_codgen generate.

Steps to reproduce

  1. flutter_rust_bridge_codegen create repro_build_rs
  2. cd repro_build_rs
  3. Update rust/Cargo.toml and rust/build.rs according to frb_example/dart_build_rs

    rust/Cargo.toml ```toml [package] name = "rust_lib_repro_frb" version = "0.1.0" edition = "2021" [lib] crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = "=2.0.0-dev.27" [build-dependencies] flutter_rust_bridge_codegen = "=2.0.0-dev.27" anyhow = { version = "1.0.80", features = ["backtrace"] } ```
    rust/build.rs ```rs use lib_flutter_rust_bridge_codegen::codegen; use lib_flutter_rust_bridge_codegen::codegen::Config; use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_logging; fn main() -> anyhow::Result<()> { // If you want to see logs // Alternatively, use `cargo build -vvv` (instead of `cargo build`) to see logs on screen configure_opinionated_logging("./logs/", true)?; // Execute code generator with auto-detected config codegen::generate( Config::from_config_file("../flutter_rust_bridge.yaml")?.unwrap(), Default::default(), ) } ```
  4. flutter run
  5. image
  6. The code generated disregarded the #[frb(sync)] of the scaffolded project and generated greet() as default async instead
    #[flutter_rust_bridge::frb(sync)] // Synchronous mode for simplicity of the demo
    pub fn greet(name: String) -> String {
        format!("Hello, {name}!")
    }

Logs

Running `cargo build -vv` ```shell [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.053Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\mod.rs:24] 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_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: None, default_external_library_loader_web_prefix: None, dump: None, dump_all: None } meta_config=MetaConfig { watch: false } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.053Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\config\internal_config_parser.rs:42] InternalConfig.parse base_dir=".." [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.162Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\mod.rs:27] internal_config=InternalConfig { controller: ControllerInternalConfig { watch: false, watching_paths: ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src"], exclude_paths: ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.io.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.web.rs"], max_count: None }, preparer: PreparerInternalConfig { dart_root: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb", deps_check: true, needs_ffigen: false }, parser: ParserInternalConfig { rust_input_path_pack: RustInputPathPack { rust_input_paths: ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs"] }, rust_crate_dir: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", force_codec_mode_pack: Some(CodecModePack { dart2rust: Pde, rust2dart: Pde }), default_rust_opaque_codec: Moi }, generator: GeneratorInternalConfig { api_dart: GeneratorApiDartInternalConfig { dart_enums_style: true, dart3: true, dart_decl_base_output_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\lib\\src\\rust", dart_entrypoint_class_name: "RustLib" }, 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: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb", extra_headers: "", dart_impl_output_path: TargetOrCommonMap { common: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\lib\\src\\rust\\frb_generated.dart", io: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\lib\\src\\rust\\frb_generated.io.dart", web: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\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: "rust_lib_repro_frb", io_directory: "rust/target/release/", web_prefix: "pkg/" }, c_symbol_prefix: "frbgen_repro_frb_" }, rust: GeneratorWireRustInternalConfig { rust_input_path_pack: RustInputPathPack { rust_input_paths: ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs"] }, rust_crate_dir: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", web_enabled: true, rust_output_path: TargetOrCommonMap { common: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", io: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.web.rs" }, c_symbol_prefix: "frbgen_repro_frb_", has_ffigen: false, default_stream_sink_codec: Sse, default_rust_opaque_codec: Moi }, c: GeneratorWireCInternalConfig { enable: false, rust_crate_dir: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", rust_output_path: TargetOrCommonMap { common: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", io: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.web.rs" }, c_output_path: None, c_symbol_prefix: "frbgen_repro_frb_" } } }, polisher: PolisherInternalConfig { duplicated_c_output_path: [], dart_format_line_length: 80, add_mod_to_lib: true, build_runner: true, web_enabled: true, dart_root: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb", rust_crate_dir: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", rust_output_path: TargetOrCommonMap { common: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", io: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.io.rs", web: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.web.rs" }, c_output_path: None, enable_auto_upgrade: true }, dumper: DumperInternalConfig { dump_contents: [], dump_directory: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\target\\frb_dump" } } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.162Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\utils\dart_repository\dart_repo.rs:22] Guessing toolchain the runner is run into [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.163Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"flutter\" \"--version\"" current_dir=None cmd="powershell" "-noprofile" "-command" "& \"flutter\" \"--version\"" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.772Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"flutter\" \"--version\"" stdout=Flutter 3.19.2 • channel stable • https://github.com/flutter/flutter.git [rust_lib_repro_frb 0.1.0] Framework • revision 7482962148 (9 days ago) • 2024-02-27 16:51:22 -0500 [rust_lib_repro_frb 0.1.0] Engine • revision 04817c99c9 [rust_lib_repro_frb 0.1.0] Tools • Dart 3.3.0 • DevTools 2.31.1 [rust_lib_repro_frb 0.1.0] stderr= [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.773Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs" module=Some("api::simple") [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.773Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir=C:\Users\Mira\Code\repro_frb\rust rust_crate_dir="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.773Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:39] Skip cargo-expand on "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros. [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.773Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\crates.rs:26] parse manifest_path="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\Cargo.toml" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.881Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib.rs", module_path: ["crate"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.881Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "api"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.881Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "api"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.881Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "api" "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib.rs" ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib\\api.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib\\api\\mod.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs" module=Some("api") [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir=C:\Users\Mira\Code\repro_frb\rust rust_crate_dir="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:39] Skip cargo-expand on "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros. [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:216] Trying to parse "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs", module_path: ["crate", "api"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "api", "simple"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "api", "simple"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "simple" "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs" ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple\\mod.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod\\simple.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod\\simple\\mod.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs" module=Some("api::simple") [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir=C:\Users\Mira\Code\repro_frb\rust rust_crate_dir="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:39] Skip cargo-expand on "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros. [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:216] Trying to parse "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs", module_path: ["crate", "api", "simple"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\simple.rs", module_path: ["crate", "api", "simple"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\api\\mod.rs", module_path: ["crate", "api"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "frb_generated"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "frb_generated"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "frb_generated" "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib.rs" ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated\\mod.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib\\frb_generated.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib\\frb_generated\\mod.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\reader.rs:22] read_rust_file rust_file_path="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs" module=Some("frb_generated") [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:31] CachedCargoExpand execute manifest_dir=C:\Users\Mira\Code\repro_frb\rust rust_crate_dir="\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:39] Skip cargo-expand on "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros. [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.882Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:216] Trying to parse "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:31] parse START info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "frb_generated", "io"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "frb_generated", "io"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "io" "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs" ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\io.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\io\\mod.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated\\io.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated\\io\\mod.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:232] Skipping unresolvable module io (tried \\?\C:\Users\Mira\Code\repro_frb\rust\src\io.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\io\mod.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\frb_generated\io.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\frb_generated\io\mod.rs) [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:150] parse_syn_item_mod module_path=["crate", "frb_generated", "web"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:202] parse_syn_item_mod_contentless module_path=["crate", "frb_generated", "web"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:205] file_path_candidates "web" "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs" ["\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\web.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\web\\mod.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated\\web.rs", "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated\\web\\mod.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:232] Skipping unresolvable module web (tried \\?\C:\Users\Mira\Code\repro_frb\rust\src\web.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\web\mod.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\frb_generated\web.rs, \\?\C:\Users\Mira\Code\repro_frb\rust\src\frb_generated\web\mod.rs) [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.885Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Inherited, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\frb_generated.rs", module_path: ["crate", "frb_generated"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.886Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\source_graph\module_parser.rs:77] parse END info=ModuleInfo { visibility: Public, file_path: "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust\\src\\lib.rs", module_path: ["crate"] } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.887Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\function_parser\mod.rs:67] parse_function function name: Ident { sym: greet, span: bytes(89..94) } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.887Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\codegen\parser\function_parser\mod.rs:67] parse_function function name: Ident { sym: init_app, span: bytes(195..203) } [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.890Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\format_dart.rs:13] execute format_dart paths=["lib\\src\\rust\\api\\simple.dart", "lib\\src\\rust\\frb_generated.dart", "lib\\src\\rust\\frb_generated.io.dart", "lib\\src\\rust\\frb_generated.web.dart"] line_length=80 [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.890Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" current_dir=Some("\\\\?\\C:\\Users\\Mira\\Code\\repro_frb") cmd="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.225Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"dart\" \"format\" \"--line-length\" \"80\" \"lib\\\\src\\\\rust\\\\api\\\\simple.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.io.dart\" \"lib\\\\src\\\\rust\\\\frb_generated.web.dart\"" stdout=Formatted lib\\src\\rust\\api\\simple.dart [rust_lib_repro_frb 0.1.0] Formatted lib\\src\\rust\\frb_generated.dart [rust_lib_repro_frb 0.1.0] Formatted lib\\src\\rust\\frb_generated.io.dart [rust_lib_repro_frb 0.1.0] Formatted lib\\src\\rust\\frb_generated.web.dart [rust_lib_repro_frb 0.1.0] Formatted 4 files (4 changed) in 0.13 seconds. [rust_lib_repro_frb 0.1.0] stderr= [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.225Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\format_rust.rs:9] execute format_rust paths=["src\\frb_generated.rs", "src\\frb_generated.io.rs", "src\\frb_generated.web.rs"] [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.225Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:129] execute command: bin=powershell args="-noprofile -command & \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\"" current_dir=Some("\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust") cmd="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\"" [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.322Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\command_runner.rs:140] command="powershell" "-noprofile" "-command" "& \"rustfmt\" \"--edition\" \"2018\" \"src\\\\frb_generated.rs\" \"src\\\\frb_generated.io.rs\" \"src\\\\frb_generated.web.rs\"" stdout= stderr= [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.322Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\utils\dart_repository\dart_repo.rs:22] Guessing toolchain the runner is run into [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.323Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\utils\dart_repository\dart_repo.rs:71] Checking presence of flutter_rust_bridge in dependencies at \\?\C:\Users\Mira\Code\repro_frb [rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:39.323Z DEBUG C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\utils\dart_repository\dart_repo.rs:103] Checking presence of flutter_rust_bridge in dependencies at \\?\C:\Users\Mira\Code\repro_frb [rust_lib_repro_frb 0.1.0] Done! ```

Expected behavior

Generate the same exact code as if running flutter_rust_bridge_codegen generate

Generated binding code

// lib/src/rust/api/simple.dart
// This file is automatically generated, so please do not edit it.
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.27.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

Future<String> greet({required String name, dynamic hint}) =>
    RustLib.instance.api.greet(name: name, hint: hint);

Future<void> initApp({dynamic hint}) =>
    RustLib.instance.api.initApp(hint: hint);

OS

Windows

Version of flutter_rust_bridge_codegen

2.0.0-dev.27

Flutter info

No response

Version of clang++

No response

Additional context

No response

fzyzcjy commented 6 months ago

Hmm, is it possible because of the 2.0.0-dev.27's new mechanism of frb_macros? So could you please firstly try dev.26 and see whether it works.

SilverMira commented 6 months ago

Tried to lower to .26 but still the same, the bridge still generated async code rather than the expected sync. Is there anything to do with this WARN mentioning cargo-expand is skipped?

[rust_lib_repro_frb 0.1.0] [2024-03-08T09:00:38.773Z WARN C:\Users\Mira\.cargo\registry\src\index.crates.io-6f17d22bba15001f\flutter_rust_bridge_codegen-2.0.0-dev.27\src\library\commands\cargo_expand.rs:39] Skip cargo-expand on "\\\\?\\C:\\Users\\Mira\\Code\\repro_frb\\rust", because cargo is already running and would block cargo-expand. This might cause errors if your api contains macros.
fzyzcjy commented 6 months ago

Looks possible (that's one of the points I suspect, before examining more in detail). I will try to find a time slot to look at it ASAP! At the same time, you can use the standard way of using it - flutter_rust_bridge_codegen generate.

github-actions[bot] commented 5 months ago

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.