summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <dmoody256@gmail.com>2019-01-10 00:13:39 -0600
committerDaniel <dmoody256@gmail.com>2019-01-10 00:13:39 -0600
commitd3cc1e0224711b55acbcaab6abb329a5e59e766e (patch)
treedc9d64b83fe6227771557d99878aa3519a15940f
parent360065d5b2bfa600c7a3ed20fea6dc494bd92a6d (diff)
parent070d31019e7ed0b57c9670e95db91afcc3932e40 (diff)
downloadscons-git-d3cc1e0224711b55acbcaab6abb329a5e59e766e.tar.gz
merge mats vc tool updates
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py114
3 files changed, 76 insertions, 44 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 231badb1c..b37c8e4dd 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -18,7 +18,9 @@ RELEASE 3.0.3 - Mon, 07 Jan 2019 20:05:22 -0400
From Mats Wichmann:
- Update doc examples to work with Python 3.5+: map() now returns an iterable instead of a list.
-
+ - Improve finding of Microsoft compiler: add a 'products' wildcard
+ in case 2017 Build Tools only is installed as it is considered a separate
+ product from the default Visual Studio
RELEASE 3.0.2 - Mon, 31 Dec 2018 16:00:12 -0700
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index b60cd5b41..a0140c6ec 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -46,7 +46,7 @@ elif LOGFILE:
debug = lambda message: open(LOGFILE, 'a').write(message + '\n')
else:
logging.basicConfig(filename=LOGFILE, level=logging.DEBUG)
- debug = logging.debug
+ debug = logging.getLogger(name=__name__).debug
else:
debug = lambda x: None
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 7a481a69e..9c194db36 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -80,15 +80,17 @@ _ARCH_TO_CANONICAL = {
"i486" : "x86",
"i586" : "x86",
"i686" : "x86",
- "ia64" : "ia64",
- "itanium" : "ia64",
+ "ia64" : "ia64", # deprecated
+ "itanium" : "ia64", # deprecated
"x86" : "x86",
"x86_64" : "amd64",
"x86_amd64" : "x86_amd64", # Cross compile to 64 bit from 32bits
+ "arm" : "arm",
+ "arm64" : "arm64",
}
-# Given a (host, target) tuple, return the argument for the bat file. Both host
-# and targets should be canonalized.
+# Given a (host, target) tuple, return the argument for the bat file.
+# Both host and targets should be canonalized.
_HOST_TARGET_ARCH_TO_BAT_ARCH = {
("x86", "x86"): "x86",
("x86", "amd64"): "x86_amd64",
@@ -96,7 +98,12 @@ _HOST_TARGET_ARCH_TO_BAT_ARCH = {
("amd64", "x86_amd64"): "x86_amd64", # This is present in (at least) VS2012 express
("amd64", "amd64"): "amd64",
("amd64", "x86"): "x86",
- ("x86", "ia64"): "x86_ia64"
+ ("x86", "ia64"): "x86_ia64", # gone since 14.0
+ ("arm", "arm"): "arm", # since 14.0, maybe gone 14.1?
+ ("x86", "arm"): "x86_arm", # since 14.0
+ ("x86", "arm64"): "x86_arm64", # since 14.1
+ ("amd64", "arm"): "amd64_arm", # since 14.0
+ ("amd64", "arm64"): "amd64_arm64", # since 14.1
}
def get_msvc_version_numeric(msvc_version):
@@ -205,21 +212,21 @@ def msvc_version_to_maj_min(msvc_version):
raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric))
def is_host_target_supported(host_target, msvc_version):
- """Return True if the given (host, target) tuple is supported given the
- msvc version.
-
- Parameters
- ----------
- host_target: tuple
- tuple of (canonalized) host-target, e.g. ("x86", "amd64") for cross
- compilation from 32 bits windows to 64 bits.
- msvc_version: str
- msvc version (major.minor, e.g. 10.0)
-
- Note
- ----
- This only check whether a given version *may* support the given (host,
- target), not that the toolchain is actually present on the machine.
+ """Check if the given (host, target) tuple is supported for given version.
+
+ Args:
+ host_target: tuple
+ tuple of (canonalized) host-targets, e.g. ("x86", "amd64")
+ for cross compilation from 32 bit Windows to 64 bits.
+ msvc_version: str
+ msvc version (major.minor, e.g. 10.0)
+
+ Returns:
+ bool:
+
+ Note:
+ This only checks whether a given version *may* support the given (host,
+ target), not that the toolchain is actually present on the machine.
"""
# We assume that any Visual Studio version supports x86 as a target
if host_target[1] != "x86":
@@ -232,10 +239,11 @@ def is_host_target_supported(host_target, msvc_version):
def find_vc_pdir_vswhere(msvc_version):
"""
- Find the MSVC product directory using vswhere.exe .
+ Find the MSVC product directory using vswhere.exe.
+
Run it asking for specified version and get MSVS install location
:param msvc_version:
- :return: MSVC install dir
+ :return: MSVC install dir or None
"""
vswhere_path = os.path.join(
'C:\\',
@@ -244,14 +252,17 @@ def find_vc_pdir_vswhere(msvc_version):
'Installer',
'vswhere.exe'
)
- vswhere_cmd = [vswhere_path, '-version', msvc_version, '-property', 'installationPath']
+ vswhere_cmd = [vswhere_path, '-products', '*', '-version', msvc_version, '-property', 'installationPath']
if os.path.exists(vswhere_path):
sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
vsdir, err = sp.communicate()
- vsdir = vsdir.decode("mbcs")
- vsdir = vsdir.rstrip()
- vc_pdir = os.path.join(vsdir, 'VC')
+ vsdir = vsdir.decode("mbcs").splitlines()
+ # vswhere could easily return multiple lines
+ # we could define a way to pick the one we prefer, but since
+ # this data is currently only used to make a check for existence,
+ # returning the first hit should be good enough for now.
+ vc_pdir = os.path.join(vsdir[0], 'VC')
return vc_pdir
else:
# No vswhere on system, no install info available
@@ -259,13 +270,25 @@ def find_vc_pdir_vswhere(msvc_version):
def find_vc_pdir(msvc_version):
- """Try to find the product directory for the given
- version.
+ """Find the product directory for the given version.
+
+ Tries to look up the path using a registry key from the table
+ _VCVER_TO_PRODUCT_DIR; if there is no key, calls find_vc_pdir_wshere
+ for help instead.
+
+ Args:
+ msvc_version: str
+ msvc version (major.minor, e.g. 10.0)
+
+ Returns:
+ str: Path found in registry, or None
+
+ Raises:
+ UnsupportedVersion: if the version is not known by this file.
+ MissingConfiguration: found version but the directory is missing.
- Note
- ----
- If for some reason the requested version could not be found, an
- exception which inherits from VisualCException will be raised."""
+ Both exceptions inherit from VisualCException.
+ """
root = 'Software\\'
try:
hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version]
@@ -279,8 +302,10 @@ def find_vc_pdir(msvc_version):
if not key:
comps = find_vc_pdir_vswhere(msvc_version)
if not comps:
- debug('find_vc_dir(): no VC found via vswhere for version {}'.format(repr(key)))
+ debug('find_vc_pdir_vswhere(): no VC found for version {}'.format(repr(msvc_version)))
raise SCons.Util.WinError
+ debug('find_vc_pdir_vswhere(): VC found: {}'.format(repr(msvc_version)))
+ return comps
else:
if common.is_win64():
try:
@@ -312,7 +337,7 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
if pdir is None:
raise NoVersionFound("No version of Visual Studio found")
- debug('vc.py: find_batch_file() pdir:{}'.format(pdir))
+ debug('vc.py: find_batch_file() in {}'.format(pdir))
# filter out e.g. "Exp" from the version name
msvc_ver_numeric = get_msvc_version_numeric(msvc_version)
@@ -417,6 +442,7 @@ def cached_get_installed_vcs(env):
def get_installed_vcs(env):
installed_versions = []
+
for ver in _VCVER:
debug('trying to find VC %s' % ver)
try:
@@ -510,16 +536,17 @@ def msvc_find_valid_batch_script(env,version,modify_env=True):
debug('vc.py:msvc_find_valid_batch_script()')
# Find the host platform, target platform, and if present the requested
# target platform
- (host_platform, target_platform,req_target_platform) = get_host_target(env)
+ platforms = get_host_target(env)
+ debug("vc.py: msvs_find_valid_batch_script(): host_platform %s, target_platform %s req_target_platform:%s" % platforms)
+ host_platform, target_platform, req_target_platform = platforms
try_target_archs = [target_platform]
- debug("msvs_find_valid_batch_script(): req_target_platform %s target_platform:%s"%(req_target_platform,target_platform))
# VS2012 has a "cross compile" environment to build 64 bit
# with x86_amd64 as the argument to the batch setup script
- if req_target_platform in ('amd64','x86_64'):
+ if req_target_platform in ('amd64', 'x86_64'):
try_target_archs.append('x86_amd64')
- elif not req_target_platform and target_platform in ['amd64','x86_64']:
+ elif not req_target_platform and target_platform in ['amd64', 'x86_64']:
# There may not be "native" amd64, but maybe "cross" x86_amd64 tools
try_target_archs.append('x86_amd64')
# If the user hasn't specifically requested a TARGET_ARCH, and
@@ -542,7 +569,7 @@ def msvc_find_valid_batch_script(env,version,modify_env=True):
(host_target, version)
SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg)
arg = _HOST_TARGET_ARCH_TO_BAT_ARCH[host_target]
-
+
# Get just version numbers
maj, min = msvc_version_to_maj_min(version)
# VS2015+
@@ -567,9 +594,11 @@ def msvc_find_valid_batch_script(env,version,modify_env=True):
# Try to use the located batch file for this host/target platform combo
debug('vc.py:msvc_find_valid_batch_script() use_script 2 %s, args:%s\n' % (repr(vc_script), arg))
+ found = None
if vc_script:
try:
d = script_env(vc_script, args=arg)
+ found = vc_script
except BatchFileExecutionError as e:
debug('vc.py:msvc_find_valid_batch_script() use_script 3: failed running VC script %s: %s: Error:%s'%(repr(vc_script),arg,e))
vc_script=None
@@ -578,6 +607,7 @@ def msvc_find_valid_batch_script(env,version,modify_env=True):
debug('vc.py:msvc_find_valid_batch_script() use_script 4: trying sdk script: %s'%(sdk_script))
try:
d = script_env(sdk_script)
+ found = sdk_script
except BatchFileExecutionError as e:
debug('vc.py:msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e))
continue
@@ -585,7 +615,7 @@ def msvc_find_valid_batch_script(env,version,modify_env=True):
debug('vc.py:msvc_find_valid_batch_script() use_script 6: Neither VC script nor SDK script found')
continue
- debug("vc.py:msvc_find_valid_batch_script() Found a working script/target: %s %s"%(repr(sdk_script),arg))
+ debug("vc.py:msvc_find_valid_batch_script() Found a working script/target: %s/%s"%(repr(found),arg))
break # We've found a working target_platform, so stop looking
# If we cannot find a viable installed compiler, reset the TARGET_ARCH
@@ -633,11 +663,11 @@ def msvc_setup_env(env):
for k, v in d.items():
debug('vc.py:msvc_setup_env() env:%s -> %s'%(k,v))
env.PrependENVPath(k, v, delete_existing=True)
-
+
# final check to issue a warning if the compiler is not present
msvc_cl = find_program_path(env, 'cl')
if not msvc_cl:
- SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning,
+ SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning,
"Could not find MSVC compiler 'cl.exe', it may need to be installed separately with Visual Studio")
def msvc_exists(env, version=None):