Closed jwinarske closed 1 year ago
Hi! Thanks for opening your first issue here! :smile:
could you please provide the diff?
I'm just checking out master and running
cd frb_example/with_flutter
flutter_rust_bridge_codegen --rust-input rust/src/bridge_generated.rs --dart-output lib/bridge_generated.dart
I want to run codegen and then compile to see the master check-in is the same as codegen output.
What do you run prior to checking in the generated files?
I'm also having a problem on Fedora with pure_dart. Not able to codegen and build for some reason.
I mean, could you please copy-paste the diff from "It shows the following files changed"
using git diff
probably
Sequence with Linux (Fedora 34)
git clone https://github.com/fzyzcjy/flutter_rust_bridge.git
cd flutter_rust_bridge/frb_example/with_flutter
flutter pub get
pushd rust && cargo build --release --verbose && popd
flutter_rust_bridge_codegen --rust-input rust/src/api.rs --dart-output lib/bridge_generated.dart
flutter build bundle
Build error
$ flutter build bundle
Running "flutter pub get" in with_flutter... 1,006ms
💪 Building with sound null safety 💪
lib/bridge_generated.io.dart:9:1: Error: 'Point' is imported from both
'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^^
lib/bridge_generated.io.dart:9:1: Error: 'Size' is imported from both
'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^
lib/bridge_generated.io.dart:9:1: Error: 'TreeNode' is imported from both
'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^^^^^
lib/bridge_generated.dart:556:9: Error: The parameter 'ptr' of the method
'FlutterRustBridgeExampleWire.store_dart_post_cobject' has type 'int', which does not match the corresponding
type, 'Pointer<NativeFunction<Bool Function(Int64, Pointer<Void>)>>', in the overridden method,
'FlutterRustBridgeWireBase.store_dart_post_cobject'.
- 'Pointer' is from 'dart:ffi'.
- 'NativeFunction' is from 'dart:ffi'.
- 'Bool' is from 'dart:ffi'.
- 'Int64' is from 'dart:ffi'.
- 'Void' is from 'dart:ffi'.
Change to a supertype of 'Pointer<NativeFunction<Bool Function(Int64, Pointer<Void>)>>', or, for a covariant
parameter, a subtype.
int ptr,
^
../../frb_dart/lib/src/ffi/stub.dart:14:8: Context: This is the overridden method ('store_dart_post_cobject').
void store_dart_post_cobject(DartPostCObject ptr) {}
^
lib/main.dart:42:20: Error: The argument type 'Size/*1*/' can't be assigned to the parameter type 'Size/*2*/'.
- 'Size/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart'
('lib/bridge_definitions.dart').
- 'Size/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart' ('lib/bridge_generated.dart').
imageSize: Size(width: 50, height: 50), zoomPoint: examplePoint, scale: generateScale(), numThreads: 4);
^
lib/main.dart:42:60: Error: The argument type 'Point/*1*/' can't be assigned to the parameter type 'Point/*2*/'.
- 'Point/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart'
('lib/bridge_definitions.dart').
- 'Point/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart' ('lib/bridge_generated.dart').
imageSize: Size(width: 50, height: 50), zoomPoint: examplePoint, scale: generateScale(), numThreads: 4);
^
lib/main.dart:47:64: Error: The argument type 'TreeNode/*1*/' can't be assigned to the parameter type
'TreeNode/*2*/'.
- 'TreeNode/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart'
('lib/bridge_definitions.dart').
- 'TreeNode/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart'
('lib/bridge_generated.dart').
final receivedText = await api.passingComplexStructs(root: createExampleTree());
^
Target kernel_snapshot failed: Exception
Failed to build bundle.
On M1 Mac (same sequence as above)
Build error
% flutter build bundle
💪 Building with sound null safety 💪
lib/bridge_generated.io.dart:9:1: Error: 'Point' is imported from both 'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^^
lib/bridge_generated.io.dart:9:1: Error: 'Size' is imported from both 'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^
lib/bridge_generated.io.dart:9:1: Error: 'TreeNode' is imported from both 'package:flutter_rust_bridge_example/bridge_definitions.dart' and
'package:flutter_rust_bridge_example/bridge_generated.dart'.
import 'bridge_generated.dart';
^^^^^^^^
lib/main.dart:42:20: Error: The argument type 'Size/*1*/' can't be assigned to the parameter type 'Size/*2*/'.
- 'Size/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart' ('lib/bridge_definitions.dart').
- 'Size/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart' ('lib/bridge_generated.dart').
imageSize: Size(width: 50, height: 50), zoomPoint: examplePoint, scale: generateScale(), numThreads: 4);
^
lib/main.dart:42:60: Error: The argument type 'Point/*1*/' can't be assigned to the parameter type 'Point/*2*/'.
- 'Point/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart' ('lib/bridge_definitions.dart').
- 'Point/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart' ('lib/bridge_generated.dart').
imageSize: Size(width: 50, height: 50), zoomPoint: examplePoint, scale: generateScale(), numThreads: 4);
^
lib/main.dart:47:64: Error: The argument type 'TreeNode/*1*/' can't be assigned to the parameter type 'TreeNode/*2*/'.
- 'TreeNode/*1*/' is from 'package:flutter_rust_bridge_example/bridge_definitions.dart' ('lib/bridge_definitions.dart').
- 'TreeNode/*2*/' is from 'package:flutter_rust_bridge_example/bridge_generated.dart' ('lib/bridge_generated.dart').
final receivedText = await api.passingComplexStructs(root: createExampleTree());
^
Target kernel_snapshot failed: Exception
Failed to build bundle.
flutter build bundle
passes without error if I skip the flutter_rust_bridge_codegen
step
Suspect the codegen command is wrong. /cc @Desdaemon IIRC you have pointed out somewhere before that the codegen command needs some modifications? Maybe we need to do that in our book as well.
Btw, please refer to .github/workflow/...yaml
to see a working sample configuration
This works
flutter_rust_bridge_codegen --rust-input rust/src/api.rs --dart-output lib/bridge_generated.dart --dart-decl-output lib/bridge_definitions.dart
Great! Where did you see the wrong command? Feel free to PR to modify the book to fix it
In the case of pure_dart
flutter_rust_bridge_codegen
requires being built with
cargo run --package flutter_rust_bridge_codegen --bin flutter_rust_bridge_codegen --features "chrono,uuid"
pure_dart
won't generate correctly with cargo install flutter_rust_bridge_codegen
package. Thinking it's missing uuid
feature.
So on M1 I can now repro other post codegen, so that's progress:
pushd frm_codegen
cargo run --package flutter_rust_bridge_codegen --bin flutter_rust_bridge_codegen --features "chrono,uuid" -- \
--rust-input ../frb_example/pure_dart/rust/src/api.rs \
--dart-output ../frb_example/pure_dart/dart/lib/bridge_generated.dart \
--dart-decl-output ../frb_example/pure_dart/dart/lib/bridge_definitions.dart \
--dart-format-line-length 120 --wasm
popd
pushd frb_example/pure_dart
pushd rust && cargo build --verbose && popd
pushd dart && dart compile exe lib/main.dart -o main && popd
dart/main ../../../target/debug/libflutter_rust_bridge_example.dylib
popd
pure_dart won't generate correctly with cargo install flutter_rust_bridge_codegen package. Thinking it's missing uuid feature.
/cc @Roms1383 maybe we should make the uuid feature default?
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.
Describe the bug
With
frb_example/with_flutter
example andflutter_rust_bridge_codegen 1.48.1
I am not able to reproduce a working project.I'm using this command:
It shows the following files changed:
How do I reproduce the
with_flutter
example codegen for tip of treemaster
?Running the example without codegen works fine.
Codegen logs with
RUST_LOG=debug
environment variableTo Reproduce
No response
Expected behavior
No response
Generated binding code
No response
OS
MacOS
Version of
flutter_rust_bridge_codegen
1.48.1
Flutter info