From 6783f86fcceb2dd7698783a237368c8ca7ff6f1c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 2 Jun 2015 23:31:14 -0700 Subject: [PATCH] Create foo.lib files for MSVC --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ba04e67..bafdc1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -188,6 +188,7 @@ impl Config { pub fn compile(&self, output: &str) { assert!(output.starts_with("lib")); assert!(output.ends_with(".a")); + let lib_name = &output[3..output.len() - 2]; let target = getenv_unwrap("TARGET"); let src = PathBuf::from(getenv_unwrap("CARGO_MANIFEST_DIR")); @@ -215,6 +216,13 @@ impl Config { out.push(dst.join(output)); run(Command::new("lib").arg(out).args(&objects).args(&self.objects), "lib"); + + // 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 + // exist for now. + let lib_dst = dst.join(format!("{}.lib", lib_name)); + let _ = fs::remove_file(&lib_dst); + fs::hard_link(dst.join(output), lib_dst).unwrap(); } else { run(Command::new(&ar(&target)).arg("crus") .arg(&dst.join(output))