Skip to content
Snippets Groups Projects
Commit 21fe254a authored by Per Lindgren's avatar Per Lindgren
Browse files

move to clap 4, wip3

parent 436f05fe
No related branches found
No related tags found
No related merge requests found
......@@ -15,3 +15,6 @@ either = "1.6.1"
clap = { version = "4.0.6", features = ["derive", "color"] }
rustc_version = "0.4.0"
anyhow = "1.0.65"
# cargo_metadata = "0.15.0"
regex = "1.6.0"
# colored = "2.0.0"
pub mod cargo_out;
pub mod cli;
use anyhow::Error;
use anyhow::{anyhow, Error};
// use std::error::Error;
use cargo_klee::cli::Cli;
use clap::Parser;
use std::str::Split;
// extern crate libc;
use std::{
env, fs,
path::PathBuf,
process::{self, Command},
process::{self, Command, ExitStatus, Stdio},
time::SystemTime,
};
......@@ -67,12 +68,9 @@ fn main() -> Result<(), Error> {
let mut cargo = Command::new("cargo");
cargo
// compile using rustc
.arg("rustc");
.arg("rustc")
// verbose output for debugging purposes
if args.verbose {
cargo.arg("-v");
}
.arg("-v");
// set features, always including `klee-analysis`
if args.all_features {
......@@ -128,13 +126,36 @@ fn main() -> Result<(), Error> {
eprintln!("\n{:?}\n", cargo);
}
// execute the command and unwrap the result into status
let status = cargo.status()?;
// // execute the command and unwrap the result into status
// let status = cargo.status()?;
// if !status.success() {
// // TODO! correctly handle exit status
// panic!("{:?}", status);
// // return Err(status.code().unwrap_or(1).into());
// }
println!("project name {:?}", project.name());
println!("project target {:?}", project.target());
println!("project toml {:?}", project.toml());
println!("project target_dir {:?}", project.target_dir());
let output = cargo.stdout(Stdio::piped()).output()?;
let stderr = String::from_utf8(output.stderr)?;
// We enforce color, assumes standard utf-8 coding for Green
let comp = "\u{1b}[32m Compiling";
let s: Split<&str> = stderr.split(comp);
let last = s.last().unwrap();
if args.verbose {
println!("{}", stderr);
} else {
println!("{}{}", comp, last);
}
if !status.success() {
// TODO! correctly handle exit status
panic!("{:?}", status);
// return Err(status.code().unwrap_or(1).into());
if !output.status.success() {
return Err(anyhow!("Compilation failed, exiting cargo-klee"));
}
Ok(())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment