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

[Feature Request] Desktop support? #66

Closed
TENX-S opened this issue Oct 11, 2021 · 12 comments
Closed

[Feature Request] Desktop support? #66

TENX-S opened this issue Oct 11, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@TENX-S
Copy link
Contributor

TENX-S commented Oct 11, 2021

It's very inspiring to have such a library for those who like both flutter and rust, but it would be better if it can also support the desktop. Any plans on that ?

@TENX-S TENX-S added the enhancement New feature or request label Oct 11, 2021
@welcome
Copy link

welcome bot commented Oct 11, 2021

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 11, 2021

Since desktop flutter allows ffi as well, there should be no problem imho.

@yoroshikun
Copy link

I just tested the example with windows and it crashes with

late final dylib =
    Platform.isAndroid ? DynamicLibrary.open('libflutter_rust_bridge_example.so') : DynamicLibrary.process();
// DynamicLibrary.process is not available on this platform

Would this be a simple fix? (I have not looked into it just ran the simple example), and as expected dart:ffi does not work for web target at all XD wonder if there is room for a wasm implementation of this bridge 🤔

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 12, 2021

@yoroshikun This library does nothing but generate some Rust&Dart code, which human beings will write down manually without this lib. Therefore, maybe simply try to run a very simple Dart FFI + Rust program on desktop. If that works, my lib should work (and please tell me).

For example, Dart using FFI to call a Rust function like fn add(a:i32,b:i32)->i32{a+b} is enough. If that works, this lib should work pretty well.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 12, 2021

As for why that example itself crashes, it is unrelated to this lib: That example (inspired from Flutter tutorial) opens .so file. However, windows should use something like dll. As mentioned above, try a simplest sample rust+dart ffi program to set up the environment.

@yoroshikun
Copy link

Quickly testing it out with the most simple api and default flutter app as you said, have followed setup instructions, however seems to be having an issue finding a file but not sure what one. (Phase: Other things), both files do exist, it generates and places the rust generated part fine

flutter_rust_bridge_codegen --rust-input rust\src\api.rs --dart-output lib\bridge_generated.dart
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "C:\\Users\\Yoroshi\\projects\\testapp\\rust\\src\\api.rs", dart_output_path: "C:\\Users\\Yoroshi\\projects\\testapp\\lib\\bridge_generated.dart", c_output_path: "C:\\Users\\Yoroshi\\AppData\\Local\\Temp\\.tmpHDUZRM.h", rust_crate_dir: "C:\\Users\\Yoroshi\\projects\\testapp\\rust", rust_output_path: "C:\\Users\\Yoroshi\\projects\\testapp\\rust\\src\\bridge_generated.rs", class_name: "Rust", dart_format_line_length: 80 }
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Parse source code to AST
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Parse AST to IR
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Transform IR
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Generate Rust code
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Generate Dart code
[2021-10-12T09:07:00Z INFO  flutter_rust_bridge_codegen] Phase: Other things
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', C:\Users\Yoroshi\.cargo\registry\src\github.com-1ecc6299db9ec823\flutter_rust_bridge_codegen-1.0.3\src\commands.rs:19:35

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 12, 2021

No, that flutter app is not tested on desktop. I mean, following Flutter's official tutorials, to create a simplest Flutter app that runs on Desktop and talks to Rust via ffi - that simplest app should not use this package (yet). Instead, do a simple add(a,b) is enough.

@fzyzcjy fzyzcjy changed the title [Feature Request] Desktop support ? [Feature Request] Desktop support? Oct 12, 2021
@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 13, 2021

I did a bit of research. Seems that Flutter desktop has the ffi functionality, such as this or this (but they are of course complex and we do not need to do that). So this lib should work well as long as you set up the Flutter desktop app's ffi functionality successfully.

I may modify my with_flutter example supporting that later. Feel free to make a PR if you want!

Theoretically, the code of this package itself should see no modification. Only the example tutorial needs to be modified.

@TENX-S
Copy link
Contributor Author

TENX-S commented Oct 16, 2021

It would be great if we can have an example include supporting desktop, but I'm not capable to do this atm.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 16, 2021

Sure. I may add that later.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Oct 28, 2021

Example is now added. #130

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants