Add optional support for prebuilt binaries#86
Open
FrankenApps wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
rustupor 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.tomlfile in the root folder of the downstream application (or Dart workspace) using anative_toolchain_rustbased library.I have a (hopefully self-explanatory) example below that can also be used for testing:
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.