Skip to content

Commit cbbb0ad

Browse files
committed
libbpf-cargo: Remove --quiet option of 'libbpf make' sub-command
Remove the '--quiet' option of the 'libbpf make' sub-command. In my opinion, it makes little sense to invert the logic here and emit output by default, but allow for silencing -- after all, the default output (on success) appears to be nothing more than some "Finished [...]" message. Let's piggy-back on the existing logging initialization instead, emitting this output if the user activated at least log level INFO. Signed-off-by: Daniel Müller <deso@posteo.net>
1 parent c31e5e8 commit cbbb0ad

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

libbpf-cargo/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Unreleased
55
sub-command
66
- Replaced `--debug` option of `libbpf` sub-command with `-v` /
77
`--verbose`
8+
- Removed `--quiet` option of `libbpf make` sub-command
89

910

1011
0.25.0-beta.1

libbpf-cargo/src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ enum Command {
9090
manifest_path: Option<PathBuf>,
9191
#[command(flatten)]
9292
clang_opts: ClangOpts,
93-
#[arg(short, long)]
94-
/// Quiet output
95-
quiet: bool,
9693
/// Arguments to pass to `cargo build`
9794
///
9895
/// Example: cargo libbpf build -- --package mypackage
@@ -146,14 +143,12 @@ fn main() -> Result<()> {
146143
clang_path,
147144
clang_args,
148145
},
149-
quiet,
150146
cargo_build_args,
151147
rustfmt_path,
152148
} => make::make(
153149
manifest_path.as_ref(),
154150
clang_path.as_ref(),
155151
clang_args,
156-
quiet,
157152
cargo_build_args,
158153
rustfmt_path.as_ref(),
159154
),

libbpf-cargo/src/make.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,29 @@ use std::process::Command;
55
use anyhow::bail;
66
use anyhow::Context;
77
use anyhow::Result;
8+
use log::debug;
9+
use log::log_enabled;
10+
use log::Level::Info;
811

912
use crate::build;
1013
use crate::gen;
1114

12-
#[allow(clippy::too_many_arguments)]
1315
pub fn make(
1416
manifest_path: Option<&PathBuf>,
1517
clang: Option<&PathBuf>,
1618
clang_args: Vec<OsString>,
17-
quiet: bool,
1819
cargo_build_args: Vec<String>,
1920
rustfmt_path: Option<&PathBuf>,
2021
) -> Result<()> {
21-
if !quiet {
22-
println!("Compiling BPF objects");
23-
}
22+
debug!("Compiling BPF objects");
2423
build::build(manifest_path, clang, clang_args).context("Failed to compile BPF objects")?;
2524

26-
if !quiet {
27-
println!("Generating skeletons");
28-
}
25+
debug!("Generating skeletons");
2926
gen::gen(manifest_path, None, rustfmt_path).context("Failed to generate skeletons")?;
3027

3128
let mut cmd = Command::new("cargo");
3229
cmd.arg("build");
33-
if quiet {
30+
if !log_enabled!(Info) {
3431
cmd.arg("--quiet");
3532
}
3633
for arg in cargo_build_args {

libbpf-cargo/src/test.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn test_make_basic() {
301301
let _prog_file =
302302
File::create(proj_dir.join("src/bpf/prog.bpf.c")).expect("failed to create prog file");
303303

304-
make(Some(&cargo_toml), None, Vec::new(), true, Vec::new(), None).unwrap();
304+
make(Some(&cargo_toml), None, Vec::new(), Vec::new(), None).unwrap();
305305

306306
// Validate generated object file
307307
validate_bpf_o(proj_dir.as_path().join("target/bpf/prog.bpf.o").as_path());
@@ -333,7 +333,6 @@ fn test_make_workspace() {
333333
Some(&workspace_cargo_toml),
334334
None,
335335
Vec::new(),
336-
true,
337336
Vec::new(),
338337
None,
339338
)
@@ -385,7 +384,7 @@ fn build_rust_project_from_bpf_c_impl(bpf_c: &str, rust: &str, run: bool) {
385384
// Lay down the necessary header files
386385
add_vmlinux_header(&proj_dir);
387386

388-
make(Some(&cargo_toml), None, Vec::new(), true, Vec::new(), None).unwrap();
387+
make(Some(&cargo_toml), None, Vec::new(), Vec::new(), None).unwrap();
389388

390389
let mut cargo = OpenOptions::new()
391390
.append(true)

0 commit comments

Comments
 (0)