Skip to content

RFC: feat: allow omission of dart-opaque feature #2662

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

Merged
merged 6 commits into from
Apr 5, 2025

Conversation

aran
Copy link
Contributor

@aran aran commented Mar 27, 2025

Changes

Fixes #2661

In this implementation flutter_rust_bridge::frb_generated_boilerplate_io and web are still present in the generated code, and now they have a reference to a dart-opaque feature that isn't present by default in the client's Cargo.toml. This can be worked around by adding the feature declaration. Fixing this so the code isn't generated at all would be a much bigger change.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 27, 2025

Great job! I will handle the CI and merge it in the next batch. Btw curious why do you want to remove the dart-opaque feature (it is totally reasonable, just wondering what is the exact use case)

@aran
Copy link
Contributor Author

aran commented Mar 27, 2025

Let me know if you have a preferred solution for the warning generated because of the 'dart-opaque' feature reference. I can take a look at it. I don't know what would be a good way to structure feature-gated generated code.

Overall I'm trying to understand the FRB code better and trying to minimize surface area on the way to solving #2588.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 29, 2025

Let me know if you have a preferred solution

Not checked in detail but usually I just add more feature gates on it...

Overall I'm trying to understand the FRB code better and trying to minimize surface area on the way to solving #2588.

I see, looks reasonable!

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally want to merge it, but after briefly checking it, what about removing the feat_no_dart_opaque example, and instead add a test that modifies dart_minimal's rust features temporarily and ensure it compiles. Because it is possible we add tests to ensure it compiles when more feature flags gets removed, and it would be great to limit the number of frb_examples to avoid heavy CI.

@aran
Copy link
Contributor Author

aran commented Apr 4, 2025

Something like this?

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to keep dart_minimal have the feature by default (to make users easier to use dart_minimal to reproduce some bugs), but yes your approach looks also ok :)

EDIT: Oh I see the default features below, looks good!

Comment on lines +24 to +26
[features]
default = ["dart-opaque"]
dart-opaque = ["flutter_rust_bridge/dart-opaque"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is it possible we make it as simple as possible, say, is it possible to remove the dart-opaque line, and directly specify as flutter_rust_bridge/dart-opaque? (just a quick nit, I forget whether rust supports so or not, if not then ignore)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of another way to do this.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 5, 2025

Great job! I will handle it soon (hopefully within a few days)

@fzyzcjy fzyzcjy changed the base branch from master to feat/2662 April 5, 2025 05:38
@fzyzcjy fzyzcjy merged commit 43791e7 into fzyzcjy:feat/2662 Apr 5, 2025
110 of 126 checks passed
@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 5, 2025

Oops, I originally wanted to merge this to feat/2662 and then fix CI and then merge to master, but then realize some nits:

  1. https://github.com/fzyzcjy/flutter_rust_bridge/actions/runs/14270290721/job/40001795109?pr=2662 Looks like we need to fix this error:

image

  1. https://github.com/fzyzcjy/flutter_rust_bridge/actions/runs/14270290721/job/40001818367?pr=2662 Also may need to fix this (maybe by changing the feature gating?):

image

@aran
Copy link
Contributor Author

aran commented Apr 7, 2025

Github isn't letting me push more commits to this with the merge. Created #2681.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow omission of dart-opaque feature
2 participants