Skip to content

Add optional support for prebuilt binaries#86

Open
FrankenApps wants to merge 3 commits into
GregoryConrad:mainfrom
FrankenApps:prebuilt-binaries
Open

Add optional support for prebuilt binaries#86
FrankenApps wants to merge 3 commits into
GregoryConrad:mainfrom
FrankenApps:prebuilt-binaries

Conversation

@FrankenApps

Copy link
Copy Markdown

This is an attempt to add support for prebuilt binaries that are downloaded from a remote server instead of building from source on an opt-in basis.

Reasoning

This feature is useful if downstream users want to avoid installing rustup or if they want to avoid building from source due to constrained disk space.

Additionally this also allows building in air-gapped environments without internet access, if the prebuilt binaries are served via a local server.

Design

The feature is roughly modeled after the support for precompiled binaries in cargokit.

At build-time the hook will check if there is a native_toolchain_rust.toml file in the root folder of the downstream application (or Dart workspace) using a native_toolchain_rust based library.

I have a (hopefully self-explanatory) example below that can also be used for testing:

[prebuilt-binaries.dart_only_prebuilt_binaries_example]
url = "https://github.com/FrankenApps/native_toolchain_rust/releases/download/dart_only_prebuilt_binaries_example-v{version}/dart_only_prebuilt_binaries_example-{target}.bin"

Note that (I think contrary to the implementation in Cargokit) the build will fail if a config file is present that for example points to an invalid URL. I found that to be more transparent for the user instead of (silently) falling back to building from source (I expect most users to not specify a custom logger).

Safety

The feature is completely opt-in and I still advised users to rely on building from source whenever possible, but as mentioned above there are circumstances where this is rather undesirable.

I contemplated letting users optionally specify a list of SHA256 hashes of which every downloaded binary per target must match exactly one, for improved safety, but for now decided against it, because it would be tedious for the users having to manually add them for every new version.

Testing

I added new tests and a dedicated example. I also updated the documented with a high-level explanation of the feature.

Please let me know what you think.

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

Successfully merging this pull request may close these issues.

1 participant