Documentation request: How Rust code compiles and loads into Flutter/Rust runtime.
I would like to read more about how FRB works.
As I understood one of the main part is flutter_rust_bridge_codegen generate which generates *_generated.rs, *_generated.dart and api/*.dart files. It's just glue code between Flutter/Dart runtime and Rust library which are communicates using FFI.
But I didn't find information how Rust code actually compiles into binary code/lib, where the lib stored, how and when it loaded, etc. Also I didn't find how flags (e.g. --release) are passed to cargo(?). Or, for example, what will happend when I change scheme configuration to release in Xcode project (this question is related to Flutter itself probably?), how my Rust code will understand that it will be need to compile with --release flag?
Additional context I would like to "sell" the FRB to my company because I would like to write on Rust but there are some senior devs who will ask a lot of "why" and "how" questions (and it's right) when I will present FRB to them. So I need to be prepared :)
But I didn't find information how Rust code actually compiles into binary code/lib, where the lib stored, how and when it loaded, etc. Also I didn't find how flags (e.g. --release) are passed to cargo(?). Or, for example, what will happend when I change scheme configuration to release in Xcode project (this question is related to Flutter itself probably?), how my Rust code will understand that it will be need to compile with --release flag?
There are many different possible ways that you can choose freely: https://cjycode.com/flutter_rust_bridge/manual/integrate/overview.
For example, suppose you are using the default template, then it is cargokit which does the compilation logic.
However, in the future, when Dart/Flutter's "native asset" feature is stablized (I guess it should be there within one or two Dart versions?), we can have easier integration logic.
I would like to "sell" the FRB to my company because I would like to write on Rust but there are some senior devs who will ask a lot of "why" and "how" questions (and it's right) when I will present FRB to them. So I need to be prepared :)
Feel free to ask questions! As can be seen, I usually reply quickly (except when sleeping) :)
There are many different possible ways that you can choose freely: https://cjycode.com/flutter_rust_bridge/manual/integrate/overview.
I saw it. Will read more carefully.
For example, suppose you are using the default template, then it is cargokit which does the compilation logic.
The most interesting question for me right now is how flutter run command knows that it needs to build some Rust code. Probably will find the answer in the link above.
The most interesting question for me right now is how flutter run command knows that it needs to build some Rust code. Probably will find the answer in the link above.
Yes more details can be found in cargokit's blog. In short, for example: In android, you have freedom to add whatever custom scripts in build.gradle - so the general approach is to add a script which compiles rust.
@fzyzcjy With old way i can build sdk without source code for my developers but with version 2 how i can build sdk and give project to other developers without expose rust code. Can you point me to the document i can learn to do that
@DAOCUONG Sure, https://cjycode.com/flutter_rust_bridge/manual/integrate/overview
Indeed, if you have been using v1, one simplest way to still distribute without exposing rust code may be that, just continue to use your current approach to build Rust+Dart, and add v2 by creating a flutter_rust_bridge.yaml and move a few Rust files and change a few imports etc.
Close since this seems to be solved. Feel free to reopen if needed!
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.