Browse Source

Merge pull request #387 from froydnj/lib-alternatives-on-windows

enable using AR to modify archiving behavior on windows
urgh
Alex Crichton 6 years ago
committed by GitHub
parent
commit
ae5b988cb6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      src/lib.rs

24
src/lib.rs

@ -1487,12 +1487,7 @@ impl Build {
let objects: Vec<_> = objs.iter().map(|obj| obj.dst.clone()).collect(); let objects: Vec<_> = objs.iter().map(|obj| obj.dst.clone()).collect();
let target = self.get_target()?; let target = self.get_target()?;
if target.contains("msvc") { if target.contains("msvc") {
let mut cmd = match self.archiver { let (mut cmd, program) = self.get_ar()?;
Some(ref s) => self.cmd(s),
None => windows_registry::find(&target, "lib.exe")
.unwrap_or_else(|| self.cmd("lib.exe")),
};
let mut out = OsString::from("/OUT:"); let mut out = OsString::from("/OUT:");
out.push(dst); out.push(dst);
cmd.arg(out).arg("/nologo"); cmd.arg(out).arg("/nologo");
@ -1537,7 +1532,7 @@ impl Build {
} else { } else {
cmd.args(&objects).args(&self.objects); cmd.args(&objects).args(&self.objects);
} }
run(&mut cmd, "lib.exe")?; run(&mut cmd, &program)?;
// The Rust compiler will look for libfoo.a and foo.lib, but the // The Rust compiler will look for libfoo.a and foo.lib, but the
// MSVC linker will also be passed foo.lib, so be sure that both // MSVC linker will also be passed foo.lib, so be sure that both
@ -1979,9 +1974,10 @@ impl Build {
if let Ok(p) = self.get_var("AR") { if let Ok(p) = self.get_var("AR") {
return Ok((self.cmd(&p), p)); return Ok((self.cmd(&p), p));
} }
let program = if self.get_target()?.contains("android") { let target = self.get_target()?;
format!("{}-ar", self.get_target()?.replace("armv7", "arm")) let program = if target.contains("android") {
} else if self.get_target()?.contains("emscripten") { format!("{}-ar", target.replace("armv7", "arm"))
} else if target.contains("emscripten") {
// Windows use bat files so we have to be a bit more specific // Windows use bat files so we have to be a bit more specific
if cfg!(windows) { if cfg!(windows) {
let mut cmd = self.cmd("cmd"); let mut cmd = self.cmd("cmd");
@ -1990,6 +1986,14 @@ impl Build {
} }
"emar".to_string() "emar".to_string()
} else if target.contains("msvc") {
match windows_registry::find_tool(&target, "lib.exe") {
Some(t) => match t.path().to_str() {
Some(ref p) => p.to_string(),
None => "lib.exe".to_string(),
},
None => "lib.exe".to_string(),
}
} else { } else {
"ar".to_string() "ar".to_string()
}; };

Loading…
Cancel
Save