dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
157 stars 45 forks source link

[native_assets_cli] `fetch` and `offline` mode #1620

Open dcharkes opened 2 months ago

dcharkes commented 2 months ago

@reidbaker Suggested we should have fetch hook/flag, and an offline flag.

I've spend some thought on what would be a good way of doing this.

One design goal should be that a build hook can wrap an existing native build system or native package manager. This leads to the following design constraints:

Another design goal should be that after the fetch step, the build step wouldn't need any internet access. In other words, it would succeed offline. This leads to the following design constraints:

I'm not sure if the best design would be to have a hook/fetch.dart which would get a FetchConfig (most likely no output, just exitCode of the process for success or not). Or if BuildConfig should get a bool fetchOnly.

Pros for fetch as flag on hook/build.dart

Cons for fetch as flag on hook/build.dart

For offline, I think a bool on BuildConfig is the right place.

And offline and fetch are related in the sense that after fetch the build hook should not need any internet access. Which passing the offline flag would enforce.

@HosseinYousefi @mosuem @liamappelbe @brianquinlan In your use cases, do you wrap existing native build systems / native package managers that need internet access to fetch dependencies? (To produce dylibs/jars/...) And if yes, do those have a separate fetch step and an offline mode?

Any other concerns we should take into account for a fetch step/flag and offline flag?

cc @mkustermann @stuartmorgan

mosuem commented 2 months ago

To be had in a separate discussion probably:

If fetchOnly is false, it's a single process invocation for fetch and build, instead of two.

That we do many process invocations for hooks is a problem in itself, which I believe should be addressed at some point (Maybe collect all hooks into a single Dart file?).

brianquinlan commented 1 month ago

In your use cases, do you wrap existing native build systems / native package managers that need internet access to fetch dependencies? (To produce dylibs/jars/...) And if yes, do those have a separate fetch step and an offline mode?

Not in any use case that I've encountered so far.