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

Add Rust package (binary-only) #16

Merged
merged 5 commits into from
May 31, 2024
Merged

Add Rust package (binary-only) #16

merged 5 commits into from
May 31, 2024

Conversation

kylewlacy
Copy link
Member

This PR adds a new rust package:

  • Using the default export as a dependency gives you rustc and cargo, among other standard Rust binaries
  • The function rust.cargoBuild() lets you build a crate, including caching dependency downloads and validating the lockfile is up to date

Rather than build from source, the current version of the rust package installs Rust by downloading a manifest file (the same one used by Rustup) and calling the install.sh file for each desired component. This ends up using the official Rust binaries.

To parse the manifest, I had to make two other changes:

  • Add typer.record() function for parsing objects based on key/value type
  • Add smol_toml package. The Rustup manifests are TOML, so to parse them, I vendored the small-toml NPM package as the smol_toml Brioche package (I made a few manual changes to silence warnings and to match the formatting conventions for .bri files)

As part of caching dependencies properly, I internally pulled in a precompiled binary for cargo-chef, namely to create a "skeleton crate" so dependencies can be cached based only on the Cargo.toml and Cargo.lock files (instead of all of the source code, which would effectively be uncached). I also tried to use this to cache builds of dependencies, but I was thwarted because each build runs in a different $HOME, and Cargo fingerprints the cache based on the source path. Caching dependencies will take some more work

@kylewlacy kylewlacy merged commit ccd78e7 into main May 31, 2024
3 checks passed
@kylewlacy kylewlacy deleted the add-rust-package branch May 31, 2024 22:16
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