Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and include kani-cov in the bundle #3641

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/build-kani/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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"])?)
Expand All @@ -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");
Expand Down
14 changes: 14 additions & 0 deletions tools/build-kani/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,17 @@ pub fn build_bin<T: AsRef<OsStr>>(extra_args: &[T]) -> Result<PathBuf> {
.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<T: AsRef<OsStr>>(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(())
}
Loading