From 5a05e13d5c32ceb011b929c5ff43b538421f3e12 Mon Sep 17 00:00:00 2001 From: Jascha Date: Thu, 1 Dec 2016 11:10:18 +0100 Subject: [PATCH 1/3] Add ATL/MFC detection for MSVC --- src/windows_registry.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/windows_registry.rs b/src/windows_registry.rs index b2c719d..e16a33f 100644 --- a/src/windows_registry.rs +++ b/src/windows_registry.rs @@ -211,6 +211,11 @@ pub fn find_tool(target: &str, tool: &str) -> Option { let sub = otry!(vc_lib_subdir(target)); tool.libs.push(path.join("lib").join(sub)); tool.include.push(path.join("include")); + let atlmfc_path = path.join("atlmfc"); + if atlmfc_path.exists() { + tool.libs.push(atlmfc_path.join("lib").join(sub)); + tool.include.push(atlmfc_path.join("include")); + } Some(tool) }).next() } From bda11f20c19c2c830001fb98c934e850f4d9854b Mon Sep 17 00:00:00 2001 From: Jascha Date: Thu, 1 Dec 2016 19:48:55 +0100 Subject: [PATCH 2/3] Add ATL/MFC workaround for linker --- src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d70de88..923ff95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -353,6 +353,24 @@ impl Config { self.compile_objects(&src_dst); self.assemble(lib_name, &dst.join(output), &objects); + if self.get_target().contains("msvc") { + let compiler = self.get_base_compiler(); + let atlmfc_lib = compiler.env().iter().find(|&&(ref var, _)| { + var == OsStr::new("LIB") + }).and_then(|&(_, ref lib_paths)| { + env::split_paths(lib_paths).find(|path| { + let sub = Path::new("atlmfc/lib"); + path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub)) + }) + }); + + if let Some(atlmfc_lib) = atlmfc_lib { + self.print("cargo:rustc-link-lib=static=atls"); + self.print(&format!("cargo:rustc-link-search=native={}", + atlmfc_lib.display())); + } + } + self.print(&format!("cargo:rustc-link-lib=static={}", &output[3..output.len() - 2])); self.print(&format!("cargo:rustc-link-search=native={}", dst.display())); From 3df9fcf938595844746de7076970319aea1efefc Mon Sep 17 00:00:00 2001 From: Jascha Date: Thu, 1 Dec 2016 20:06:30 +0100 Subject: [PATCH 3/3] Revert emitting atls.lib cargo metadata --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 923ff95..7c258c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -365,7 +365,6 @@ impl Config { }); if let Some(atlmfc_lib) = atlmfc_lib { - self.print("cargo:rustc-link-lib=static=atls"); self.print(&format!("cargo:rustc-link-search=native={}", atlmfc_lib.display())); }