Skip to content

Commit

Permalink
Merge branch fede1024#161
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
  • Loading branch information
a-rodin1 committed Oct 22, 2019
2 parents 0dd9a21 + 07980ed commit 0d8777c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions rdkafka-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,21 @@ macro_rules! println_stderr(
} }
);

fn run_command_or_fail(dir: &str, cmd: &str, args: &[&str]) {
println_stderr!("Running command: \"{} {}\" in dir: {}", cmd, args.join(" "), dir);
fn run_command_or_fail<P>(dir: &str, cmd: P, args: &[&str])
where
P: AsRef<Path>,
{
let cmd = cmd.as_ref();
let cmd = if cmd.components().count() > 1 && cmd.is_relative() {
// If `cmd` is a relative path (and not a bare command that should be
// looked up in PATH), absolutize it relative to `dir`, as otherwise the
// behavior of std::process::Command is undefined.
// https://github.com/rust-lang/rust/issues/37868
PathBuf::from(dir).join(cmd).canonicalize().expect("canonicalization failed")
} else {
PathBuf::from(cmd)
};
println_stderr!("Running command: \"{} {}\" in dir: {}", cmd.display(), args.join(" "), dir);
let ret = Command::new(cmd).current_dir(dir).args(args).status();
match ret.map(|status| (status.success(), status.code())) {
Ok((true, _)) => { return },
Expand Down

0 comments on commit 0d8777c

Please sign in to comment.