Skip to content

Commit 028d4ec

Browse files
authored
Merge pull request #3 from timberio/use-better-fix-for-catalina
Use better fix for macOS Catalina
2 parents 9cb0245 + 0d8777c commit 028d4ec

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

rdkafka-sys/build.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@ macro_rules! println_stderr(
1515
} }
1616
);
1717

18-
fn run_command_or_fail(dir: &str, cmd: &str, args: &[&str]) {
19-
println_stderr!("Running command: \"{} {}\" in dir: {}", cmd, args.join(" "), dir);
18+
fn run_command_or_fail<P>(dir: &str, cmd: P, args: &[&str])
19+
where
20+
P: AsRef<Path>,
21+
{
22+
let cmd = cmd.as_ref();
23+
let cmd = if cmd.components().count() > 1 && cmd.is_relative() {
24+
// If `cmd` is a relative path (and not a bare command that should be
25+
// looked up in PATH), absolutize it relative to `dir`, as otherwise the
26+
// behavior of std::process::Command is undefined.
27+
// https://github.com/rust-lang/rust/issues/37868
28+
PathBuf::from(dir).join(cmd).canonicalize().expect("canonicalization failed")
29+
} else {
30+
PathBuf::from(cmd)
31+
};
32+
println_stderr!("Running command: \"{} {}\" in dir: {}", cmd.display(), args.join(" "), dir);
2033
let ret = Command::new(cmd).current_dir(dir).args(args).status();
2134
match ret.map(|status| (status.success(), status.code())) {
2235
Ok((true, _)) => { return },
@@ -109,7 +122,7 @@ fn build_librdkafka() {
109122
}
110123

111124
println!("Configuring librdkafka");
112-
run_command_or_fail("librdkafka", "sh", &[&["-c", "./configure"], configure_flags.as_slice()].concat());
125+
run_command_or_fail("librdkafka", "./configure", configure_flags.as_slice());
113126

114127
println!("Compiling librdkafka");
115128
make_librdkafka();

0 commit comments

Comments
 (0)