Skip to content

Commit d48c540

Browse files
avoid [&OsStr]::join for rust version compatibility
1 parent cb140c0 commit d48c540

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/lib.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern crate cc;
22

33
use std::env;
4-
use std::ffi::OsStr;
4+
use std::ffi::{OsStr, OsString};
55
use std::fs;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
@@ -330,19 +330,13 @@ impl Build {
330330
// On some platforms (like emscripten on windows), the ar to use may not be a
331331
// single binary, but instead a multi-argument command like `cmd /c emar.bar`.
332332
// We can't convey that through `AR` alone, and so also need to set ARFLAGS.
333-
configure.env(
334-
"ARFLAGS",
335-
ar.get_args().collect::<Vec<_>>().join(OsStr::new(" ")),
336-
);
333+
configure.env("ARFLAGS", join_args(ar.get_args()));
337334
}
338335
let ranlib = cc.get_ranlib();
339336
configure.env("RANLIB", ranlib.get_program());
340337
if ranlib.get_args().count() == 0 {
341338
// Same thing as for AR -- we may need to set RANLIBFLAGS
342-
configure.env(
343-
"RANLIBFLAGS",
344-
ranlib.get_args().collect::<Vec<_>>().join(OsStr::new(" ")),
345-
);
339+
configure.env("RANLIBFLAGS", join_args(ranlib.get_args()));
346340
}
347341

348342
// Make sure we pass extra flags like `-ffunction-sections` and
@@ -566,6 +560,17 @@ fn apply_patches_musl(target: &str, inner: &Path) {
566560
fs::write(path, buf).unwrap();
567561
}
568562

563+
fn join_args<'a>(args: impl Iterator<Item = &'a OsStr>) -> OsString {
564+
let mut output = OsString::new();
565+
for arg in args {
566+
if !output.is_empty() {
567+
output.push(" ");
568+
}
569+
output.push(arg);
570+
}
571+
output
572+
}
573+
569574
fn sanitize_sh(path: &Path) -> String {
570575
if !cfg!(windows) {
571576
return path.to_str().unwrap().to_string();

0 commit comments

Comments
 (0)