Update copy_vcruntime_binaries for VS2017

This commit is contained in:
John Kleinschmidt 2018-05-23 11:20:11 -04:00
parent 886230f64f
commit 8a15231475
2 changed files with 43 additions and 24 deletions

View file

@ -3,6 +3,7 @@
from __future__ import print_function
import itertools
import os
import subprocess
import sys
@ -58,31 +59,42 @@ def get_environment_from_batch_command(env_cmd, initial=None):
proc.communicate()
return result
def get_vs_location(vs_version):
"""
Returns the location of the VS building environment.
The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
"""
# vswhere can't handle spaces, like "[15.0, 16.0)" should become "[15.0,16.0)"
vs_version = vs_version.replace(" ", "")
program_files = os.environ.get('ProgramFiles(x86)')
# Find visual studio
proc = subprocess.Popen(
program_files + "\\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()
return location
def get_vs_env(vs_version, arch):
"""
Returns the env object for VS building environment.
The vs_version can be strings like "[15.0,16.0)", meaning 2017, but not the next version.
vs_version is the version of Visual Studio to use. See get_vs_location for
more details.
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.
"amd64_arm", i.e. the args passed to vcvarsall.bat.
"""
# 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()
location = get_vs_location(vs_version)
# Launch the process.
vsvarsall = "{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(location)
return get_environment_from_batch_command([vsvarsall, arch])
return get_environment_from_batch_command([vsvarsall, arch])