Closed iapicca closed 1 year ago
Hi! Thanks for opening your first issue here! :smile:
@fzyzcjy I tried the troubleshooting you suggested here and indeed your example works as intended
So, are you just using the frb template repository without any modifications? Does the frb_example/with_flutter code work for you or not?
gh repo clone fzyzcjy/flutter_rust_bridge && \
cd flutter_rust_bridge/frb_example/pure_dart/ && \
rm -rf dart/lib/bridge_generated.* && \
rm -rf rust/src/bridge_generated.* && \
flutter_rust_bridge_codegen -r rust/src/api.rs -d dart/lib/bridge_generated.dart
Maybe there is something wrong with @Desdaemon 's flutter_rust_bridge mason brick or more likely I'm doing something wrong, either way I could use some help.
You mentioned a "[...] are you just using the frb template repository [...]", did you mean the mason brick I used above? I opened an issue to check if the problem is caused by the brick itself
I found this flutter-only template do you have a recommendation?
Thank you
The issue with the brick has been solved and can be closed now.
@Desdaemon Good job!
@iapicca So... is the bug resolved now?
@Desdaemon Good job!
@iapicca So... is the bug resolved now?
@fzyzcjy yes, the issue is solved @Desdaemon fixed the problem in a blink of an eye, thank you! Everything works as intended now
Thank you both!
Hello, I'm in the process of updating an existing project and am running into this same error.
Using version 1.80.1
works fine, but when I bump to 1.80.1
or higher I get the following error:
flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output lib/bridge/bridge_generated.dart # --c-output ios/Runner/bridge_generated.h # --c-output macos/Runner/bridge_generated.h --dart-decl-output lib/bridge/bridge_definitions.dart # --wasm
2023/09/28 08:01:40 [DEBUG] configs=[Opts { rust_input_path: "/home/cranston/workspace/oat_rs/native/src/api.rs", dart_output_path: "/home/cranston/workspace/oat_rs/lib/bridge/bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["/tmp/.tmppLPGXl.h"], rust_crate_dir: "/home/cranston/workspace/oat_rs/native", rust_output_path: "/home/cranston/workspace/oat_rs/native/src/bridge_generated.rs", class_name: "Native", dart_format_line_length: 80, dart_enums_style: false, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "/home/cranston/workspace/oat_rs/native/Cargo.toml", dart_root: Some("/home/cranston/workspace/oat_rs"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: false, wasm_enabled: false, inline_rust: false, bridge_in_method: true, extra_headers: "", dart3: true, keep_going: false }]
2023/09/28 08:01:40 [INFO] Running cargo expand in '/home/cranston/workspace/oat_rs/native'
2023/09/28 08:01:40 [DEBUG] execute command: bin=cargo args="expand --theme=none --ugly" current_dir=Some("/home/cranston/workspace/oat_rs/native") cmd=cd "/home/cranston/workspace/oat_rs/native" && "cargo" "expand" "--theme=none" "--ugly"
2023/09/28 08:01:41 [WARN] command=cd "/home/cranston/workspace/oat_rs/native" && "cargo" "expand" "--theme=none" "--ugly" stdout= stderr=error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
2023/09/28 08:01:41 [ERROR] panicked at 'cargo expand returned empty output', /home/cranston/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-1.81.0/src/commands.rs:316:17
thread 'main' panicked at 'cargo expand returned empty output', /home/cranston/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge_codegen-1.81.0/src/commands.rs:316:17
stack backtrace:
0: std::panicking::begin_panic
1: lib_flutter_rust_bridge_codegen::utils::misc::read_rust_file
2: lib_flutter_rust_bridge_codegen::config::opts::Opts::get_ir_file
3: lib_flutter_rust_bridge_codegen::utils::misc::get_symbols_if_no_duplicates
4: flutter_rust_bridge_codegen::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: Recipe `gen` failed on line 21 with exit code 101
I can open a separate issue if needed.
@cranst0n Hi, does the solution above work for you? (especially, the fix in the brick)
Sorry I'm not exactly sure what you mean by 'brick' here. If it's the command to clone the example repo and rust the code generator, then I can confirm that works as intended.
Hi, I mean the fix @Desdaemon mentioned
I'm not using mason or any bricks. I'm bumping the flutter_rust_bridge
library on the dart and rust side as well as the flutter_rust_bridge_codegen
executable.
2023/09/28 08:01:40 [DEBUG] execute command: bin=cargo args="expand --theme=none --ugly" current_dir=Some("/home/cranston/workspace/oat_rs/native") cmd=cd "/home/cranston/workspace/oat_rs/native" && "cargo" "expand" "--theme=none" "--ugly" 2023/09/28 08:01:41 [WARN] command=cd "/home/cranston/workspace/oat_rs/native" && "cargo" "expand" "--theme=none" "--ugly" stdout= stderr=error: extra arguments to
rustc
can only be passed to one target, consider filtering the package by passing, e.g.,--lib
or--bin NAME
to specify a single target
Ok it seems that, we did not consider the case that there can be multiple targets. cc @MnlPhlp who made that helpful cargo expand feature.
At the same time, you can disable the cargo expand feature (as long as you do not need frb to understand fancy macros)
Can you point me in the direction of how to disable it? I browsed through the source code looking for some kind of flag or environmental variable to set and came up empty.
Oops you are right. It is not a flag there yet (just auto disable under some circumstances but it is not enough for this case).
Indeed just modify this line https://github.com/fzyzcjy/flutter_rust_bridge/blob/b585ab532c078af5151f7160e4efc398437ac02c/frb_codegen/src/commands.rs#L262 to be true
;)
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
I'm getting started with flutter_rust_bridge, but I'm getting an error when I run the code generator
Codegen logs with
RUST_LOG=debug
environment variablelogs
```shell 2023/09/26 13:25:13 [INFO] Running cargo expand in '/Volumes/ROG/dev/deleteme/native' 2023/09/26 13:25:35 [WARN] command=cd "/Volumes/ROG/dev/deleteme/native" && "cargo" "expand" "--theme=none" "--ugly" stdout= stderr= Updating crates.io index Downloading crates ... Downloaded clap v4.4.5 Downloaded clap_builder v4.4.5 Compiling proc-macro2 v1.0.67 Compiling libc v0.2.148 Compiling unicode-ident v1.0.12 Compiling autocfg v1.1.0 Compiling serde v1.0.188 Compiling rustix v0.38.14 Compiling bitflags v2.4.0 Compiling memchr v2.6.3 Compiling utf8parse v0.2.1 Compiling syn v1.0.109 Compiling num-traits v0.2.16 Compiling indexmap v1.9.3 Compiling ryu v1.0.15 Compiling serde_json v1.0.107 Compiling hashbrown v0.12.3 Compiling strsim v0.10.0 Compiling cfg-if v1.0.0 Compiling heck v0.4.1 Compiling anstyle-parse v0.2.1 Compiling os_str_bytes v6.5.1 Compiling gimli v0.28.0 Compiling quote v1.0.33 Compiling syn v2.0.37 Compiling adler v1.0.2 Compiling colorchoice v1.0.0 Compiling itoa v1.0.9 Compiling rustversion v1.0.14 Compiling anstyle-query v1.0.0 Compiling anstyle v1.0.3 Compiling semver v1.0.19 Compiling camino v1.1.6 Compiling core-foundation-sys v0.8.4 Compiling iana-time-zone v0.1.57 Compiling anstream v0.5.0 Compiling miniz_oxide v0.7.1 Compiling cc v1.0.83 Compiling errno v0.3.3 Compiling atty v0.2.14 Compiling clap_lex v0.2.4 Compiling object v0.32.1 Compiling aho-corasick v1.1.1 Compiling anyhow v1.0.75 Compiling addr2line v0.21.0 Compiling regex-syntax v0.7.5 Compiling backtrace v0.3.69 Compiling is-terminal v0.4.9 Compiling linked-hash-map v0.5.6 Compiling fastrand v2.0.1 Compiling lazy_static v1.4.0 Compiling clap_lex v0.5.1 Compiling termcolor v1.3.0 Compiling log v0.4.20 Compiling textwrap v0.16.0 Compiling thiserror v1.0.48 Compiling bitflags v1.3.2 Compiling rustc-demangle v0.1.23 Compiling cbindgen v0.24.5 Compiling clap v3.2.25 Compiling clap_builder v4.4.5 Compiling tempfile v3.8.0 Compiling colored v1.9.4 Compiling yaml-rust v0.4.5 Compiling regex-automata v0.3.8 Compiling chrono v0.4.31 Compiling serde_derive v1.0.188 Compiling enum-iterator-derive v1.2.1 Compiling thiserror-impl v1.0.48 Compiling clap_derive v4.4.2 Compiling lock_api v0.4.10 Compiling parking_lot_core v0.9.8 Compiling once_cell v1.18.0 Compiling either v1.9.0 Compiling enum_dispatch v0.3.12 Compiling itertools v0.10.5 Compiling regex v1.9.5 Compiling clap v4.4.5 Compiling enum-iterator v1.4.1 Compiling strum_macros v0.24.3 Compiling fern v0.6.2 Compiling delegate-attr v0.3.0 Compiling dart-sys v4.0.2 Checking smallvec v1.11.1 Compiling pathdiff v0.2.1 Checking scopeguard v1.2.0 Compiling topological-sort v0.2.2 Compiling build-target v0.4.0 Compiling convert_case v0.5.0 Compiling flutter_rust_bridge v1.82.1 Checking num_cpus v1.16.0 Checking atomic v0.5.3 Checking threadpool v1.8.1 Checking parking_lot v0.12.1 Checking bytemuck v1.14.0 Compiling flutter_rust_bridge_macros v1.82.1 Checking allo-isolate v0.1.20 Compiling toml v0.5.11 Compiling cargo-platform v0.1.3 Compiling serde_yaml v0.8.26 Compiling cargo_metadata v0.14.2 Compiling flutter_rust_bridge_codegen v1.82.1 Compiling native v0.1.0 (/Volumes/ROG/dev/deleteme/native) error: failed to run custom build command for `native v0.1.0 (/Volumes/ROG/dev/deleteme/native)` Caused by: process didn't exit successfully: `/Volumes/ROG/dev/deleteme/native/target/debug/build/native-b6a714489c2a87e9/build-script-build` (exit status: 2) --- stdout cargo:rerun-if-changed=src/api.rs --- stderr error: --c-output's inputs should match --rust-input's length Usage: flutter_rust_bridge_codegen [OPTIONS] --rust-inputTo Reproduce
Expected behavior
create the file
'bridge_generated.dart
and the correctNativeImpl
Generated binding code
OS
macOS 13.6 22G120 arm64
Version of
flutter_rust_bridge_codegen
v1.0.3
Flutter info
Version of
clang++
Apple clang version 15.0.0 (clang-1500.0.40.1)
Version of
ffigen
ffi: ^2.1.0
Additional context