Skip to content

Commit

Permalink
Drop unnecessary (always true) verbose argument from task::run()
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jan 3, 2025
1 parent defd698 commit beec195
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion xbuild/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl CargoBuild {
self.cc_triple_env("CFLAGS", &self.c_flags.clone());
// These strings already end with a space if they're non-empty:
self.cc_triple_env("CXXFLAGS", &format!("{}{}", self.c_flags, self.cxx_flags));
task::run(&mut self.cmd, true)?;
task::run(&mut self.cmd)?;
Ok(())
}
}
Expand Down
5 changes: 1 addition & 4 deletions xbuild/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ impl<'a> DownloadManager<'a> {
}

fn rustup_target(&self, target: &str) -> Result<()> {
task::run(
Command::new("rustup").arg("target").arg("add").arg(target),
true,
)
task::run(Command::new("rustup").arg("target").arg("add").arg(target))
}

pub fn prefetch(&self) -> Result<()> {
Expand Down
1 change: 0 additions & 1 deletion xbuild/src/gradle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ pub fn build(env: &BuildEnv, out: &Path) -> Result<()> {
Format::Apk => "assemble",
_ => unreachable!(),
}),
true,
)?;
let output = gradle
.join("app")
Expand Down
25 changes: 6 additions & 19 deletions xbuild/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl TaskRunner {
}
}

pub fn run(command: &mut Command, verbose: bool) -> Result<()> {
pub fn run(command: &mut Command) -> Result<()> {
fn format_error(command: &Command, status: Option<i32>) -> String {
let status = if let Some(code) = status {
format!(" exited with {}", code)
Expand All @@ -75,24 +75,11 @@ pub fn run(command: &mut Command, verbose: bool) -> Result<()> {
};
format!("{} `{:?}`{}", style("[ERROR]").red(), command, status)
}
if !verbose {
let output = command
.output()
.with_context(|| format_error(command, None))?;
if !output.status.success() {
let stdout = std::str::from_utf8(&output.stdout)?;
print!("{}", stdout);
let stderr = std::str::from_utf8(&output.stderr)?;
print!("{}", stderr);
anyhow::bail!("{}", format_error(command, output.status.code()));
}
} else {
let status = command
.status()
.with_context(|| format_error(command, None))?;
if !status.success() {
anyhow::bail!("{}", format_error(command, status.code()));
}
let status = command
.status()
.with_context(|| format_error(command, None))?;
if !status.success() {
anyhow::bail!("{}", format_error(command, status.code()));
}
Ok(())
}

0 comments on commit beec195

Please sign in to comment.