Skip to content

Commit d61f172

Browse files
committed
Make kani-verifier the root crate (rust-lang#1085)
* Make kani-verifier the root crate * clean up after cbmc install
1 parent 6767b1f commit d61f172

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+60
-47
lines changed

.github/workflows/kani.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Build Kani
2222
run: |
2323
export RUST_BACKTRACE=1
24-
cargo build
24+
cargo build --workspace
2525
2626
- name: Execute Kani regression
2727
run: ./scripts/kani-regression.sh
@@ -42,7 +42,7 @@ jobs:
4242
- name: Build Kani
4343
run: |
4444
export RUST_BACKTRACE=1
45-
cargo build
45+
cargo build --workspace
4646
4747
- name: Install book runner dependencies
4848
run: ./scripts/setup/install_bookrunner_deps.sh

Cargo.toml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

4+
[package]
5+
name = "kani-verifier"
6+
version = "0.1.0"
7+
edition = "2021"
8+
description = "A bit-precise model checker for Rust."
9+
readme = "README.md"
10+
keywords = ["model-checking", "verification"]
11+
categories = ["development-tools"]
12+
license = "MIT OR Apache-2.0"
13+
repository = "https://github.com/model-checking/kani"
14+
documentation = "https://model-checking.github.io/kani/"
15+
homepage = "https://github.com/model-checking/kani"
16+
17+
[dependencies]
18+
anyhow = "1"
19+
home = "0.5"
20+
21+
[[bin]]
22+
name = "kani"
23+
path = "src/bin/kani.rs"
24+
25+
[[bin]]
26+
name = "cargo-kani"
27+
path = "src/bin/cargo_kani.rs"
28+
29+
[profile.release]
30+
strip = "debuginfo"
31+
32+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33+
# SPDX-License-Identifier: Apache-2.0 OR MIT
34+
435
[workspace]
536
members = [
637
"library/kani",
738
"library/std",
839
"tools/bookrunner",
940
"tools/compiletest",
1041
"tools/make-kani-release",
11-
"src/kani-verifier",
12-
"src/kani-driver",
13-
"src/kani-compiler",
14-
"src/kani_metadata",
42+
"kani-driver",
43+
"kani-compiler",
44+
"kani_metadata",
1545
# `librustdoc` is still needed by bookrunner.
1646
"tools/bookrunner/librustdoc",
1747
]
File renamed without changes.

docs/src/cheat-sheets.md

Lines changed: 2 additions & 2 deletions
File renamed without changes.

src/kani-compiler/Cargo.toml renamed to kani-compiler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010
[dependencies]
1111
atty = "0.2.14"
1212
bitflags = { version = "1.0", optional = true }
13-
cbmc = { path = "../../cprover_bindings", package = "cprover_bindings", optional = true }
13+
cbmc = { path = "../cprover_bindings", package = "cprover_bindings", optional = true }
1414
clap = "2.33.0"
1515
kani_queries = {path = "kani_queries"}
1616
kani_metadata = { path = "../kani_metadata", optional = true }

src/kani-compiler/build.rs renamed to kani-compiler/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ macro_rules! path_str {
1919

2020
/// Build the target library, and setup cargo to rerun them if the source has changed.
2121
fn setup_lib(out_dir: &str, lib_out: &str, lib: &str) {
22-
let kani_lib = vec!["..", "..", "library", lib];
22+
let kani_lib = vec!["..", "library", lib];
2323
println!("cargo:rerun-if-changed={}", path_str!(kani_lib));
2424

2525
let mut kani_lib_toml = kani_lib;
@@ -35,7 +35,14 @@ fn setup_lib(out_dir: &str, lib_out: &str, lib: &str) {
3535
"--target-dir",
3636
&out_dir,
3737
];
38-
Command::new("cargo").env("CARGO_ENCODED_RUSTFLAGS", "--cfg=kani").args(args).status().unwrap();
38+
let result = Command::new("cargo")
39+
.env("CARGO_ENCODED_RUSTFLAGS", "--cfg=kani")
40+
.args(args)
41+
.status()
42+
.unwrap();
43+
if !result.success() {
44+
std::process::exit(1);
45+
}
3946
}
4047

4148
/// Configure the compiler to build kani-compiler binary. We currently support building
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/kani_metadata/Cargo.toml renamed to kani_metadata/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ edition = "2021"
1010

1111
[dependencies]
1212
serde = {version = "1", features = ["derive"]}
13-
cbmc = { path = "../../cprover_bindings", package = "cprover_bindings" }
13+
cbmc = { path = "../cprover_bindings", package = "cprover_bindings" }
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/kani-regression.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ${SCRIPT_DIR}/kani-fmt.sh --check
2929
PYTHONPATH=${SCRIPT_DIR} python3 -m unittest ${SCRIPT_DIR}/test_cbmc_json_parser.py
3030

3131
# Build all packages in the workspace
32-
cargo build
32+
cargo build --workspace
3333

3434
# Unit tests
3535
cargo test -p cprover_bindings

scripts/setup/ubuntu/install_cbmc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ wget -O "$FILE" "$URL"
1515
sudo dpkg -i "$FILE"
1616

1717
cbmc --version
18+
19+
# Clean up on success
20+
rm $FILE
File renamed without changes.
File renamed without changes.

src/kani-verifier/Cargo.toml

Lines changed: 0 additions & 31 deletions
This file was deleted.
File renamed without changes.

tools/compiletest/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ fn common_inputs_stamp() -> Stamp {
353353

354354
// Add source, library and script directories
355355
stamp.add_dir(&rust_src_dir.join("src/"));
356+
stamp.add_dir(&rust_src_dir.join("kani-compiler/"));
357+
stamp.add_dir(&rust_src_dir.join("kani-driver/"));
358+
stamp.add_dir(&rust_src_dir.join("kani_metadata/"));
359+
stamp.add_dir(&rust_src_dir.join("cprover_bindings/"));
356360
stamp.add_dir(&rust_src_dir.join("library/"));
357361
stamp.add_dir(&rust_src_dir.join("scripts/"));
358362

tools/make-kani-release/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fn parse_args() -> Result<String> {
4646
/// Ensures everything is good to go before we begin to build the release bundle.
4747
/// Notably, builds Kani in release mode.
4848
fn prebundle(dir: &Path) -> Result<()> {
49-
if !Path::new("src/kani-compiler").exists() {
50-
bail!("Run from project root directory. Couldn't find 'src/kani-compiler'.");
49+
if !Path::new("kani-compiler").exists() {
50+
bail!("Run from project root directory. Couldn't find 'kani-compiler'.");
5151
}
5252

5353
if dir.exists() {
@@ -62,7 +62,7 @@ fn prebundle(dir: &Path) -> Result<()> {
6262
}
6363

6464
// Before we begin, ensure Kani is built successfully in release mode.
65-
Command::new("cargo").args(&["build", "--release"]).run()?;
65+
Command::new("cargo").args(&["build", "--release", "--workspace"]).run()?;
6666

6767
Ok(())
6868
}

0 commit comments

Comments
 (0)