Skip to content

build.d: Get path to vswhere#8596

Merged
dlang-bot merged 3 commits intodlang:masterfrom
JinShil:build_win_vswhere
Aug 27, 2018
Merged

build.d: Get path to vswhere#8596
dlang-bot merged 3 commits intodlang:masterfrom
JinShil:build_win_vswhere

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Aug 22, 2018

This gets the path to vswhere: https://github.com/Microsoft/vswhere

vswhere is a single executable for locating Visual Studio installations and components. It's installed automatically by Visual Studio 2017 v15.2+ to a standard location at %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe. It is also downloadable from the GitHub repository linked above.

I intend to use it at

enum defaultVSVersion = "10.0";
auto cl = environment.get("MSVC_CC",
environment.get("VCINSTALLDIR",
`\Program Files (x86)\Microsoft Visual Studio %s\VC\`.format(defaultVSVersion))
.buildPath("bin", "amd64", "cl.exe"));
and
auto lib = environment.get("MSVC_AR",
environment.get("VCINSTALLDIR", `\Program Files (x86)\Microsoft Visual Studio 10.0\VC\`)
.buildPath("bin", "amd64", "lib.exe"));
I think that code has a typo: notice that the path begins with \Program Files without a drive letter. Anyway, that code doesn't even work on my computer, so I can't get a build. I think vswhere will be a better solution for locating cl.exe and lib.exe.

msvc-dmc and msvc_lib will check the environment variable HOST_VSWHERE and execute it to locate cl.exe and lib.exe. build.d is responsible for setting HOST_VSWHERE, and that's what this PR does.

cc @rainers for your expertise

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8596"

src/build.d Outdated
continue;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better wrap this in a function as we can reuse it for a cross-platform download of the bootstrap compiler too, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I didn't change the existing bootstrap compiler download to avoid introducing issues. I can always do that as a followup.

src/build.d Outdated
// Check if vswhere.exe is in the standard location
auto standardPath = ["cmd", "/C", "echo", `%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe`].execute.output;
standardPath = standardPath.replace(`"`, ""); // Remove quotes surrounding the path
standardPath = standardPath.replace("\r\n", ""); // Remove trailing newline characters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the functions are chained standardPath could be made const.

src/build.d Outdated
return outputPath;

// Could not find or obtain vswhere.exe
throw new Exception("Could not obtain vswhere.exe. Consider downloading it from https://github.com/Microsoft/vswhere and placing it in your PATH");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra space before Consider.

@dlang-bot dlang-bot merged commit 448c5e5 into dlang:master Aug 27, 2018
@JinShil JinShil deleted the build_win_vswhere branch August 27, 2018 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants