Fix clippy
This commit is contained in:
93
src/app.rs
93
src/app.rs
@@ -186,7 +186,7 @@ impl App {
|
||||
fn add_package(package: &str) -> std::io::Result<()> {
|
||||
let status = Command::new("pkg-config")
|
||||
.arg("--exists")
|
||||
.arg(&package)
|
||||
.arg(package)
|
||||
.status()
|
||||
.map_err(|_| {
|
||||
std::io::Error::new(
|
||||
@@ -276,7 +276,7 @@ fn gen_compile_commands(mode: &Option<String>) -> std::io::Result<()> {
|
||||
.collect();
|
||||
|
||||
let json = serde_json::to_string_pretty(&entries)
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{e}")))?;
|
||||
.map_err(|e| std::io::Error::other(format!("{e}")))?;
|
||||
|
||||
std::fs::write("compile_commands.json", json)?;
|
||||
|
||||
@@ -381,45 +381,43 @@ fn build(mode: &Option<String>, force_recompile: bool) -> std::io::Result<()> {
|
||||
let mut extra_compile_flags: Vec<String> = Vec::new();
|
||||
let mut extra_link_flags: Vec<String> = Vec::new();
|
||||
|
||||
if let Some(deps) = &conf.dependencies {
|
||||
if !deps.is_empty() {
|
||||
let cflags = Command::new("pkg-config")
|
||||
.arg("--cflags")
|
||||
.args(deps)
|
||||
.output()
|
||||
.map_err(|_| {
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found")
|
||||
})?;
|
||||
if !cflags.status.success() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"pkg-config --cflags failed - is the package installed?",
|
||||
));
|
||||
}
|
||||
|
||||
let libs = Command::new("pkg-config")
|
||||
.arg("--libs")
|
||||
.args(deps)
|
||||
.output()
|
||||
.map_err(|_| {
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found")
|
||||
})?;
|
||||
if !libs.status.success() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"pkg-config --libs failed - is the pacakge installed?",
|
||||
));
|
||||
}
|
||||
|
||||
extra_compile_flags = String::from_utf8_lossy(&cflags.stdout)
|
||||
.split_whitespace()
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
extra_link_flags = String::from_utf8_lossy(&libs.stdout)
|
||||
.split_whitespace()
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
if let Some(deps) = &conf.dependencies
|
||||
&& !deps.is_empty()
|
||||
{
|
||||
let cflags = Command::new("pkg-config")
|
||||
.arg("--cflags")
|
||||
.args(deps)
|
||||
.output()
|
||||
.map_err(|_| {
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found")
|
||||
})?;
|
||||
if !cflags.status.success() {
|
||||
return Err(std::io::Error::other(
|
||||
"pkg-config --cflags failed - is the package installed?",
|
||||
));
|
||||
}
|
||||
|
||||
let libs = Command::new("pkg-config")
|
||||
.arg("--libs")
|
||||
.args(deps)
|
||||
.output()
|
||||
.map_err(|_| {
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found")
|
||||
})?;
|
||||
if !libs.status.success() {
|
||||
return Err(std::io::Error::other(
|
||||
"pkg-config --libs failed - is the pacakge installed?",
|
||||
));
|
||||
}
|
||||
|
||||
extra_compile_flags = String::from_utf8_lossy(&cflags.stdout)
|
||||
.split_whitespace()
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
extra_link_flags = String::from_utf8_lossy(&libs.stdout)
|
||||
.split_whitespace()
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
}
|
||||
|
||||
let source_files: Vec<PathBuf> = glob("src/*.c")
|
||||
@@ -455,10 +453,10 @@ fn build(mode: &Option<String>, force_recompile: bool) -> std::io::Result<()> {
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("failed to compile {}", src.display()),
|
||||
));
|
||||
return Err(std::io::Error::other(format!(
|
||||
"failed to compile {}",
|
||||
src.display()
|
||||
)));
|
||||
}
|
||||
|
||||
std::fs::write(&hash_path, &hash)?;
|
||||
@@ -493,15 +491,12 @@ fn build(mode: &Option<String>, force_recompile: bool) -> std::io::Result<()> {
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"linking failed",
|
||||
));
|
||||
return Err(std::io::Error::other("linking failed"));
|
||||
}
|
||||
|
||||
let stop = start.elapsed();
|
||||
|
||||
gen_compile_commands(&mode)?;
|
||||
gen_compile_commands(mode)?;
|
||||
|
||||
println!(
|
||||
" {} '{}' profile for project '{}' in {:.2}s",
|
||||
|
||||
Reference in New Issue
Block a user