Skip to content

Commit

Permalink
libbpf-cargo: Remove --quiet option of 'libbpf make' sub-command
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
d-e-s-o committed Jan 16, 2025
1 parent 0883681 commit 48bc08e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions libbpf-cargo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Unreleased
sub-command
- Replaced `--debug` option of `libbpf` sub-command with `-v` /
`--verbose`
- Removed `--quiet` option of `libbpf make` sub-command


0.25.0-beta.1
Expand Down
5 changes: 0 additions & 5 deletions libbpf-cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ enum Command {
manifest_path: Option<PathBuf>,
#[command(flatten)]
clang_opts: ClangOpts,
#[arg(short, long)]
/// Quiet output
quiet: bool,
/// Arguments to pass to `cargo build`
///
/// Example: cargo libbpf build -- --package mypackage
Expand Down Expand Up @@ -146,14 +143,12 @@ fn main() -> Result<()> {
clang_path,
clang_args,
},
quiet,
cargo_build_args,
rustfmt_path,
} => make::make(
manifest_path.as_ref(),
clang_path.as_ref(),
clang_args,
quiet,
cargo_build_args,
rustfmt_path.as_ref(),
),
Expand Down
14 changes: 6 additions & 8 deletions libbpf-cargo/src/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use std::process::Command;
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use log::debug;
use log::log_enabled;
use log::Level::Info;

use crate::build;
use crate::gen;
Expand All @@ -14,23 +17,18 @@ pub fn make(
manifest_path: Option<&PathBuf>,
clang: Option<&PathBuf>,
clang_args: Vec<OsString>,
quiet: bool,
cargo_build_args: Vec<String>,
rustfmt_path: Option<&PathBuf>,
) -> Result<()> {
if !quiet {
println!("Compiling BPF objects");
}
debug!("Compiling BPF objects");
build::build(manifest_path, clang, clang_args).context("Failed to compile BPF objects")?;

if !quiet {
println!("Generating skeletons");
}
debug!("Generating skeletons");
gen::gen(manifest_path, None, rustfmt_path).context("Failed to generate skeletons")?;

let mut cmd = Command::new("cargo");
cmd.arg("build");
if quiet {
if !log_enabled!(Info) {
cmd.arg("--quiet");
}
for arg in cargo_build_args {
Expand Down

0 comments on commit 48bc08e

Please sign in to comment.