diff --git a/tools/build-kani/src/main.rs b/tools/build-kani/src/main.rs index 7000ddb045a7..8f36f4598e88 100644 --- a/tools/build-kani/src/main.rs +++ b/tools/build-kani/src/main.rs @@ -10,7 +10,9 @@ mod parser; mod sysroot; -use crate::sysroot::{build_bin, build_lib, kani_no_core_lib, kani_playback_lib, kani_sysroot_lib}; +use crate::sysroot::{ + build_bin, build_lib, build_tools, kani_no_core_lib, kani_playback_lib, kani_sysroot_lib, +}; use anyhow::{Result, bail}; use clap::Parser; use std::{ffi::OsString, path::Path, process::Command}; @@ -72,6 +74,8 @@ fn prebundle(dir: &Path) -> Result<()> { bail!("Couldn't find the 'cbmc' binary to include in the release bundle."); } + build_tools(&["--release"])?; + // Before we begin, ensure Kani is built successfully in release mode. // And that libraries have been built too. build_lib(&build_bin(&["--release"])?) @@ -86,6 +90,7 @@ fn bundle_kani(dir: &Path) -> Result<()> { let release = Path::new("./target/release"); cp(&release.join("kani-driver"), &bin)?; cp(&release.join("kani-compiler"), &bin)?; + cp(&release.join("kani-cov"), &bin)?; // 2. Kani scripts let scripts = dir.join("scripts"); diff --git a/tools/build-kani/src/sysroot.rs b/tools/build-kani/src/sysroot.rs index edd2a0973a83..29d481e4b9dd 100644 --- a/tools/build-kani/src/sysroot.rs +++ b/tools/build-kani/src/sysroot.rs @@ -278,3 +278,17 @@ pub fn build_bin>(extra_args: &[T]) -> Result { .or(Err(format_err!("Failed to build binaries.")))?; Ok(out_dir) } + +/// Build tool binaries with the extra arguments provided. +/// At present, the only tool we build for the bundle is `kani-cov`, but this +/// could include other tools in the future. +pub fn build_tools>(extra_args: &[T]) -> Result<()> { + let args = ["-p", "kani-cov"]; + Command::new("cargo") + .arg("build") + .args(extra_args) + .args(args) + .run() + .or(Err(format_err!("Failed to build tool binaries.")))?; + Ok(()) +}