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

Precompiled builds #68

Open
vhdirk opened this issue May 22, 2024 · 3 comments
Open

Precompiled builds #68

vhdirk opened this issue May 22, 2024 · 3 comments

Comments

@vhdirk
Copy link

vhdirk commented May 22, 2024

First off, congrats and thanks for this project 👏 .

I know this (the title) is probably orthogonal to your project, but I was hoping to get in touch since rust+flutter is really rather new.
For a parser library I'm creating, I wanted to make dart/flutter bindings: vhdirk/dash7-rs#33:

The project was generated with flutter_rust_bridge and then modified a bit to try and make the 'magic' aspect of it a little less hidden. One of my goals is to not require the users of this library (me :) ) to have a working rust toolchain. Rather, I'd like to make builds available on pub, so that I can just use the package as if it where a regular dart/flutter package.

As far as I can tell, there seem to be 2 ways to do this:

  • hook into the flutter build system and download the prebuilt binaries for the platform as needed. I don't know where I'd host them, but it probably won't be github for reasons beyond the scope of this issue.
  • use native assets (☂️ Native assets support flutter/flutter#129757)

For simplicity (from front-end developer POV), I wanted to try out native assets. It seems rather logical that the binaries would be shipped with the package itself. I came across your other project https://github.com/irondash/native_toolchain_rust. I think this is a (albeit very experimental) way to bundle rust libs with a dart/flutter package.

Seeing how iOS is currently still missing from native_toolchain_rust, and me not knowing the tiniest bit about building for iOS in the first place, I was thinking:

Do you think it possible to trigger cargokit from hooks/build.dart, as such that it would then provide (and tell flutter/dart build about) the binaries? Since native_toolchain_cli provides the utilities to specify binaries per platform, I would guess that it shouldn't be that hard.

Which is why I started from the example here: https://github.com/dart-lang/native/blob/main/pkgs/native_assets_cli/example/build/local_asset/hook/build.dart. I am assuming the file asset.txt should end up in build/flutter_assets and referenced in AssetManifest.json , when running flutter build bundle (without arguments).

Is this correct at all? Am I on the right track here?

If you could share some of your wisdom (or point me to a place where I should look instead), I would be very grateful!

@knopp
Copy link
Contributor

knopp commented May 22, 2024

Hi,

what do you mean by ios missing from native_toolchain_rust? The iOS support should be all there. Cargokit is basically a hack that was necessary before native assets, and I plan to retire it as soon as possible because it's essentially holds together with duck tape. native_toolchain_rust is the way to go. Though it currently needs flutter main and an experimental flag.

One thing cargokit has that native_toolchain_rust doesn't is support for precompiled binaries, but long term I'd prefer to rely on native_doctor to setup user environment instead of shipping binary blobs.

@vhdirk
Copy link
Author

vhdirk commented May 22, 2024

Interesting!

The iOS support should be all there.

Then obviously I was wrong :). The thing that made me jump to that conclusion is the presence of https://github.com/irondash/cargokit/blob/main/build_tool/lib/src/build_pod.dart in cargokit. But as said, my experience with building for iOS is extremely limited.

One thing cargokit has that native_toolchain_rust doesn't is support for precompiled binaries

What do you mean by this? Now I'm confused; I thought the whole point was to compile the binaries 'here' to begin with?

Is flutter main needed only for building the package? or also for consuming?

I will post any further questions on the native_toolchain_rust repo instead.

@vhdirk
Copy link
Author

vhdirk commented May 22, 2024

After reading the proposal for native_assets again, I realize I had it all wrong, apparently. My goal of bundling the shared library with the package seems really not what that is all intended for?

If so, I guess I need to go about it in another way: build the native bits with cargokit, place them somewhere so that they get picked up by pub publish, and then use native_assets_cli to hand them over to the app that is being built. Does that sound about right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants