|
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,16 +330,15 @@ 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 |
| - // OpenSSL does not support RANLIBFLAGS. Jam the flags in RANLIB. |
340 |
| - let mut args = vec![ranlib.get_program()]; |
341 |
| - args.extend(ranlib.get_args()); |
342 |
| - configure.env("RANLIB", args.join(OsStr::new(" "))); |
| 336 | + if ranlib.get_args().count() != 0 { |
| 337 | + // OpenSSL does not support RANLIBFLAGS. Jam the flags in RANLIB. |
| 338 | + let rancmd = |
| 339 | + IntoIterator::into_iter([ranlib.get_program()]).chain(ranlib.get_args()); |
| 340 | + configure.env("RANLIB", join_args(rancmd)); |
| 341 | + } |
343 | 342 |
|
344 | 343 | // Make sure we pass extra flags like `-ffunction-sections` and
|
345 | 344 | // other things like ARM codegen flags.
|
@@ -562,6 +561,17 @@ fn apply_patches_musl(target: &str, inner: &Path) {
|
562 | 561 | fs::write(path, buf).unwrap();
|
563 | 562 | }
|
564 | 563 |
|
| 564 | +fn join_args<'a>(args: impl Iterator<Item = &'a OsStr>) -> OsString { |
| 565 | + let mut output = OsString::new(); |
| 566 | + for arg in args { |
| 567 | + if !output.is_empty() { |
| 568 | + output.push(" "); |
| 569 | + } |
| 570 | + output.push(arg); |
| 571 | + } |
| 572 | + output |
| 573 | +} |
| 574 | + |
565 | 575 | fn sanitize_sh(path: &Path) -> String {
|
566 | 576 | if !cfg!(windows) {
|
567 | 577 | return path.to_str().unwrap().to_string();
|
|
0 commit comments