Rust
This page will help you use Earthly if you are using Rust.
Step 1: Import the Rust library
To get started, import the rust library as shown below. Note that the --global-cache
flag is currently required to allow for adequate caching of the Rust toolchain. This flag will be implied in a future release.
Step 2: Initialize the Rust toolchain
Next, initialize the Rust toolchain via rust+INIT
. This will install any necessary dependencies that rust+CARGO
needs underneath.
Step 3: Build your Rust project
Now you can build your Rust project. Collect the necessary sources and call rust+CARGO
to build your project.
Notice the need for the --keep-ts
flag when copying the source files. This is necessary to ensure that the timestamps of the source files are preserved such that Rust's incremental compilation works correctly.
Additionally, because cargo does not make a good distinction between intermediate and final artifacts, we use the --output
flag to specify which files should be extracted from the cache at the end of the operation.
Finally
For a complete Earthfile example on how to use Rust in Earthly, visit the rust example directory on GitHub.
See also the reference documentation for lib/rust, to understand the different parameters used with rust+INIT
and rust+CARGO
.
Last updated