rules/rust/toolchain/index.js
Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.
RUST_TOOL
const RUST_TOOL
Undocumented.
rustArtifactName()
rustArtifactName(_version, plat)
Return the rustup-init filename for a platform. versioned by RUSTUP_VERSION, not the Rust release).
| Parameter | Type | Description |
|---|---|---|
| _version | string | Rust toolchain version (unused; the installer is |
| plat | { os: string, arch: string } |
Returns: string
rustDownloadUrl()
rustDownloadUrl(version, plat)
Return the rustup-init download URL for a platform, pinned to RUSTUP_VERSION.
| Parameter | Type | Description |
|---|---|---|
| version | string | Rust toolchain version (recorded in the lock; not in the URL). |
| plat | { os: string, arch: string } |
Returns: string
rustCacheKey()
rustCacheKey(version, plat)
Return the named-cache key for a Rust toolchain version and platform. Shared by both the rustup-home and cargo-home caches.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
rustToolchainId()
rustToolchainId(version, plat)
Return the on-disk toolchains/<id> directory name rustup installs into.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
rustSupportedPlatforms()
rustSupportedPlatforms()
Return the platforms we publish rustup-init lockfile entries for, derived from the TARGET_TRIPLES map (keyed "os-arch").
Returns: Array<{ os: string, arch: string }>
RustToolchain (implementation class)
class RustToolchain
Implementation class. BUILD files should use rustToolchain().
Undocumented.
rustToolchain()
rustToolchain(version, opts = {})
Declare a Rust toolchain version and optionally set it as the default. without a matching lockfile entry (warns instead of failing). gccToolchain()) registering a "rust-link-driver" product. Falls back to defaultGccToolchain() if omitted. registering a "rust-linker" product. No extra backend flag is added if omitted. kacheToolchain(), see //rules/rust/kache) registering a "rust-build-cache" product. Wraps rustc with kache and points it at a persistent on-disk object cache; no build caching beyond cargo's own (mtime-defeated, sandbox-fresh) incremental state is added if omitted.
| Parameter | Type | Description |
|---|---|---|
| version | string | Exact Rust version, e.g. "1.79.0" (channels rejected). |
| [opts] | object | |
| [opts.default=false] | boolean | Set as the default toolchain. |
| [opts.unverified=false] | boolean | Allow downloading rustup-init |
| [opts.linkDriver] | object | C link driver toolchain handle (e.g. |
| [opts.linker] | object | Linker toolchain handle (e.g. moldToolchain()) |
| [opts.kache] | object | kache toolchain handle (e.g. |
Returns: object Target handle for this Rust toolchain.
installRustToolchain()
installRustToolchain(version, source)
Seed the rustup-home and cargo-home caches from an already-installed layout.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| source | { rustupHome: string, cargoHome: string } |
Returns: { rustupHome: string|null, cargoHome: string|null }
acquireRustToolchain
const acquireRustToolchain
Acquire a Rust toolchain: download rustup-init and run it, installing into the rustup-home and cargo-home named caches.
| Parameter | Type | Description |
|---|---|---|
| version | string |
Returns: Promise<string> Local path to the RUSTUP_HOME cache root.
resolveRustToolchainVersion()
resolveRustToolchainVersion(version)
Resolve an explicit or default Rust toolchain version.
| Parameter | Type | Description |
|---|---|---|
| [version] | string |
Returns: string|null
defaultRustToolchainVersion()
defaultRustToolchainVersion()
Return the currently configured default Rust toolchain version.
Returns: string|null
defaultRustToolchain()
defaultRustToolchain()
Return the currently configured default Rust toolchain target handle.
Returns: object|null