fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 283 forks source link

[Bug] should allow ffigen 7.x #822

Closed CicadaCinema closed 1 year ago

CicadaCinema commented 1 year ago

Describe the bug

Section 5.2. Installing dependencies of the docs suggests running dart pub add --dev ffigen or flutter pub add --dev ffigen. The current major version of this package is 7.x.x, but adding a constraint like ffigen: ^7.2.0 results in the following error message when running the codegen:

>flutter_rust_bridge_codegen -r native\src\lib.rs -d lib\bridge_generated.dart
Flutter 3.3.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e99c9c7cd9 (4 days ago) • 2022-11-01 16:59:00 -0700
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0
[2022-11-05T12:56:00Z ERROR flutter_rust_bridge_codegen] fatal: please update version of ffigen in your dev_dependencies. (version >=6.0.1, <7.0.0)

Codegen logs with RUST_LOG=debug environment variable

>flutter_rust_bridge_codegen -r native\src\lib.rs -d lib\bridge_generated.dart
[2022-11-05T13:18:56Z DEBUG flutter_rust_bridge_codegen] configs=[Opts { rust_input_path: "C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\native\\src\\lib.rs", dart_output_path: "C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\lib\\bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["C:\\Users\\Atom\\AppData\\Local\\Temp\\.tmpybb1Z3.h"], rust_crate_dir: "C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\native", rust_output_path: "C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\native\\src\\bridge_generated.rs", class_name: "Native", dart_format_line_length: 80, 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: "C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\native\\Cargo.toml", dart_root: Some("C:\\Users\\Atom\\AndroidStudioProjects\\ffv"), build_runner: true, block_index: BlockIndex(0), skip_deps_check: false, wasm_enabled: false, inline_rust: false }]
[2022-11-05T13:18:56Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "\\\\?\\C:\\Users\\Atom\\AndroidStudioProjects\\ffv\\native\\src\\bridge_generated.rs"
[2022-11-05T13:18:56Z WARN  lib_flutter_rust_bridge_codegen::source_graph] Skipping unresolvable module io (tried \\?\C:\Users\Atom\AndroidStudioProjects\ffv\native\src\io.rs, \\?\C:\Users\Atom\AndroidStudioProjects\ffv\native\src\io\mod.rs, \\?\C:\Users\Atom\AndroidStudioProjects\ffv\native\src\bridge_generated\io.rs, \\?\C:\Users\Atom\AndroidStudioProjects\ffv\native\src\bridge_generated\io\mod.rs, )
[2022-11-05T13:18:56Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(add)
[2022-11-05T13:18:56Z DEBUG lib_flutter_rust_bridge_codegen::tools] Guessing toolchain the runner is run into
[2022-11-05T13:18:56Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=powershell args="-noprofile -command & \"flutter\" \"--version\"" current_dir=None cmd="powershell" "-noprofile" "-command" "& \"flutter\" \"--version\""
Flutter 3.3.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e99c9c7cd9 (4 days ago) • 2022-11-01 16:59:00 -0700
Engine • revision 857bd6b74c
Tools • Dart 2.18.4 • DevTools 2.15.0
[2022-11-05T13:18:58Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="powershell" "-noprofile" "-command" "& \"flutter\" \"--version\"" stdout= stderr=
[2022-11-05T13:18:58Z DEBUG lib_flutter_rust_bridge_codegen::tools] Checking presence of ffi in dependencies at C:\Users\Atom\AndroidStudioProjects\ffv
[2022-11-05T13:18:58Z DEBUG lib_flutter_rust_bridge_codegen::tools] Checking presence of ffi in dependencies at C:\Users\Atom\AndroidStudioProjects\ffv
[2022-11-05T13:18:58Z DEBUG lib_flutter_rust_bridge_codegen::tools] Checking presence of ffigen in dev_dependencies at C:\Users\Atom\AndroidStudioProjects\ffv
[2022-11-05T13:18:58Z DEBUG lib_flutter_rust_bridge_codegen::tools] Checking presence of ffigen in dev_dependencies at C:\Users\Atom\AndroidStudioProjects\ffv
[2022-11-05T13:18:58Z ERROR flutter_rust_bridge_codegen] fatal: please update version of ffigen in your dev_dependencies. (version >=6.0.1, <7.0.0)

To Reproduce

No response

Expected behavior

No response

Generated binding code

No response

OS

Windows

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Version of ffigen

No response

Additional context

See also:

C. The below error message was output with a boiler plate project created with Android Studio when using flutter_rust_bridge_codegen

fatal: please update version of ffigen in your dev_dependencies. (version >=6.0.1, <7.0.0)

The fix was obvious - but it might be useful to update installation instructions:

dev_dependencies:
  ffigen: ^6.0.1

https://github.com/fzyzcjy/flutter_rust_bridge/issues/816#issuecomment-1300955739

welcome[bot] commented 1 year ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 1 year ago

Feel free to PR! That should be quite easy (make the constraint looser)

CicadaCinema commented 1 year ago

I don't know much about the codebase - does the breaking change in 7.0.0 impact the bridge in any way?

fzyzcjy commented 1 year ago

I guess no since frb uses abs path. Anyway you can PR and see ci

github-actions[bot] commented 1 year ago

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.