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.29k stars 301 forks source link

`build.rs` ignores the `rust_release` parameter #2338

Closed codercengiz closed 1 month ago

codercengiz commented 1 month ago

Describe the bug

If we want to use rust_release parameter with build.rs , cargo build generates without considering frb attributes. For example, even if you specify #[cfg_attr(feature = "mobile",frb(sync))], it generates async function. However, flutter_rust_bridge_codegen generate generates as expected.

The two method are generating different codes.

Steps to reproduce

  1. Download the simple app https://github.com/codercengiz/frb_test/
  2. Go to rust folder and run cargo build then you will see on generated file lib/src/rust/api/simple.dart
    Future<String> greet({required String name}) =>
    RustLib.instance.api.crateApiSimpleGreet(name: name);
  3. To compare this generated code with the generated codes by codegen Install the codegen from git on master branch cargo install --git https://github.com/fzyzcjy/flutter_rust_bridge --branch master flutter_rust_bridge_codegen
    1. run flutter_rust_bridge_codegen generate, then you will see on generated file lib/src/rust/api/simple.dart
      String greet({required String name}) =>
      RustLib.instance.api.crateApiSimpleGreet(name: name);

Logs

❯ flutter_rust_bridge_codegen --version
flutter_rust_bridge_codegen 2.4.0

Expected behavior

No response

Generated binding code

No response

OS

No response

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Additional context

No response

fzyzcjy commented 1 month ago

Yes, build.rs currently has some limitations such as not able to parse macros to avoid deadlock (you know, when build.rs is executed, you are already running a Rust build, so if you further call cargo expand you will trigger a nested Rust build). Thus I suggest to use the normal generate command.

codercengiz commented 1 month ago

Ok, I see

github-actions[bot] commented 1 month 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.