pub fn link_exe_cmd(sess: &Session) -> (Command, Option<PathBuf>) {
        let arch = &sess.target.target.arch;
        env::var_os("VCINSTALLDIR").and_then(|_| {
            debug!("Detected that vcvars was already run.");
            let path = otry!(env::var_os("PATH"));
            // Mingw has its own link which is not the link we want so we
            // look for `cl.exe` too as a precaution.
            env::split_paths(&path).find(|path| {
                path.join("cl.exe").is_file()
                    && path.join("link.exe").is_file()
            }).map(|path| {
                (Command::new(path.join("link.exe")), None)
            })
        }).or_else(|| {
            None.or_else(|| {
                find_msvc_latest(arch, "15.0")
            }).or_else(|| {
                find_msvc_latest(arch, "14.0")
            }).or_else(|| {
                find_msvc_12(arch)
            }).or_else(|| {
                find_msvc_11(arch)
            }).map(|(cmd, path)| (cmd, Some(path)))
        }).unwrap_or_else(|| {
            debug!("Failed to locate linker.");
            (Command::new("link.exe"), None)
        })
    }
// First we need to figure out whether the environment is already correctly
// configured by vcvars. We do this by looking at the environment variable
// `VCINSTALLDIR` which is always set by vcvars, and unlikely to be set
// otherwise. If it is defined, then we find `link.exe` in `PATH and trust
// that everything else is configured correctly.
//
// If `VCINSTALLDIR` wasn't defined (or we couldn't find the linker where
// it claimed it should be), then we resort to finding everything
// ourselves. First we find where the latest version of MSVC is installed
// and what version it is. Then based on the version we find the
// appropriate SDKs.
//
// If despite our best efforts we are still unable to find MSVC then we
// just blindly call `link.exe` and hope for the best.
//
// This code only supports VC 11 through 15. For versions older than that
// the user will need to manually execute the appropriate vcvars bat file
// and it should hopefully work.
//
// The second member of the tuple we return is the directory for the host
// linker toolchain, which is necessary when using the cross linkers.
First we need to figure out whether the environment is already correctly
configured by vcvars. We do this by looking at the environment variable
`VCINSTALLDIR` which is always set by vcvars, and unlikely to be set
otherwise. If it is defined, then we find `link.exe` in `PATH and trust
that everything else is configured correctly.

If `VCINSTALLDIR` wasn't defined (or we couldn't find the linker where
it claimed it should be), then we resort to finding everything
ourselves. First we find where the latest version of MSVC is installed
and what version it is. Then based on the version we find the
appropriate SDKs.

If despite our best efforts we are still unable to find MSVC then we
just blindly call `link.exe` and hope for the best.

This code only supports VC 11 through 15. For versions older than that
the user will need to manually execute the appropriate vcvars bat file
and it should hopefully work.

The second member of the tuple we return is the directory for the host
linker toolchain, which is necessary when using the cross linkers.
First we need to figure out whether the environment is already correctly configured by vcvars . We do this by looking at the environment variable ` VCINSTALLDIR ` which is always set by vcvars and unlikely to be set otherwise . If it is defined then we find ` link . exe ` in ` PATH and trust that everything else is configured correctly . If ` VCINSTALLDIR ` wasn ' t defined ( or we couldn ' t find the linker where it claimed it should be ) then we resort to finding everything ourselves . First we find where the latest version of MSVC is installed and what version it is . Then based on the version we find the appropriate SDKs . If despite our best efforts we are still unable to find MSVC then we just blindly call ` link . exe ` and hope for the best . This code only supports VC 11 through 15 . For versions older than that the user will need to manually execute the appropriate vcvars bat file and it should hopefully work . The second member of the tuple we return is the directory for the host linker toolchain which is necessary when using the cross linkers .
pub fn link_exe_cmd(sess: &Session) -> (Command, Option<PathBuf>) {
        let arch = &sess.target.target.arch;
        env::var_os("VCINSTALLDIR").and_then(|_| {
            debug!("Detected that vcvars was already run.");
            let path = otry!(env::var_os("PATH"));
            // Mingw has its own link which is not the link we want so we
            // look for `cl.exe` too as a precaution.
            env::split_paths(&path).find(|path| {
                path.join("cl.exe").is_file()
                    && path.join("link.exe").is_file()
            }).map(|path| {
                (Command::new(path.join("link.exe")), None)
            })
        }).or_else(|| {
            None.or_else(|| {
                find_msvc_latest(arch, "15.0")
            }).or_else(|| {
                find_msvc_latest(arch, "14.0")
            }).or_else(|| {
                find_msvc_12(arch)
            }).or_else(|| {
                find_msvc_11(arch)
            }).map(|(cmd, path)| (cmd, Some(path)))
        }).unwrap_or_else(|| {
            debug!("Failed to locate linker.");
            (Command::new("link.exe"), None)
        })
    }
pub fn link_exe_cmd ( sess : & Session ) -> ( Command , Option < PathBuf > ) { let arch = & sess . target . target . arch ; env :: var_os ( " " ) . and_then ( | _ | { debug ! ( " " ) ; let path = otry ! ( env var_os ( " " ) ) ; // Mingw has its own link which is not the link we want so we // look for `cl.exe` too as a precaution. env :: split_paths ( & path ) . find ( | path | { path . join ( " " ) . is_file ( ) && path . join ( " " ) . is_file ( ) } ) . map ( | path | { ( Command :: new ( path . join ( " " ) ) , None ) } ) } ) . or_else ( | | { None . or_else ( | | { find_msvc_latest ( arch , " " ) } ) . or_else ( | | { find_msvc_latest ( arch , " " ) } ) . or_else ( | | { find_msvc_12 ( arch ) } ) . or_else ( | | { find_msvc_11 ( arch ) } ) . map ( | ( cmd , path ) | ( cmd , Some ( path ) ) ) } ) . unwrap_or_else ( | | { debug ! ( " " ) ; ( Command :: new ( " " ) , None ) } ) }
First we need to figure out whether the environment is already correctly
configured by vcvars.
First we need to figure out whether the environment is already correctly configured by vcvars .
sess
&Session
sess
&Session