summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel <dmoody256@gmail.com>2019-01-10 09:02:29 (GMT)
committerDaniel <dmoody256@gmail.com>2019-01-10 09:02:29 (GMT)
commita362956e9af4095ff946bffd32ae275030806ac5 (patch)
treeee26825b16b8be4fe7f0f3c4c54dec017091d113
parent13c07e009280e59ddfe127c344b05cba9bf174f5 (diff)
downloadSCons-a362956e9af4095ff946bffd32ae275030806ac5.zip
SCons-a362956e9af4095ff946bffd32ae275030806ac5.tar.gz
SCons-a362956e9af4095ff946bffd32ae275030806ac5.tar.bz2
added support for checking for arm target support, and UWP apps for 2017
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py90
-rw-r--r--test/MSVC/MSVC_UWP_APP.py141
3 files changed, 154 insertions, 79 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index a0140c6..f7c07b2 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -206,7 +206,7 @@ def get_output(vcbat, args = None, env = None):
output = stdout.decode("mbcs")
return output
-def parse_output(output, keep=("INCLUDE", "LIB", "LIBPATH", "PATH")):
+def parse_output(output, keep=("INCLUDE", "LIB", "LIBPATH", "PATH", 'VSCMD_ARG_app_plat')):
"""
Parse output from running visual c++/studios vcvarsall.bat and running set
To capture the values listed in keep
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 823f9e0..7401f5c 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -84,9 +84,9 @@ _ARCH_TO_CANONICAL = {
"itanium" : "ia64", # deprecated
"x86" : "x86",
"x86_64" : "amd64",
- "x86_amd64" : "x86_amd64", # Cross compile to 64 bit from 32bits
"arm" : "arm",
"arm64" : "arm64",
+ "aarch64" : "arm64",
}
# Given a (host, target) tuple, return the argument for the bat file.
@@ -372,6 +372,20 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
__INSTALLED_VCS_RUN = None
+def _get_host_target_dir(host_platform, target_platform):
+
+ host_target_dir = _HOST_TARGET_ARCH_TO_BAT_ARCH.get((host_platform, target_platform), False)
+
+ if not host_target_dir:
+ debug('_check_cl_exists_in_vc_dir(): unsupported host/target combination' + host_target_dir)
+ return False
+ elif host_target_dir in 'x86':
+ host_target_dir == ''
+ else:
+ host_target_dir += '\\'
+
+ return host_target_dir
+
def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# determine if there is a specific target platform we want to build for and
@@ -383,6 +397,11 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
host_platform = platform.machine().lower()
target_platform = host_platform
+ host_platform = _ARCH_TO_CANONICAL[host_platform]
+ target_platform = _ARCH_TO_CANONICAL[target_platform]
+
+ debug('_check_cl_exists_in_vc_dir(): host platform %s, target platform %s' % (host_platform, target_platform))
+
ver_num = float(get_msvc_version_numeric(msvc_version))
# make sure the cl.exe exists meaning the tool is installed
@@ -390,58 +409,71 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# 2017 and newer allowed multiple versions of the VC toolset to be installed at the same time.
# Just get the default tool version for now
#TODO: support setting a specific minor VC version
+ default_toolset_file = os.path.join(vc_dir, r'Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')
try:
- f = open(os.path.join(vc_dir, r'Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'))
+ f = open(default_toolset_file)
vc_specific_version = f.readlines()[0].strip()
except OSError:
+ debug('_check_cl_exists_in_vc_dir(): failed to open ' + default_toolset_file)
return False
except IndexError:
+ debug('_check_cl_exists_in_vc_dir(): failed to get MSVC version from ' + default_toolset_file)
return False
- if host_platform in ('amd64','x86_64'):
+ if host_platform == 'amd64':
host_dir = "Hostx64"
- elif host_platform in ('i386','i686','x86'):
+ elif host_platform == 'x86':
host_dir = "Hostx86"
else:
+ debug('_check_cl_exists_in_vc_dir(): unsupported host platform ' + host_platform)
return False
- if target_platform in ('amd64','x86_64'):
+ if target_platform == 'amd64':
target_dir = "x64"
- elif target_platform in ('i386','i686','x86'):
- target_dir = "x86"
+ elif target_platform in ('x86', 'arm', 'arm64'):
+ target_dir = target_platform
else:
+ debug('_check_cl_exists_in_vc_dir(): unsupported target platform ' + target_platform)
return False
-
- if os.path.exists(os.path.join(vc_dir, r'Tools\MSVC', vc_specific_version, 'bin', host_dir, target_dir, 'cl.exe')):
+
+ cl_path = os.path.join(vc_dir, r'Tools\MSVC', vc_specific_version, 'bin', host_dir, target_dir, 'cl.exe')
+ debug('_check_cl_exists_in_vc_dir(): checking for cl.exe at ' + cl_path)
+ if os.path.exists(cl_path):
+ debug('_check_cl_exists_in_vc_dir(): found cl.exe!')
return True
- elif ver_num <= 14:
+ elif ver_num <= 14 and ver_num >= 8:
- if host_platform in ('amd64','x86_64'):
- host_platform = "amd64"
- elif host_platform in ('i386','i686','x86'):
- host_platform = "x86"
- else:
+ if host_platform not in ('amd64','x86'):
+ debug('_check_cl_exists_in_vc_dir(): unsupported host platform ' + host_platform)
return False
- if target_platform in ('amd64','x86_64'):
- target_platform = "amd64"
- elif target_platform in ('i386','i686','x86'):
- target_platform = "x86"
- elif target_platform in ('ia64'):
- target_platform = "ia64"
- else:
+ if target_platform not in ('amd64','x86', 'ia64', 'arm' , 'arm64'):
+ debug('_check_cl_exists_in_vc_dir(): unsupported target platform ' + target_platform)
return False
- host_target_dir = _HOST_TARGET_ARCH_TO_BAT_ARCH[(host_platform, target_platform)]
- if host_target_dir == 'x86':
- host_target_dir == ''
- else:
- host_target_dir += '\\'
-
- if os.path.exists(os.path.join(vc_dir, 'bin\\' + host_target_dir + 'cl.exe')):
+ cl_path = os.path.join(vc_dir, 'bin\\' + _get_host_target_dir(host_platform, target_platform) + 'cl.exe')
+ debug('_check_cl_exists_in_vc_dir(): checking for cl.exe at ' + cl_path)
+
+ cl_path_exists = os.path.exists(cl_path)
+ if not cl_path_exists and host_platform == 'amd64':
+ # older versions of visual studio only had x86 binaries, so if the host platform is amd64, we need to check cross compile options (x86 binary compiles some other target on a 64 bit os)
+ cl_path = os.path.join(vc_dir, 'bin\\' + _get_host_target_dir('x86', target_platform) + 'cl.exe')
+ debug('_check_cl_exists_in_vc_dir(): checking for cl.exe at ' + cl_path)
+ cl_path_exists = os.path.exists(cl_path)
+
+ if cl_path_exists:
+ debug('_check_cl_exists_in_vc_dir(): found cl.exe!')
return True
+ elif ver_num < 8 and ver_num >= 6:
+ # not sure about these versions so if a VC dir was found, consider it possibly valid
+ # and let the batch script run, and any issues can get caught there
+ return os.path.exists(vc_dir)
+ else:
+ # version not support return false
+ debug('_check_cl_exists_in_vc_dir(): unsupported MSVC version: ' + str(ver_num))
+
return False
def cached_get_installed_vcs(env=None):
diff --git a/test/MSVC/MSVC_UWP_APP.py b/test/MSVC/MSVC_UWP_APP.py
index c72c739..cdd260c 100644
--- a/test/MSVC/MSVC_UWP_APP.py
+++ b/test/MSVC/MSVC_UWP_APP.py
@@ -31,22 +31,28 @@ the desired effect.
import TestSCons
import SCons.Tool.MSCommon.vc as msvc
+from SCons.Tool.MSCommon.vc import get_msvc_version_numeric
def AreVCStoreLibPathsInLIBPATH(output):
libpath = None
msvc_version = None
+ UWP_APP = None
lines = output.splitlines()
for line in lines:
if 'env[ENV][LIBPATH]=' in line:
libpath = line.split('=')[1]
elif 'env[MSVC_VERSION]=' in line:
msvc_version = line.split('=')[1]
+ elif 'env[ENV][VSCMD_ARG_app_plat]=' in line:
+ UWP_APP = line.split('=')[1]
if not libpath or not msvc_version:
# Couldn't find the libpath or msvc version in the output
return (False, False, None)
libpaths = libpath.lower().split(';')
+ msvc_num = float(get_msvc_version_numeric(msvc_version))
+
(vclibstore_path_present, vclibstorerefs_path_present) = (False, False)
for path in libpaths:
# Look for the Store VC Lib paths in the LIBPATH:
@@ -55,10 +61,18 @@ def AreVCStoreLibPathsInLIBPATH(output):
# For example,
# C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\store\amd64
# C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\store\references
- if r'vc\lib\store\references' in path:
- vclibstorerefs_path_present = True
- elif r'vc\lib\store' in path:
- vclibstore_path_present = True
+
+ if msvc_num <= 14:
+ if r'vc\lib\store\references' in path:
+ vclibstorerefs_path_present = True
+ elif r'vc\lib\store' in path:
+ vclibstore_path_present = True
+ elif msvc_num > 14:
+ if UWP_APP == "UWP":
+ if(r'\lib\x86\store\references' in path
+ or r'\lib\x64\store' in path):
+ vclibstorerefs_path_present = True
+ vclibstore_path_present = True
return (vclibstore_path_present, vclibstorerefs_path_present, msvc_version)
@@ -68,60 +82,89 @@ test = TestSCons.TestSCons()
test.skip_if_not_msvc()
-test.write('SConstruct', """
+installed_msvc_versions = msvc.cached_get_installed_vcs()
+# MSVC guaranteed to be at least one version on the system or else skip_if_not_msvc() function
+# would have skipped the test
+
+msvc_140 = '14.0' in installed_msvc_versions
+msvc_141 = '14.1' in installed_msvc_versions
+
+if not (msvc_140 or msvc_141):
+ test.skip_test("Available MSVC doesn't support App store")
+
+if msvc_140:
+
+ test.write('SConstruct', """
if ARGUMENTS.get('MSVC_UWP_APP'):
help_vars = Variables()
help_vars.Add(EnumVariable(
- 'MSVC_UWP_APP',
- 'Build for a Universal Windows Platform (UWP) Application',
- '0',
- allowed_values=('0', '1')))
+ 'MSVC_UWP_APP',
+ 'Build for a Universal Windows Platform (UWP) Application',
+ '0',
+ allowed_values=('0', '1')))
else:
help_vars = None
-env = Environment(tools=['default', 'msvc'], variables=help_vars)
+env = Environment(tools=['default', 'msvc'], variables=help_vars, MSVC_VERSION='14.0')
# Print the ENV LIBPATH to stdout
print('env[ENV][LIBPATH]=%s' % env.get('ENV').get('LIBPATH'))
print('env[MSVC_VERSION]=%s' % env.get('MSVC_VERSION'))
-""")
+ """)
-installed_msvc_versions = msvc.cached_get_installed_vcs()
-# MSVC guaranteed to be at least one version on the system or else skip_if_not_msvc() function
-# would have skipped the test
-greatest_msvc_version_on_system = installed_msvc_versions[0]
-maj, min = msvc.msvc_version_to_maj_min(greatest_msvc_version_on_system)
-
-# We always use the greatest MSVC version installed on the system
-
-if maj < 14:
- # Skip the test if MSVC version is less than VS2015
- test.skip_test("Available MSVC doesn't support App store ")
-
-# Test setting MSVC_UWP_APP is '1' (True)
-test.run(arguments = "MSVC_UWP_APP=1")
-(vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
-test.fail_test(msvc_version != greatest_msvc_version_on_system,
- message='MSVC_VERSION (%s) does not match expected greatest version on system (%s)' \
- % (msvc_version, greatest_msvc_version_on_system))
-test.fail_test((vclibstore_path_present is False) or (vclibstorerefs_path_present is False),
- message='VC Store LIBPATHs NOT present when MSVC_UWP_APP=1 (msvc_version=%s)' % msvc_version)
-
-# Test setting MSVC_UWP_APP is '0' (False)
-test.run(arguments = "MSVC_UWP_APP=0")
-(vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
-test.fail_test(msvc_version != greatest_msvc_version_on_system,
- message='MSVC_VERSION (%s) does not match expected greatest version on system (%s)' \
- % (msvc_version, greatest_msvc_version_on_system))
-test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
- message='VC Store LIBPATHs present when MSVC_UWP_APP=0 (msvc_version=%s)' % msvc_version)
-
-# Test not setting MSVC_UWP_APP
-test.run(arguments = "")
-(vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
-test.fail_test(msvc_version != greatest_msvc_version_on_system,
- message='MSVC_VERSION (%s) does not match expected greatest version on system (%s)' \
- % (msvc_version, greatest_msvc_version_on_system))
-test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
- message='VC Store LIBPATHs present when MSVC_UWP_APP not set (msvc_version=%s)' % msvc_version)
+ # Test setting MSVC_UWP_APP is '1' (True)
+ test.run(arguments = "MSVC_UWP_APP=1")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is False) or (vclibstorerefs_path_present is False),
+ message='VC Store LIBPATHs NOT present when MSVC_UWP_APP=1 (msvc_version=%s)' % msvc_version)
+
+ # Test setting MSVC_UWP_APP is '0' (False)
+ test.run(arguments = "MSVC_UWP_APP=0")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
+ message='VC Store LIBPATHs present when MSVC_UWP_APP=0 (msvc_version=%s)' % msvc_version)
+
+ # Test not setting MSVC_UWP_APP
+ test.run(arguments = "")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
+ message='VC Store LIBPATHs present when MSVC_UWP_APP not set (msvc_version=%s)' % msvc_version)
+
+if msvc_141:
+
+ test.write('SConstruct', """
+if ARGUMENTS.get('MSVC_UWP_APP'):
+ help_vars = Variables()
+ help_vars.Add(EnumVariable(
+ 'MSVC_UWP_APP',
+ 'Build for a Universal Windows Platform (UWP) Application',
+ '0',
+ allowed_values=('0', '1')))
+else:
+ help_vars = None
+env = Environment(tools=['default', 'msvc'], variables=help_vars, MSVC_VERSION='14.1')
+# Print the ENV LIBPATH to stdout
+print(str(env.get('ENV')))
+print('env[ENV][LIBPATH]=%s' % env.get('ENV').get('LIBPATH'))
+print('env[MSVC_VERSION]=%s' % env.get('MSVC_VERSION'))
+print('env[ENV][VSCMD_ARG_app_plat]=%s' % env.get('ENV').get('VSCMD_ARG_app_plat'))
+ """)
+
+ # 2017 adds
+ test.run(arguments = "MSVC_UWP_APP=1")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is False) or (vclibstorerefs_path_present is False),
+ message='VC Store LIBPATHs NOT present when MSVC_UWP_APP=1 (msvc_version=%s)' % msvc_version)
+
+ # Test setting MSVC_UWP_APP is '0' (False)
+ test.run(arguments = "MSVC_UWP_APP=0")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
+ message='VC Store LIBPATHs NOT present when MSVC_UWP_APP=1 (msvc_version=%s)' % msvc_version)
+
+ # Test not setting MSVC_UWP_APP
+ test.run(arguments = "")
+ (vclibstore_path_present, vclibstorerefs_path_present, msvc_version) = AreVCStoreLibPathsInLIBPATH(test.stdout())
+ test.fail_test((vclibstore_path_present is True) or (vclibstorerefs_path_present is True),
+ message='VC Store LIBPATHs NOT present when MSVC_UWP_APP=1 (msvc_version=%s)' % msvc_version)
test.pass_test()