aboutsummaryrefslogtreecommitdiff
path: root/gcc/src/windows_registry.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2017-09-16 08:37:31 -0700
committerDaniel Mueller <deso@posteo.net>2017-09-16 08:37:31 -0700
commitab3c2a935b1ba655de2f3fec35da2c14b69966dc (patch)
treecb546a86fe9648b2afcd78776d7e035a05c04b76 /gcc/src/windows_registry.rs
parentea4ea0e5fced2780c569b2e420e56f47f62adca8 (diff)
downloadnitrocli-ab3c2a935b1ba655de2f3fec35da2c14b69966dc.tar.gz
nitrocli-ab3c2a935b1ba655de2f3fec35da2c14b69966dc.tar.bz2
Update gcc crate to 0.3.54
Import subrepo gcc/:gcc at dc329205d54b53a45ab66368aed265b68fe7f261
Diffstat (limited to 'gcc/src/windows_registry.rs')
-rw-r--r--gcc/src/windows_registry.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/src/windows_registry.rs b/gcc/src/windows_registry.rs
index d05fc1d..9099e0f 100644
--- a/gcc/src/windows_registry.rs
+++ b/gcc/src/windows_registry.rs
@@ -87,6 +87,7 @@ pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
}
/// A version of Visual Studio
+#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum VsVers {
/// Visual Studio 12 (2013)
Vs12,
@@ -99,6 +100,7 @@ pub enum VsVers {
/// handle an enumeration of `VsVers` instances should always have a default
/// case meaning that it's a VS version they don't understand.
#[doc(hidden)]
+ #[allow(bad_style)]
__Nonexhaustive_do_not_match_this_or_your_code_will_break,
}
@@ -195,6 +197,10 @@ mod impl_ {
// In MSVC 15 (2017) MS once again changed the scheme for locating
// the tooling. Now we must go through some COM interfaces, which
// is super fun for Rust.
+ //
+ // Note that much of this logic can be found [online] wrt paths, COM, etc.
+ //
+ // [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/
pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
otry!(com::initialize().ok());
@@ -213,12 +219,12 @@ mod impl_ {
fn tool_from_vs15_instance(tool: &str, target: &str,
instance: &SetupInstance) -> Option<Tool> {
- let (bin_path, lib_path, include_path) = otry!(vs15_vc_paths(target, instance));
+ let (bin_path, host_dylib_path, lib_path, include_path) = otry!(vs15_vc_paths(target, instance));
let tool_path = bin_path.join(tool);
if !tool_path.exists() { return None };
let mut tool = MsvcTool::new(tool_path);
- tool.path.push(bin_path.clone());
+ tool.path.push(host_dylib_path);
tool.libs.push(lib_path);
tool.include.push(include_path);
@@ -232,7 +238,7 @@ mod impl_ {
Some(tool.into_tool())
}
- fn vs15_vc_paths(target: &str, instance: &SetupInstance) -> Option<(PathBuf, PathBuf, PathBuf)> {
+ fn vs15_vc_paths(target: &str, instance: &SetupInstance) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> {
let instance_path: PathBuf = otry!(instance.installation_path().ok()).into();
let version_path = instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt");
let mut version_file = otry!(File::open(version_path).ok());
@@ -245,11 +251,18 @@ mod impl_ {
_ => return None,
};
let target = otry!(lib_subdir(target));
+ // The directory layout here is MSVC/bin/Host$host/$target/
let path = instance_path.join(r"VC\Tools\MSVC").join(version);
+ // This is the path to the toolchain for a particular target, running
+ // on a given host
let bin_path = path.join("bin").join(&format!("Host{}", host)).join(&target);
+ // But! we also need PATH to contain the target directory for the host
+ // architecture, because it contains dlls like mspdb140.dll compiled for
+ // the host architecture.
+ let host_dylib_path = path.join("bin").join(&format!("Host{}", host)).join(&host.to_lowercase());
let lib_path = path.join("lib").join(&target);
let include_path = path.join("include");
- Some((bin_path, lib_path, include_path))
+ Some((bin_path, host_dylib_path, lib_path, include_path))
}
fn atl_paths(target: &str, path: &Path) -> Option<(PathBuf, PathBuf)> {