-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cc-rs refuses to find MSVC tools via environment when ran as a CustomBuild from msbuild #1189
Comments
diff --git a/src/windows/find_tools.rs b/src/windows/find_tools.rs
index e124c57..d71b872 100644
--- a/src/windows/find_tools.rs
+++ b/src/windows/find_tools.rs
@@ -362,13 +362,16 @@ mod impl_ {
env_getter: &dyn EnvGetter,
) -> Option<Tool> {
// Early return if the environment doesn't contain a VC install.
- env_getter.get_env("VCINSTALLDIR")?;
- let vs_install_dir: PathBuf = env_getter.get_env("VSINSTALLDIR")?.into();
+ if env_getter.get_env("VCINSTALLDIR").is_none() && env_getter.get_env("VisualStudioDir").is_none()
+ {
+ return None;
+ }
// If the vscmd target differs from the requested target then
// attempt to get the tool using the VS install directory.
if is_vscmd_target(target, env_getter) == Some(false) {
// We will only get here with versions 15+.
+ let vs_install_dir: PathBuf = env_getter.get_env("VSINSTALLDIR")?.into();
tool_from_vs15plus_instance(tool, target, &vs_install_dir, env_getter)
} else {
// Fallback to simply using the current environment. works great for me...if yall agree this makes sense I can comment it up and open a PR. |
As I recall the The suggested change looks like it will still achieve that goal, so it looks good to me! |
Gah, turns out that marker env var isn't good enough-- we often run builds by invoking msbuild manually, and those don't set
We're thinking |
We have a bit of rust code that we build from msbuild, and we want it to pick up the exact compiler version that msbuild is using.
msbuild sets the environment so that $PATH contains the path to cl.exe, but cc-rs only considers finding cl.exe from the environment if
VCINSTALLDIR
is in the environment, which somewhat strangely msbuild doesn't set when running custom build tools.The environment that is set while running this tool is
Maybe we could considering allowing environment-based detection if one of these variables is set? Maybe
VisualStudioDir
?The text was updated successfully, but these errors were encountered: