diff --git a/cmd/soroban-cli/src/commands/contract/build.rs b/cmd/soroban-cli/src/commands/contract/build.rs
index 26da7cf66..bf40b8c94 100644
--- a/cmd/soroban-cli/src/commands/contract/build.rs
+++ b/cmd/soroban-cli/src/commands/contract/build.rs
@@ -13,6 +13,8 @@ use std::{
use cargo_metadata::{Metadata, MetadataCommand, Package};
+use crate::{commands::global, print::Print};
+
/// Build a contract from source
///
/// Builds all crates that are referenced by the cargo manifest (Cargo.toml)
@@ -88,7 +90,9 @@ pub enum Error {
}
impl Cmd {
- pub fn run(&self) -> Result<(), Error> {
+ pub fn run(&self, global_args: &global::Args) -> Result<(), Error> {
+ let print = Print::new(global_args.quiet);
+
let working_dir = env::current_dir().map_err(Error::GettingCurrentDir)?;
let metadata = self.metadata()?;
@@ -135,7 +139,7 @@ impl Cmd {
}
}
- if let Some(rustflags) = make_rustflags_to_remap_absolute_paths()? {
+ if let Some(rustflags) = make_rustflags_to_remap_absolute_paths(&print)? {
cmd.env("CARGO_BUILD_RUSTFLAGS", rustflags);
}
@@ -158,7 +162,7 @@ impl Cmd {
if self.print_commands_only {
println!("{cmd_str}");
} else {
- eprintln!("{cmd_str}");
+ print.infoln(cmd_str);
let status = cmd.status().map_err(Error::CargoCmd)?;
if !status.success() {
return Err(Error::Exit(status));
@@ -296,39 +300,27 @@ impl Cmd {
/// the absolute path replacement. Non-Unicode `CARGO_BUILD_RUSTFLAGS` will result in the
/// existing rustflags being ignored, which is also the behavior of
/// Cargo itself.
-fn make_rustflags_to_remap_absolute_paths() -> Result