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

Upgrade Guide from pre-2.0 #2360

Open
dragazo opened this issue Oct 21, 2024 · 2 comments
Open

Upgrade Guide from pre-2.0 #2360

dragazo opened this issue Oct 21, 2024 · 2 comments
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc

Comments

@dragazo
Copy link

dragazo commented Oct 21, 2024

Hi, I've had a flutter app I've been maintaining since pre 2.0 of this package. I'm trying to upgrade to the latest version, but I'm having some issues.

I was previously using this command to generate bindings:

flutter_rust_bridge_codegen \
    --rust-input native/src/api.rs \
    --dart-output lib/bridge_generated.dart \
    --c-output ios/Runner/bridge_generated.h \
    --extra-c-output-path macos/Runner/ \
    --dart-decl-output lib/bridge_definitions.dart \
    --wasm

In the latest version, I noticed it's switched to a sub-command flutter_rust_bridge_codegen generate, which I did. However, there have apparently been a few arg changes. I saw that --extra-c-output-path was renamed to --duplicated-c-output, which I also applied. It looks like --rust-input has also changed, but it conveniently gives directions for updating that part.

However, I cannot seem to find equivalents for --dart-decl-output or --wasm. Do you have an info about this?

I've tried just removing --dart-decl-output and --wasm, which will get past the arg parser, but I then get a File exists (os error 17) error from building:

flutter_rust_bridge_codegen generate --rust-root native/ --rust-input crate::api --dart-output lib/bridge_generated.dart --c-output ios/Runner/bridge_generated.h --duplicated-c-output macos/Runner/ 
[2024-10-21T15:56:14.040Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "C" }` because of error (e=struct with unit fields are not supported yet, what about using `struct C {}` or `#[frb(opaque)] struct C;` instead)
[2024-10-21T15:56:14.040Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "EntityState" }` because of error (e=struct with unit fields are not supported yet, what about using `struct EntityState {}` or `#[frb(opaque)] struct EntityState;` instead)
[2024-10-21T15:56:14.040Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "ProcessState" }` because of error (e=struct with unit fields are not supported yet, what about using `struct ProcessState {}` or `#[frb(opaque)] struct ProcessState;` instead)
[2024-10-21T15:56:14.046Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/lifetimeable.rs:52] To handle some types, `enable_lifetime: true` may need to be set. Please visit https://fzyzcjy.github.io/flutter_rust_bridge/guides/lifetimes for more details
[2024-10-21T15:56:14.046Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "C" }` because of error (e=struct with unit fields are not supported yet, what about using `struct C {}` or `#[frb(opaque)] struct C;` instead)
[2024-10-21T15:56:14.046Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "EntityState" }` because of error (e=struct with unit fields are not supported yet, what about using `struct EntityState {}` or `#[frb(opaque)] struct EntityState;` instead)
[2024-10-21T15:56:14.046Z INFO /home/devin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-2.2.0/src/library/codegen/parser/mir/parser/ty/enum_or_struct.rs:73] Skip parsing enum_or_struct `NamespacedName { namespace: Namespace { joined_path: "crate::api" }, name: "ProcessState" }` because of error (e=struct with unit fields are not supported yet, what about using `struct ProcessState {}` or `#[frb(opaque)] struct ProcessState;` instead)
[0.4s] Parse  
  └── [0.3s] Cargo expand & syn parse  
  └── [0.0s] Parse HIR  
  └── [0.0s] Parse MIR  
[0.0s] Generate
Error: File exists (os error 17)

I don't have a minimal example, but here's my code (just master branch) if needed: https://github.com/dragazo/phone-iot-2

@dragazo
Copy link
Author

dragazo commented Oct 21, 2024

I've updated the command to:

flutter_rust_bridge_codegen generate \
    --rust-root native/ \
    --rust-input crate::api \
    --dart-output lib/bridge_generated.dart \
    --c-output ios/Runner/bridge_generated.h \
    --duplicated-c-output macos/Runner/ \
    --enable-lifetime

(I guess lifetimes are not supported by default anymore?)

This fixes the warnings, but I still get a mysterious file exists error:

flutter_rust_bridge_codegen generate --rust-root native/ --rust-input crate::api --dart-output lib/bridge_generated.dart --c-output ios/Runner/bridge_generated.h --duplicated-c-output macos/Runner/ --enable-lifetime 
[0.4s] Parse  
  └── [0.4s] Cargo expand & syn parse  
  └── [0.0s] Parse HIR  
  └── [0.0s] Parse MIR  
[0.0s] Generate
Error: File exists (os error 17)

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 21, 2024

Hi, upgrade guide: https://cjycode.com/flutter_rust_bridge/guides/miscellaneous/upgrade/v2

Feel free to ping me if you have any questions after reading it!

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Oct 21, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants