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

build.rs ignores the rust_release parameter #2338

Closed
codercengiz opened this issue Oct 4, 2024 · 2 comments
Closed

build.rs ignores the rust_release parameter #2338

codercengiz opened this issue Oct 4, 2024 · 2 comments
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@codercengiz
Copy link

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);
  1. 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
  2. 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

@codercengiz codercengiz added the bug Something isn't working label Oct 4, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 4, 2024

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.

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Oct 4, 2024
@codercengiz
Copy link
Author

Ok, I see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants