pub struct WasmBuildSpec { /* private fields */ }Expand description
Complete caller-owned description of one cacheable Cargo Wasm build.
The selected package graph, sources, semantic workspace projection, Cargo configuration, Rust toolchain files, target, profile arguments, explicit child environment, selected inherited environment, and additional watched inputs contribute to the build fingerprint. The complete workspace manifest and lockfile remain conservative mutation-validation inputs.
Implementations§
Source§impl WasmBuildSpec
impl WasmBuildSpec
Sourcepub fn new(
workspace_root: &Path,
target_dir: &Path,
packages: &[&str],
profile_target_dir: &str,
) -> Self
pub fn new( workspace_root: &Path, target_dir: &Path, packages: &[&str], profile_target_dir: &str, ) -> Self
Describe one Cargo build targeting wasm32-unknown-unknown.
profile_target_dir is Cargo’s output subdirectory, such as debug,
release, or the name supplied to --profile. It must be one normal
path component so artifacts remain inside their target directories.
It must match the profile selected by with_cargo_profile_args: the
default, dev, and test use debug; release and bench use release.
Relative workspace_root and exact target_dir paths are resolved from
the caller’s working directory. Shared targets are workspace-relative.
Package names are sorted and deduplicated for identity, discovery,
Cargo invocation, and artifact paths.
Misses share the workspace-relative target/ic-testkit-incremental
Cargo target by default. Use Self::with_isolated_builds when compiler
state must be independent, and select retention limits explicitly.
Acquisition always builds package libraries with Cargo’s --lib flag;
binary and other targets cannot replace the canister library output.
Each acquired package must declare a cdylib library with the same name
as the package, matching its expected <package>.wasm output path.
Sourcepub fn with_cargo_profile_args<I, S>(self, arguments: I) -> Self
pub fn with_cargo_profile_args<I, S>(self, arguments: I) -> Self
Set Cargo profile and feature arguments used for the build and fingerprint.
Workspace, package, compilation target, and target-directory overrides
are rejected before resolution or acquisition; use this specification’s
corresponding fields and builders. --config overrides are also
rejected: use Cargo’s discovered configuration files or explicit
environment overrides so resolution and execution share tracked inputs.
Help and build-graph flags are rejected because they exit successfully
without building. The selected profile must match profile_target_dir;
declaring an output directory does not select a Cargo profile.
Binary, example, test, bench, and all-target selectors are rejected to
keep acquisition restricted to canister libraries. --lib is supported
and already included in every build command.
Sourcepub fn with_extra_env<I, K, V>(self, environment: I) -> Self
pub fn with_extra_env<I, K, V>(self, environment: I) -> Self
Set deterministic OS-native child-process environment overrides.
CARGO_TARGET_DIR is owned by the cache configuration and cannot be
overridden here. Conflicting specifications fail before acquisition.
Sourcepub fn with_inherited_env<I, S>(self, names: I) -> Self
pub fn with_inherited_env<I, S>(self, names: I) -> Self
Add ambient environment names whose current values affect the build.
Common Rust and Cargo toolchain variables are included automatically. Callers must declare application-specific variables read by build scripts.
Sourcepub fn with_additional_inputs<I, P>(self, paths: I) -> Self
pub fn with_additional_inputs<I, P>(self, paths: I) -> Self
Add files or directories not discoverable through Cargo’s local dependency graph.
Relative paths are resolved from the workspace root. Use this for build script configuration, generated schemas, or other externally read inputs.
Sourcepub fn with_target(self, target: &str) -> Self
pub fn with_target(self, target: &str) -> Self
Override the Cargo compilation target.
Sourcepub fn with_cargo_program(self, program: impl Into<OsString>) -> Self
pub fn with_cargo_program(self, program: impl Into<OsString>) -> Self
Override the Cargo executable used by metadata, identity, and build commands.
Sourcepub fn with_rustc_program(self, program: impl Into<OsString>) -> Self
pub fn with_rustc_program(self, program: impl Into<OsString>) -> Self
Override the Rust compiler executable used to fingerprint the toolchain.
This selects the -vV identity probe; it does not change the compiler
invoked by Cargo or infer a compiler hidden inside a Cargo shim. Supply
the actual shim-selected compiler. To configure Cargo and its identity
together, use with_extra_env([("RUSTC", program)]); that explicit environment
selection takes precedence over this identity-only setting.
Build cache misses in one caller-owned shared Cargo incremental target.
Exact final Wasm artifacts still live in the content-addressed cache.
The shared target is coordinated across processes but is never pruned
or removed by ic-testkit after a failed build.
Sourcepub fn with_isolated_builds(self) -> Self
pub fn with_isolated_builds(self) -> Self
Build each fingerprint in a separate Cargo target instead of sharing state.
Select this when the test explicitly requires isolated compiler state. Retained targets need a caller-selected prune policy to bound disk use.
Schedule caller-owned shared-target retention as part of acquisition.
This option requires shared incremental mode (the default). Every acquisition coordinates through that target, including an exact hit, so a missing target can be created and receive its first schedule marker immediately. Matching recent passes only check the marker; due passes reuse the acquisition’s exact Cargo input resolution before evaluating retention. The structured result is attached to the build record and emitted through observed progress. Maintenance failures fail the acquisition and do not record a successful schedule marker.
Attach an explicit shared-target maintenance configuration.
This is the configurable counterpart to
Self::with_shared_incremental_target_maintenance_at_most_every and
supports strict or best-effort failure handling.
Sourcepub const fn with_prune_policy(self, policy: ArtifactCachePrunePolicy) -> Self
pub const fn with_prune_policy(self, policy: ArtifactCachePrunePolicy) -> Self
Apply cache retention under the build operation’s existing process lock.
Maintenance is best-effort: its structured result is attached to the successful build record and cannot turn ready artifacts into a build failure. The active fingerprint is protected from this pruning pass.
Sourcepub const fn with_prune_policy_at_most_every(
self,
policy: ArtifactCachePrunePolicy,
minimum_interval: Duration,
) -> Self
pub const fn with_prune_policy_at_most_every( self, policy: ArtifactCachePrunePolicy, minimum_interval: Duration, ) -> Self
Apply exact-entry retention at most once per minimum_interval.
The active fingerprint remains protected. A zero interval is equivalent
to Self::with_prune_policy. The interval covers attempted
maintenance, including a nonfatal failed attempt. This schedule never
owns or scans a caller-owned shared incremental Cargo target.
Sourcepub fn workspace_root(&self) -> &Path
pub fn workspace_root(&self) -> &Path
Workspace containing the selected Cargo packages.
Sourcepub fn target_dir(&self) -> &Path
pub fn target_dir(&self) -> &Path
Cargo target directory containing artifacts, lock, and stamps.
Sourcepub fn packages(&self) -> &[String]
pub fn packages(&self) -> &[String]
Selected Cargo package names in sorted order, without duplicates.
Sourcepub const fn cache_mode(&self) -> &WasmBuildCacheMode
pub const fn cache_mode(&self) -> &WasmBuildCacheMode
Cargo-target ownership mode used for cache misses.
Sourcepub const fn prune_policy(&self) -> Option<ArtifactCachePrunePolicy>
pub const fn prune_policy(&self) -> Option<ArtifactCachePrunePolicy>
Exact-entry retention policy attached to this specification, when configured.
Sourcepub const fn prune_interval(&self) -> Option<Duration>
pub const fn prune_interval(&self) -> Option<Duration>
Minimum interval between exact-entry retention attempts, when scheduled.
Shared incremental-target maintenance attached to this specification.
Trait Implementations§
Source§impl Clone for WasmBuildSpec
impl Clone for WasmBuildSpec
Source§impl Debug for WasmBuildSpec
impl Debug for WasmBuildSpec
impl Eq for WasmBuildSpec
Source§impl PartialEq for WasmBuildSpec
impl PartialEq for WasmBuildSpec
impl StructuralPartialEq for WasmBuildSpec
Auto Trait Implementations§
impl Freeze for WasmBuildSpec
impl RefUnwindSafe for WasmBuildSpec
impl Send for WasmBuildSpec
impl Sync for WasmBuildSpec
impl Unpin for WasmBuildSpec
impl UnsafeUnpin for WasmBuildSpec
impl UnwindSafe for WasmBuildSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.