|
1 | 1 | extern crate cc;
|
2 | 2 |
|
3 | 3 | use std::env;
|
4 |
| -use std::ffi::OsStr; |
| 4 | +use std::ffi::{OsStr, OsString}; |
5 | 5 | use std::fs;
|
6 | 6 | use std::path::{Path, PathBuf};
|
7 | 7 | use std::process::Command;
|
@@ -330,19 +330,13 @@ impl Build {
|
330 | 330 | // On some platforms (like emscripten on windows), the ar to use may not be a
|
331 | 331 | // single binary, but instead a multi-argument command like `cmd /c emar.bar`.
|
332 | 332 | // 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())); |
337 | 334 | }
|
338 | 335 | let ranlib = cc.get_ranlib();
|
339 | 336 | configure.env("RANLIB", ranlib.get_program());
|
340 | 337 | if ranlib.get_args().count() == 0 {
|
341 | 338 | // 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())); |
346 | 340 | }
|
347 | 341 |
|
348 | 342 | // Make sure we pass extra flags like `-ffunction-sections` and
|
@@ -566,6 +560,17 @@ fn apply_patches_musl(target: &str, inner: &Path) {
|
566 | 560 | fs::write(path, buf).unwrap();
|
567 | 561 | }
|
568 | 562 |
|
| 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 | + |
569 | 574 | fn sanitize_sh(path: &Path) -> String {
|
570 | 575 | if !cfg!(windows) {
|
571 | 576 | return path.to_str().unwrap().to_string();
|
|
0 commit comments