|
@@ -63,9 +63,26 @@ def get_vs_env(vs_version, arch):
|
|
|
"""
|
|
|
Returns the env object for VS building environment.
|
|
|
|
|
|
- The vs_version can be strings like "2017", the arch has to
|
|
|
- be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm", "amd64_x86",
|
|
|
+ The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
|
|
|
+ The arch has to be one of "x86", "amd64", "arm", "x86_amd64", "x86_arm", "amd64_x86",
|
|
|
"amd64_arm", e.g. the args passed to vcvarsall.bat.
|
|
|
"""
|
|
|
- vsvarsall = "C:\\Program Files (x86)\\Microsoft Visual Studio\\{0}\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(vs_version)
|
|
|
- return get_environment_from_batch_command([vsvarsall, arch])
|
|
|
+
|
|
|
+ # vswhere can't handle spaces, like "[15.0, 16.0)" should become "[15.0,16.0)"
|
|
|
+ vs_version = vs_version.replace(" ", "")
|
|
|
+
|
|
|
+ # Find visual studio
|
|
|
+ proc = subprocess.Popen(
|
|
|
+ "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe "
|
|
|
+ "-property installationPath "
|
|
|
+ "-requires Microsoft.VisualStudio.Component.VC.CoreIde "
|
|
|
+ "-format value "
|
|
|
+ "-version {0}".format(vs_version),
|
|
|
+ stdout=subprocess.PIPE)
|
|
|
+
|
|
|
+ location = proc.stdout.readline().rstrip()
|
|
|
+
|
|
|
+ # Launch the process.
|
|
|
+ vsvarsall = "{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(location)
|
|
|
+
|
|
|
+ return get_environment_from_batch_command([vsvarsall, arch])
|