Update copy_vcruntime_binaries for VS2017
This commit is contained in:
parent
886230f64f
commit
8a15231475
2 changed files with 43 additions and 24 deletions
|
@ -14,7 +14,8 @@ if sys.platform == "win32":
|
||||||
from lib.config import BASE_URL, PLATFORM, enable_verbose_mode, \
|
from lib.config import BASE_URL, PLATFORM, enable_verbose_mode, \
|
||||||
get_target_arch, get_zip_name, build_env
|
get_target_arch, get_zip_name, build_env
|
||||||
from lib.util import scoped_cwd, rm_rf, get_electron_version, make_zip, \
|
from lib.util import scoped_cwd, rm_rf, get_electron_version, make_zip, \
|
||||||
execute, electron_gyp, electron_features
|
execute, electron_gyp, electron_features, parse_version
|
||||||
|
from lib.env_util import get_vs_location
|
||||||
|
|
||||||
|
|
||||||
ELECTRON_VERSION = get_electron_version()
|
ELECTRON_VERSION = get_electron_version()
|
||||||
|
@ -146,22 +147,28 @@ def copy_chrome_binary(binary):
|
||||||
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
def copy_vcruntime_binaries():
|
def copy_vcruntime_binaries():
|
||||||
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
|
||||||
r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC", 0,
|
|
||||||
_winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) as key:
|
|
||||||
crt_dir = _winreg.QueryValueEx(key, "ProductDir")[0]
|
|
||||||
|
|
||||||
arch = get_target_arch()
|
arch = get_target_arch()
|
||||||
if arch == "ia32":
|
if arch == "ia32":
|
||||||
arch = "x86"
|
arch = "x86"
|
||||||
|
subkey = r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\\"
|
||||||
|
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey + arch, 0,
|
||||||
|
_winreg.KEY_READ | _winreg.KEY_WOW64_32KEY) as key:
|
||||||
|
runtime_version = _winreg.QueryValueEx(key, "Version")[0][1:]
|
||||||
|
|
||||||
crt_dir += r"redist\{0}\Microsoft.VC140.CRT\\".format(arch)
|
version_parts = parse_version(runtime_version)
|
||||||
|
if len(version_parts) > 3:
|
||||||
|
runtime_version = '.'.join(version_parts[0:3])
|
||||||
|
|
||||||
|
vs_location = get_vs_location('[15.0,16.0)')
|
||||||
|
|
||||||
|
crt_dir = os.path.join(vs_location, 'VC', 'Redist', 'MSVC', runtime_version,
|
||||||
|
arch, 'Microsoft.VC141.CRT')
|
||||||
|
|
||||||
dlls = ["msvcp140.dll", "vcruntime140.dll"]
|
dlls = ["msvcp140.dll", "vcruntime140.dll"]
|
||||||
|
|
||||||
# Note: copyfile is used to remove the read-only flag
|
# Note: copyfile is used to remove the read-only flag
|
||||||
for dll in dlls:
|
for dll in dlls:
|
||||||
shutil.copyfile(crt_dir + dll, os.path.join(DIST_DIR, dll))
|
shutil.copyfile(os.path.join(crt_dir, dll), os.path.join(DIST_DIR, dll))
|
||||||
TARGET_BINARIES_EXT.append(dll)
|
TARGET_BINARIES_EXT.append(dll)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -58,31 +59,42 @@ def get_environment_from_batch_command(env_cmd, initial=None):
|
||||||
proc.communicate()
|
proc.communicate()
|
||||||
return result
|
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):
|
def get_vs_env(vs_version, arch):
|
||||||
"""
|
"""
|
||||||
Returns the env object for VS building environment.
|
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",
|
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)"
|
location = get_vs_location(vs_version)
|
||||||
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.
|
# Launch the process.
|
||||||
vsvarsall = "{0}\\VC\\Auxiliary\\Build\\vcvarsall.bat".format(location)
|
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])
|
||||||
|
|
Loading…
Reference in a new issue