Skip to content

Commit f436463

Browse files
d-e-s-odanielocfb
authored andcommitted
Factor out run_impl() function in build.rs
Factor out the run_impl() function in our build script, which acts as a generalization of the existing run() with a configurable stdout output. Signed-off-by: Daniel Müller <[email protected]>
1 parent 8ae390f commit f436463

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

libbpf-rs/build.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,15 @@ where
6666
}
6767

6868

69-
/// Run a command with the provided arguments.
70-
fn run<C, A, S>(command: C, args: A) -> Result<()>
69+
fn run_impl<C, A, S>(command: C, args: A, stdout: Stdio) -> Result<Output>
7170
where
7271
C: AsRef<OsStr>,
7372
A: IntoIterator<Item = S> + Clone,
7473
S: AsRef<OsStr>,
7574
{
7675
let output = Command::new(command.as_ref())
7776
.stdin(Stdio::null())
78-
.stdout(Stdio::null())
77+
.stdout(stdout)
7978
.env_clear()
8079
.envs(env::vars().filter(|(k, _)| k == "PATH"))
8180
.args(args.clone())
@@ -91,6 +90,17 @@ where
9190
})?;
9291

9392
let () = evaluate(&output, command, args)?;
93+
Ok(output)
94+
}
95+
96+
/// Run a command with the provided arguments.
97+
fn run<C, A, S>(command: C, args: A) -> Result<()>
98+
where
99+
C: AsRef<OsStr>,
100+
A: IntoIterator<Item = S> + Clone,
101+
S: AsRef<OsStr>,
102+
{
103+
let _output = run_impl(command, args, Stdio::null())?;
94104
Ok(())
95105
}
96106

0 commit comments

Comments
 (0)