pub fn build_native_executable(
spec: &NativeExecutableSpec<'_>,
cargo: impl FnMut() -> Command,
diagnostics: impl Write,
admit: impl FnMut() -> Result<()>,
) -> Result<NativeExecutable, Box<dyn Error + Send + Sync>>Expand description
Build a selected native target and return Cargo’s reported executable.
The factory supplies the same Cargo prefix, working directory, environment
and network/tool policy for metadata and build. Commands add --locked, exact
package/target selection and Cargo’s JSON diagnostics format. Stdout is a
bounded-per-message protocol; rendered compiler diagnostics and piped stderr
stream to diagnostics. Other stderr configurations remain intact. Stdin is
null. This owns direct-child completion, not process-group or signal policy.
admit runs before each command factory, so caller interruption can refuse
another dispatch after metadata. In-flight commands still run to completion.
Callers exclude source/config/tool mutation and retain artifact custody. No cache, installation, release admission, retry or elapsed-time default is added. Interrupted or rejected capture uses Host’s direct-child cleanup evidence.
§Errors
Refuses invalid selection before command effects, missing/ambiguous metadata or artifacts, malformed/oversized messages, sink failures and command failures. Original Host execution/status/cleanup causes remain downcastable.