diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-07-19 23:49:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-19 23:49:27 (GMT) |
commit | aa4a3ce99508569d646852932db13471da2714b7 (patch) | |
tree | 07820e0103c17b5c58080491d0e2b54353bd2c2f | |
parent | fe8e5013e9c0a313efe97c9eb55dc8f050ac5e0a (diff) | |
parent | b7f00d77d207b3ff6d6fac2103d8aebe2a29aafe (diff) | |
download | SCons-aa4a3ce99508569d646852932db13471da2714b7.zip SCons-aa4a3ce99508569d646852932db13471da2714b7.tar.gz SCons-aa4a3ce99508569d646852932db13471da2714b7.tar.bz2 |
Merge pull request #3409 from grossag/topic/grossag/msvs
Upgrade and improve Visual Studio solution/project generation code
28 files changed, 708 insertions, 2677 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 89e0124..ce7e43a 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -52,6 +52,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER def my_decider(dependency, target, prev_ni, repo_node): Where repo_node is the repository (or other) node to use to check if the node is out of date instead of dependency. + From Adam Gross: + - Upgraded and improved Visual Studio solution/project generation code using the MSVSProject builder. + - Added support for Visual Studio 2017 and 2019. + - Added support for the following per-variant parameters to the builder: + - cpppaths: Provides per-variant include paths. + - cppdefines: Provides per-variant preprocessor definitions. + From Michael Hartmann: - Fix handling of Visual Studio Compilers to properly reject any unknown HOST_PLATFORM or TARGET_PLATFORM diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 297c083..d27294b 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -70,10 +70,14 @@ def xmlify(s): s = s.replace('\n', '
') return s -# Process a CPPPATH list in includes, given the env, target and source. -# Returns a tuple of nodes. def processIncludes(includes, env, target, source): - return SCons.PathList.PathList(includes).subst_path(env, target, source) + """ + Process a CPPPATH list in includes, given the env, target and source. + Returns a list of directory paths. These paths are absolute so we avoid + putting pound-prefixed paths in a Visual Studio project file. + """ + return [env.Dir(i).abspath for i in + SCons.PathList.PathList(includes).subst_path(env, target, source)] external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}' @@ -348,10 +352,20 @@ V10DebugSettings = { } class _GenerateV10User(_UserGenerator): - """Generates a Project'user file for MSVS 2010""" + """Generates a Project'user file for MSVS 2010 or later""" def __init__(self, dspfile, source, env): - self.versionstr = '4.0' + version_num, suite = msvs_parse_version(env['MSVS_VERSION']) + if version_num >= 14.2: + # Visual Studio 2019 is considered to be version 16. + self.versionstr = '16.0' + elif version_num >= 14.1: + # Visual Studio 2017 is considered to be version 15. + self.versionstr = '15.0' + elif version_num == 14.0: + self.versionstr = '14.0' + else: + self.versionstr = '4.0' self.usrhead = V10UserHeader self.usrconf = V10UserConfiguration self.usrdebg = V10DebugSettings @@ -462,15 +476,41 @@ class _DSPGenerator(object): self.sconscript = env['MSVSSCONSCRIPT'] - if 'cmdargs' not in env or env['cmdargs'] is None: - cmdargs = [''] * len(variants) - elif SCons.Util.is_String(env['cmdargs']): - cmdargs = [env['cmdargs']] * len(variants) - elif SCons.Util.is_List(env['cmdargs']): - if len(env['cmdargs']) != len(variants): - raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.") + def GetKeyFromEnv(env, key, variants): + """ + Retrieves a specific key from the environment. If the key is + present, it is expected to either be a string or a list with length + equal to the number of variants. The function returns a list of + the desired value (e.g. cpp include paths) guaranteed to be of + length equal to the length of the variants list. + """ + if key not in env or env[key] is None: + return [''] * len(variants) + elif SCons.Util.is_String(env[key]): + return [env[key]] * len(variants) + elif SCons.Util.is_List(env[key]): + if len(env[key]) != len(variants): + raise SCons.Errors.InternalError("Sizes of '%s' and 'variant' lists must be the same." % key) + else: + return env[key] else: - cmdargs = env['cmdargs'] + raise SCons.Errors.InternalError("Unsupported type for key '%s' in environment: %s" % + (key, type(env[key]))) + + cmdargs = GetKeyFromEnv(env, 'cmdargs', variants) + + # The caller is allowed to put 'cppdefines' and/or 'cpppaths' in the + # environment, which is useful if they want to provide per-variant + # values for these. Otherwise, we fall back to using the global + # 'CPPDEFINES' and 'CPPPATH' functions. + if 'cppdefines' in env: + cppdefines = GetKeyFromEnv(env, 'cppdefines', variants) + else: + cppdefines = [env.get('CPPDEFINES', [])] * len(variants) + if 'cpppaths' in env: + cpppaths = GetKeyFromEnv(env, 'cpppaths', variants) + else: + cpppaths = [env.get('CPPPATH', [])] * len(variants) self.env = env @@ -513,13 +553,17 @@ class _DSPGenerator(object): for n in sourcenames: self.sources[n].sort(key=lambda a: a.lower()) - def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile): + def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, cppdefines, cpppaths, dspfile=dspfile, env=env): config = Config() config.buildtarget = buildtarget config.outdir = outdir config.cmdargs = cmdargs + config.cppdefines = cppdefines config.runfile = runfile + # Dir objects can't be pickled, so we need an absolute path here. + config.cpppaths = processIncludes(cpppaths, env, None, None) + match = re.match(r'(.*)\|(.*)', variant) if match: config.variant = match.group(1) @@ -532,7 +576,7 @@ class _DSPGenerator(object): print("Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'") for i in range(len(variants)): - AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i]) + AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i], cppdefines[i], cpppaths[i]) self.platforms = [] for key in list(self.configs.keys()): @@ -882,6 +926,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): buildtarget = self.configs[kind].buildtarget runfile = self.configs[kind].runfile cmdargs = self.configs[kind].cmdargs + cpppaths = self.configs[kind].cpppaths + cppdefines = self.configs[kind].cppdefines env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: @@ -899,9 +945,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): # This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE, # so they could vary depending on the command being generated. This code # assumes they don't. - preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) - includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None) - includepath = xmlify(';'.join([str(x) for x in includepath_Dirs])) + preprocdefs = xmlify(';'.join(processDefines(cppdefines))) + includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None))) if not env_has_buildtarget: del self.env['MSVSBUILDTARGET'] @@ -1060,7 +1105,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User): V10DSPHeader = """\ <?xml version="1.0" encoding="%(encoding)s"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="%(versionstr)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> """ V10DSPProjectConfiguration = """\ @@ -1075,6 +1120,7 @@ V10DSPGlobals = """\ \t\t<ProjectGuid>%(project_guid)s</ProjectGuid> %(scc_attrs)s\t\t<RootNamespace>%(name)s</RootNamespace> \t\t<Keyword>MakeFileProj</Keyword> +\t\t<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName> \t</PropertyGroup> """ @@ -1112,9 +1158,9 @@ V15DSPHeader = """\ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): """Generates a Project file for MSVS 2010""" - def __init__(self, dspfile, header, source, env): + def __init__(self, dspfile, source, env): _DSPGenerator.__init__(self, dspfile, source, env) - self.dspheader = header + self.dspheader = V10DSPHeader self.dspconfiguration = V10DSPProjectConfiguration self.dspglobals = V10DSPGlobals @@ -1123,6 +1169,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): def PrintHeader(self): env = self.env name = self.name + versionstr = self.versionstr encoding = env.subst('$MSVSENCODING') project_guid = env.get('MSVS_PROJECT_GUID', '') scc_provider = env.get('MSVS_SCC_PROVIDER', '') @@ -1198,6 +1245,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): buildtarget = self.configs[kind].buildtarget runfile = self.configs[kind].runfile cmdargs = self.configs[kind].cmdargs + cpppaths = self.configs[kind].cpppaths + cppdefines = self.configs[kind].cppdefines env_has_buildtarget = 'MSVSBUILDTARGET' in self.env if not env_has_buildtarget: @@ -1215,9 +1264,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): # This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE, # so they could vary depending on the command being generated. This code # assumes they don't. - preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', [])))) - includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None) - includepath = xmlify(';'.join([str(x) for x in includepath_Dirs])) + preprocdefs = xmlify(';'.join(processDefines(cppdefines))) + includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None))) if not env_has_buildtarget: del self.env['MSVSBUILDTARGET'] @@ -1234,7 +1282,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User): raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail)) self.filters_file.write('<?xml version="1.0" encoding="utf-8"?>\n' - '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n') + '<Project ToolsVersion="%s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n' % + self.versionstr) self.PrintSourceFiles() @@ -1466,6 +1515,9 @@ class _GenerateV7DSW(_DSWGenerator): for dspfile in self.dspfiles: dsp_folder_path, name = os.path.split(dspfile) dsp_folder_path = os.path.abspath(dsp_folder_path) + if SCons.Util.splitext(name)[1] == '.filters': + # Ignore .filters project files + continue dsp_relative_folder_path = os.path.relpath(dsp_folder_path, self.dsw_folder_path) if dsp_relative_folder_path == os.curdir: dsp_relative_file_path = name @@ -1515,7 +1567,11 @@ class _GenerateV7DSW(_DSWGenerator): def PrintSolution(self): """Writes a solution file""" self.file.write('Microsoft Visual Studio Solution File, Format Version %s\n' % self.versionstr) - if self.version_num > 14.0: + if self.version_num >= 14.2: + # Visual Studio 2019 is considered to be version 16. + self.file.write('# Visual Studio 16\n') + elif self.version_num > 14.0: + # Visual Studio 2015 and 2017 are both considered to be version 15. self.file.write('# Visual Studio 15\n') elif self.version_num >= 12.0: self.file.write('# Visual Studio 14\n') @@ -1695,11 +1751,8 @@ def GenerateDSP(dspfile, source, env): version_num = 6.0 if 'MSVS_VERSION' in env: version_num, suite = msvs_parse_version(env['MSVS_VERSION']) - if version_num > 14.0: - g = _GenerateV10DSP(dspfile, V15DSPHeader, source, env) - g.Build() - elif version_num >= 10.0: - g = _GenerateV10DSP(dspfile, V10DSPHeader, source, env) + if version_num >= 10.0: + g = _GenerateV10DSP(dspfile, source, env) g.Build() elif version_num >= 7.0: g = _GenerateV7DSP(dspfile, source, env) @@ -1792,8 +1845,7 @@ def projectEmitter(target, source, env): # Project file depends on CPPDEFINES and CPPPATH preprocdefs = xmlify(';'.join(processDefines(env.get('CPPDEFINES', [])))) - includepath_Dirs = processIncludes(env.get('CPPPATH', []), env, None, None) - includepath = xmlify(';'.join([str(x) for x in includepath_Dirs])) + includepath = xmlify(';'.join(processIncludes(env.get('CPPPATH', []), env, None, None))) source = source + "; ppdefs:%s incpath:%s"%(preprocdefs, includepath) if 'buildtarget' in env and env['buildtarget'] is not None: @@ -1973,8 +2025,14 @@ def generate(env): default_MSVS_SConscript = env.File('SConstruct') env['MSVSSCONSCRIPT'] = default_MSVS_SConscript - env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env)) - env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}' + # Allow consumers to provide their own versions of MSVSSCONS and + # MSVSSCONSFLAGS. This helps support consumers who use wrapper scripts to + # invoke scons. + if 'MSVSSCONS' not in env: + env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env)) + if 'MSVSSCONSFLAGS' not in env: + env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}' + env['MSVSSCONSCOM'] = '$MSVSSCONS $MSVSSCONSFLAGS' env['MSVSBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"' env['MSVSREBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"' diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml index 6467a2b..3a9fdf0 100644 --- a/src/engine/SCons/Tool/msvs.xml +++ b/src/engine/SCons/Tool/msvs.xml @@ -48,14 +48,16 @@ See its __doc__ string for a discussion of the format. latest installed version, or the version specified by &cv-link-MSVS_VERSION; in the Environment constructor). For Visual Studio 6, it will generate a <filename>.dsp</filename> - file. For Visual Studio 7 (.NET) and later versions, it will - generate a <filename>.vcproj</filename> file. + file. For Visual Studio 7, 8, and 9, it will + generate a <filename>.vcproj</filename> file. For Visual + Studio 10 and later, it will generate a + <filename>.vcxproj</filename> file. </para> <para> By default, this also generates a solution file for the specified project, a <filename>.dsw</filename> file for Visual Studio 6 or a <filename>.sln</filename> file for - Visual Studio 7 (.NET). This behavior may be disabled by + Visual Studio 7 and later. This behavior may be disabled by specifying <literal>auto_build_solution=0</literal> when you call &b-MSVSProject;, in which case you presumably want to build the solution file(s) by calling the &b-MSVSSolution; @@ -128,6 +130,36 @@ See its __doc__ string for a discussion of the format. </listitem> </varlistentry> <varlistentry> + <term>cppdefines</term> + <listitem> + <para> + Preprocessor definitions for the different variants. + The number of <literal>cppdefines</literal> entries + must match the number of <literal>variant</literal> + entries, or be empty (not specified). If you give + only one, it will automatically be propagated to all + variants. If you don't give this parameter, SCons + will use the invoking environment's + <literal>CPPDEFINES</literal> entry for all variants. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>cpppaths</term> + <listitem> + <para> + Compiler include paths for the different variants. + The number of <literal>cpppaths</literal> entries + must match the number of <literal>variant</literal> + entries, or be empty (not specified). If you give + only one, it will automatically be propagated to all + variants. If you don't give this parameter, SCons + will use the invoking environment's + <literal>CPPPATH</literal> entry for all variants. + </para> + </listitem> + </varlistentry> + <varlistentry> <term>buildtarget</term> <listitem> <para> diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 477694a..cc4f717 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -34,6 +34,7 @@ import TestUnit from SCons.Tool.msvs import * from SCons.Tool.MSCommon.vs import SupportedVSList +import SCons.Node.FS import SCons.Util import SCons.Warnings @@ -352,6 +353,36 @@ regdata_80 = r''' "VCXDCMakeTool"="*.xdc" '''.split('\n') +regdata_140 = r''' +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS] +"MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\" +"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\" +"VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe" +"EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe" +"EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\" +"VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\" +"VS7CommonBinDir"="" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber] +"1033"="14.0" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community] +"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI] +"Version"="14.0.25527" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI] +"Version"="14.0.25527" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro] +"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional] +"IsInstallInProgress"="0" +"CurrentOperation"="install" +"SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409" +"SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml" +"InstallResult"="0" +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller] +[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools] +"Version"="7.0.20620.1" +'''.split('\n') + regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion] "ProgramFilesDir"="C:\Program Files" "CommonFilesDir"="C:\Program Files\Common Files" @@ -363,6 +394,7 @@ regdata_none = [] class DummyEnv(object): def __init__(self, dict=None): + self.fs = SCons.Node.FS.FS() if dict: self.dict = dict else: @@ -385,6 +417,16 @@ class DummyEnv(object): def has_key(self,name): return name in self.dict + def get(self, name, value=None): + if self.has_key(name): + return self.dict[name] + else: + return value + + def Dir(self, name): + return self.fs.Dir(name) + + class RegKey(object): """key class for storing an 'open' registry key""" def __init__(self,key): @@ -554,6 +596,11 @@ class msvsTestCase(unittest.TestCase): from SCons.Tool.MSCommon.vs import reset_installed_visual_studios reset_installed_visual_studios() + self.test = TestCmd.TestCmd(workdir='') + # FS doesn't like the cwd to be something other than its root. + os.chdir(self.test.workpath("")) + self.fs = SCons.Node.FS.FS() + def test_get_default_version(self): """Test retrieval of the default visual studio version""" @@ -607,13 +654,19 @@ class msvsTestCase(unittest.TestCase): version_num, suite = msvs_parse_version(self.highest_version) if version_num >= 10.0: function_test = _GenerateV10DSP + suffix = '.vcxproj' elif version_num >= 7.0: function_test = _GenerateV7DSP + suffix = '.dsp' else: function_test = _GenerateV6DSP + suffix = '.dsp' + + # Avoid any race conditions between the test cases when we test + # actually writing the files. + dspfile = 'test%s%s' % (hash(self), suffix) str_function_test = str(function_test.__init__) - dspfile = 'test.dsp' source = 'test.cpp' # Create the cmdargs test list @@ -623,50 +676,95 @@ class msvsTestCase(unittest.TestCase): 'debug=False target_arch=32', 'debug=True target_arch=x64', 'debug=False target_arch=x64'] - - # Tuple list : (parameter, dictionary of expected result per variant) - tests_cmdargs = [(None, dict.fromkeys(list_variant, '')), - ('', dict.fromkeys(list_variant, '')), - (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])), - (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))] - + list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []] + list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'], + [self.fs.Dir('subdir')], []] + + def TestParamsFromList(test_variant, test_list): + """ + Generates test data based on the parameters passed in. + + Returns tuple list: + 1. Parameter. + 2. Dictionary of expected result per variant. + """ + def normalizeParam(param): + """ + Converts the raw data based into the AddConfig function of + msvs.py to the expected result. + + Expects the following behavior: + 1. A value of None will be converted to an empty list. + 2. A File or Directory object will be converted to an + absolute path (because those objects can't be pickled). + 3. Otherwise, the parameter will be used. + """ + if param is None: + return [] + elif isinstance(param, list): + return [normalizeParam(p) for p in param] + elif hasattr(param, 'abspath'): + return param.abspath + else: + return param + + return [ + (None, dict.fromkeys(test_variant, '')), + ('', dict.fromkeys(test_variant, '')), + (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))), + (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list])))) + ] + + tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs) + tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines) + tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths) + # Run the test for each test case for param_cmdargs, expected_cmdargs in tests_cmdargs: - debug('Testing %s. with :\n variant = %s \n cmdargs = "%s"' % \ - (str_function_test, list_variant, param_cmdargs)) - param_configs = [] - expected_configs = {} - for platform in ['Win32', 'x64']: - for variant in ['Debug', 'Release']: - variant_platform = '%s|%s' % (variant, platform) - runfile = '%s\\%s\\test.exe' % (platform, variant) - buildtarget = '%s\\%s\\test.exe' % (platform, variant) - outdir = '%s\\%s' % (platform, variant) + for param_cppdefines, expected_cppdefines in tests_cppdefines: + for param_cpppaths, expected_cpppaths in tests_cpppaths: + debug('Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s"' % \ + (str_function_test, list_variant, param_cmdargs, param_cppdefines, param_cpppaths)) + param_configs = [] + expected_configs = {} + for platform in ['Win32', 'x64']: + for variant in ['Debug', 'Release']: + variant_platform = '%s|%s' % (variant, platform) + runfile = '%s\\%s\\test.exe' % (platform, variant) + buildtarget = '%s\\%s\\test.exe' % (platform, variant) + outdir = '%s\\%s' % (platform, variant) - # Create parameter list for this variant_platform - param_configs.append([variant_platform, runfile, buildtarget, outdir]) - - # Create expected dictionary result for this variant_platform - expected_configs[variant_platform] = \ - {'variant': variant, 'platform': platform, - 'runfile': runfile, - 'buildtarget': buildtarget, - 'outdir': outdir, - 'cmdargs': expected_cmdargs[variant_platform]} + # Create parameter list for this variant_platform + param_configs.append([variant_platform, runfile, buildtarget, outdir]) + # Create expected dictionary result for this variant_platform + expected_configs[variant_platform] = { + 'variant': variant, + 'platform': platform, + 'runfile': runfile, + 'buildtarget': buildtarget, + 'outdir': outdir, + 'cmdargs': expected_cmdargs[variant_platform], + 'cppdefines': expected_cppdefines[variant_platform], + 'cpppaths': expected_cpppaths[variant_platform], + } + # Create parameter environment with final parameter dictionary param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'), [list(l) for l in zip(*param_configs)]))) param_dict['cmdargs'] = param_cmdargs + param_dict['cppdefines'] = param_cppdefines + param_dict['cpppaths'] = param_cpppaths # Hack to be able to run the test with a 'DummyEnv' class _DummyEnv(DummyEnv): - def subst(self, string) : + def subst(self, string, *args, **kwargs): return string env = _DummyEnv(param_dict) env['MSVSSCONSCRIPT'] = '' env['MSVS_VERSION'] = self.highest_version + env['MSVSBUILDTARGET'] = 'target' # Call function to test genDSP = function_test(dspfile, source, env) @@ -676,6 +774,16 @@ class msvsTestCase(unittest.TestCase): for key in list(genDSP.configs.keys()): self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key]) + genDSP.Build() + + # Delete the resulting file so we don't leave anything behind. + for file in [dspfile, dspfile + '.filters']: + path = os.path.realpath(file) + try: + os.remove(path) + except OSError: + pass + class msvs6aTestCase(msvsTestCase): """Test MSVS 6 Registry""" registry = DummyRegistry(regdata_6a + regdata_cv) @@ -787,6 +895,18 @@ class msvs80TestCase(msvsTestCase): } default_install_loc = install_locs['8.0'] +class msvs140TestCase(msvsTestCase): + """Test MSVS 140 Registry""" + registry = DummyRegistry(regdata_140 + regdata_cv) + default_version = '14.0' + highest_version = '14.0' + number_of_versions = 2 + install_locs = { + '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0', + 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'}, + } + default_install_loc = install_locs['14.0'] + class msvsEmptyTestCase(msvsTestCase): """Test Empty Registry""" registry = DummyRegistry(regdata_none) @@ -829,6 +949,7 @@ if __name__ == "__main__": msvs71TestCase, msvs8ExpTestCase, msvs80TestCase, + msvs140TestCase, msvsEmptyTestCase, ] diff --git a/test/MSVS/vs-10.0-files.py b/test/MSVS/vs-10.0-files.py deleted file mode 100644 index 8cdc152..0000000 --- a/test/MSVS/vs-10.0-files.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 10.0 project (.vcxproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['10.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_10_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_10_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_10_0 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '10.0', None, 'SConstruct') -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '10.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcxproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '10.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-10.0-scc-legacy-files.py b/test/MSVS/vs-10.0-scc-legacy-files.py deleted file mode 100644 index 9cb65d8..0000000 --- a/test/MSVS/vs-10.0-scc-legacy-files.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 10.0 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['10.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_10_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_10_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='10.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '10.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '10.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-11.0-files.py b/test/MSVS/vs-11.0-files.py deleted file mode 100644 index 6c4933c..0000000 --- a/test/MSVS/vs-11.0-files.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 11.0 project (.vcxproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['11.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_11_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_11_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_11_0 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '11.0', None, 'SConstruct') -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '11.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcxproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '11.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-11.0-scc-files.py b/test/MSVS/vs-11.0-scc-files.py deleted file mode 100644 index 2b13e46..0000000 --- a/test/MSVS/vs-11.0-scc-files.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 11.0 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['11.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_11_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_11_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='11.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_CONNECTION_ROOT='.', - MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_sln_sccinfo = """\ -\tGlobalSection(SourceCodeControl) = preSolution -\t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\\u0020Project -\t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM -\t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcxproj -\t\tSccLocalPath1 = . -\t\tCanCheckoutShared = true -\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ -\tEndGlobalSection -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>.</SccLocalPath> -\t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '11.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '11.0', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-11.0-scc-legacy-files.py b/test/MSVS/vs-11.0-scc-legacy-files.py deleted file mode 100644 index 9e46f6a..0000000 --- a/test/MSVS/vs-11.0-scc-legacy-files.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 11.0 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['11.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_11_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_11_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='11.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '11.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '11.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0-files.py b/test/MSVS/vs-14.0-files.py deleted file mode 100644 index e4ba8e2..0000000 --- a/test/MSVS/vs-14.0-files.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 14.0 project (.vcxproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_14_0 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct') -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcxproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0-scc-files.py b/test/MSVS/vs-14.0-scc-files.py deleted file mode 100644 index d706b32..0000000 --- a/test/MSVS/vs-14.0-scc-files.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 14.0 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_CONNECTION_ROOT='.', - MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_sln_sccinfo = """\ -\tGlobalSection(SourceCodeControl) = preSolution -\t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\\u0020Project -\t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM -\t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcxproj -\t\tSccLocalPath1 = . -\t\tCanCheckoutShared = true -\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ -\tEndGlobalSection -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>.</SccLocalPath> -\t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.1-files.py b/test/MSVS/vs-14.1-files.py deleted file mode 100644 index a7c8437..0000000 --- a/test/MSVS/vs-14.1-files.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 14.1 project (.vcxproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.1'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_14_1 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_1 -SConscript_contents = TestSConsMSVS.SConscript_contents_14_1 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.1', None, 'SConstruct') -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.1', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -test.must_exist(test.workpath('Test.vcxproj.filters')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcxproj')) -test.must_not_exist(test.workpath('Test.vcxproj.filters')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcxproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcxproj') - -test.must_exist(test.workpath('Test.vcxproj')) -vcxproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.1', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.1-scc-files.py b/test/MSVS/vs-14.1-scc-files.py deleted file mode 100644 index 465c904..0000000 --- a/test/MSVS/vs-14.1-scc-files.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 14.1 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.1'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_14_1 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_1 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.1', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_CONNECTION_ROOT='.', - MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_sln_sccinfo = """\ -\tGlobalSection(SourceCodeControl) = preSolution -\t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\\u0020Project -\t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM -\t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcxproj -\t\tSccLocalPath1 = . -\t\tCanCheckoutShared = true -\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ -\tEndGlobalSection -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>.</SccLocalPath> -\t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.1', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.1', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.1-scc-legacy-files.py b/test/MSVS/vs-14.1-scc-legacy-files.py deleted file mode 100644 index 45d94a6..0000000 --- a/test/MSVS/vs-14.1-scc-legacy-files.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 14.1 project (.vcxproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.1'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_14_1 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_1 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.1', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_vcproj_sccinfo = """\ -\t\t<SccProjectName>Perforce Project</SccProjectName> -\t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath> -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") - -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.1', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.1', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-clean.py b/test/MSVS/vs-8.0-clean.py deleted file mode 100644 index 7ca1c46..0000000 --- a/test/MSVS/vs-8.0-clean.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Verify the -c option's ability to clean generated Visual Studio 8.0 -project (.vcproj) and solution (.sln) files. -""" - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 - - - -test.write('SConstruct', """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -p = env.MSVSProject(target = 'Test.vcproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release', - auto_build_solution = 0) - -env.MSVSSolution(target = 'Test.sln', - slnguid = '{SLNGUID}', - projects = [p], - variant = 'Release') -"""%{'HOST_ARCH': host_arch}) - -test.run(arguments=".") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='.') - -test.must_exist(test.workpath('Test.vcproj')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.vcproj') - -test.must_not_exist(test.workpath('Test.vcproj')) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-files.py b/test/MSVS/vs-8.0-files.py deleted file mode 100644 index 038a5bf..0000000 --- a/test/MSVS/vs-8.0-files.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 8.0 project (.vcproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_8_0 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-scc-files.py b/test/MSVS/vs-8.0-scc-files.py deleted file mode 100644 index 05a8a5f..0000000 --- a/test/MSVS/vs-8.0-scc-files.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 8.0 project (.vcproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_CONNECTION_ROOT='.', - MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_sln_sccinfo = """\ -\tGlobalSection(SourceCodeControl) = preSolution -\t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\\u0020Project -\t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM -\t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcproj -\t\tSccLocalPath1 = . -\t\tCanCheckoutShared = true -\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ -\tEndGlobalSection -""" - -expected_vcproj_sccinfo = """\ -\tSccProjectName="Perforce Project" -\tSccLocalPath="." -\tSccProvider="MSSCCI:Perforce SCM" -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-scc-legacy-files.py b/test/MSVS/vs-8.0-scc-legacy-files.py deleted file mode 100644 index bfb8416..0000000 --- a/test/MSVS/vs-8.0-scc-legacy-files.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 8.0 project (.vcproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_vcproj_sccinfo = """\ -\tSccProjectName="Perforce Project" -\tSccLocalPath="C:\\MyMsVsProjects" -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-variant_dir.py b/test/MSVS/vs-8.0-variant_dir.py deleted file mode 100644 index 20c7381..0000000 --- a/test/MSVS/vs-8.0-variant_dir.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 8.0 project (.vcproj) and -solution (.sln) files that look correct when using a variant_dir. -""" - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_8_0 - - - -test.subdir('src') - -test.write('SConstruct', """\ -SConscript('src/SConscript', variant_dir='build') -""") - -test.write(['src', 'SConscript'], SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments=".") - -project_guid = "{25F6CE89-8E22-2910-8B6E-FFE6DC1E2792}" -vcproj = test.read(['src', 'Test.vcproj'], 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct', - project_guid=project_guid) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('src', 'Test.sln')) -sln = test.read(['src', 'Test.sln'], 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', 'src', - project_guid=project_guid) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.must_match(['build', 'Test.vcproj'], """\ -This is just a placeholder file. -The real project file is here: -%s -""" % test.workpath('src', 'Test.vcproj'), - mode='r') - -test.must_match(['build', 'Test.sln'], """\ -This is just a placeholder file. -The real workspace file is here: -%s -""" % test.workpath('src', 'Test.sln'), - mode='r') - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-8.0-x64-files.py b/test/MSVS/vs-8.0-x64-files.py deleted file mode 100644 index 072ba22..0000000 --- a/test/MSVS/vs-8.0-x64-files.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 8.0 project (.vcproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['8.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_8_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_8_0 - -# We didn't create an API for putting parameters like this into -# the common generated and expected files. Until we do, just patch -# in the values. -expected_slnfile = expected_slnfile.replace('Win32', 'x64') -expected_vcprojfile = expected_vcprojfile.replace('Win32', 'x64') -SConscript_contents = SConscript_contents.replace('\'Release\'', '\'Release|x64\'') - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-9.0-files.py b/test/MSVS/vs-9.0-files.py deleted file mode 100644 index eccca51..0000000 --- a/test/MSVS/vs-9.0-files.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 9.0 project (.vcproj) and -solution (.sln) files that look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() -host_arch = test.get_vs_host_arch() - - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['9.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_9_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_9_0 -SConscript_contents = TestSConsMSVS.SConscript_contents_9_0 - - - -test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '9.0', None, 'SConstruct') -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '9.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - -test.run(arguments='-c .') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -test.must_exist(test.workpath('Test.sln')) - -test.run(arguments='-c Test.sln') - -test.must_not_exist(test.workpath('Test.vcproj')) -test.must_not_exist(test.workpath('Test.sln')) - - - -# Test that running SCons with $PYTHON_ROOT in the environment -# changes the .vcproj output as expected. -os.environ['PYTHON_ROOT'] = 'xyzzy' -python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) - -test.run(arguments='Test.vcproj') - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '9.0', None, 'SConstruct', - python=python) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-9.0-scc-files.py b/test/MSVS/vs-9.0-scc-files.py deleted file mode 100644 index c270010..0000000 --- a/test/MSVS/vs-9.0-scc-files.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 9.0 project (.vcproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['9.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_9_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_9_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='9.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_CONNECTION_ROOT='.', - MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_sln_sccinfo = """\ -\tGlobalSection(SourceCodeControl) = preSolution -\t\tSccNumberOfProjects = 2 -\t\tSccProjectName0 = Perforce\\u0020Project -\t\tSccLocalPath0 = . -\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM -\t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcproj -\t\tSccLocalPath1 = . -\t\tCanCheckoutShared = true -\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ -\tEndGlobalSection -""" - -expected_vcproj_sccinfo = """\ -\tSccProjectName="Perforce Project" -\tSccLocalPath="." -\tSccProvider="MSSCCI:Perforce SCM" -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '9.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '9.0', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-9.0-scc-legacy-files.py b/test/MSVS/vs-9.0-scc-legacy-files.py deleted file mode 100644 index 0085f64..0000000 --- a/test/MSVS/vs-9.0-scc-legacy-files.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that we can generate Visual Studio 9.0 project (.vcproj) and -solution (.sln) files that contain SCC information and look correct. -""" - -import os - -import TestSConsMSVS - -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['9.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_9_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_9_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='9.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', - MSVS_SCC_PROJECT_NAME='Perforce Project') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -expected_vcproj_sccinfo = """\ -\tSccProjectName="Perforce Project" -\tSccLocalPath="C:\\MyMsVsProjects" -""" - - -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcproj") - -test.must_exist(test.workpath('Test.vcproj')) -vcproj = test.read('Test.vcproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '9.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '9.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-files.py b/test/MSVS/vs-files.py new file mode 100644 index 0000000..b330ce7 --- /dev/null +++ b/test/MSVS/vs-files.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that we can generate Visual Studio 10.0 or later project (.vcxproj) and +solution (.sln) files that look correct. +""" + +import os + +import TestSConsMSVS + +for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): + test = TestSConsMSVS.TestSConsMSVS() + host_arch = test.get_vs_host_arch() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj' + filters_file = project_file + '.filters' + filters_file_expected = major >= 10 + expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file) + expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file) + + test.write('SConstruct', test.get_expected_sconscript_file_contents(vc_version, project_file)) + + test.run(arguments=project_file) + + test.must_exist(test.workpath(project_file)) + if filters_file_expected: + test.must_exist(test.workpath(filters_file)) + else: + test.must_not_exist(test.workpath(filters_file)) + vcxproj = test.read(project_file, 'r') + expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct') + # don't compare the pickled data + assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) + + test.must_exist(test.workpath('Test.sln')) + sln = test.read('Test.sln', 'r') + expect = test.msvs_substitute(expected_slnfile, vc_version, None, 'SConstruct') + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.run(arguments='-c .') + + test.must_not_exist(test.workpath(project_file)) + test.must_not_exist(test.workpath(filters_file)) + test.must_not_exist(test.workpath('Test.sln')) + + test.run(arguments=project_file) + + test.must_exist(test.workpath(project_file)) + if filters_file_expected: + test.must_exist(test.workpath(filters_file)) + else: + test.must_not_exist(test.workpath(filters_file)) + test.must_exist(test.workpath('Test.sln')) + + test.run(arguments='-c Test.sln') + + test.must_not_exist(test.workpath(project_file)) + test.must_not_exist(test.workpath(filters_file)) + test.must_not_exist(test.workpath('Test.sln')) + + # Test that running SCons with $PYTHON_ROOT in the environment + # changes the .vcxproj output as expected. + os.environ['PYTHON_ROOT'] = 'xyzzy' + python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) + + test.run(arguments=project_file) + + test.must_exist(test.workpath(project_file)) + vcxproj = test.read(project_file, 'r') + expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct', + python=python) + # don't compare the pickled data + assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) + + test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-10.0-scc-files.py b/test/MSVS/vs-scc-files.py index 8a08ece..85fa27c 100644 --- a/test/MSVS/vs-10.0-scc-files.py +++ b/test/MSVS/vs-scc-files.py @@ -29,21 +29,23 @@ Test that we can generate Visual Studio 10.0 project (.vcxproj) and solution (.sln) files that contain SCC information and look correct. """ -import os - import TestSConsMSVS -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['10.0'] - - - -expected_slnfile = TestSConsMSVS.expected_slnfile_10_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_10_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='10.0', +for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): + test = TestSConsMSVS.TestSConsMSVS() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj' + filters_file = project_file + '.filters' + filters_file_expected = major >= 10 + expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file) + expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file) + SConscript_contents = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='{vc_version}', CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], CPPPATH=['inc1', 'inc2'], MSVS_SCC_CONNECTION_ROOT='.', @@ -56,7 +58,7 @@ testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] -env.MSVSProject(target = 'Test.vcxproj', +env.MSVSProject(target = '{project_file}', srcs = testsrc, incs = testincs, localincs = testlocalincs, @@ -64,49 +66,58 @@ env.MSVSProject(target = 'Test.vcxproj', misc = testmisc, buildtarget = 'Test.exe', variant = 'Release') -""" +""".format(vc_version=vc_version, project_file=project_file) -expected_sln_sccinfo = """\ + expected_sln_sccinfo = """\ \tGlobalSection(SourceCodeControl) = preSolution \t\tSccNumberOfProjects = 2 \t\tSccProjectName0 = Perforce\\u0020Project \t\tSccLocalPath0 = . \t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM \t\tCanCheckoutShared = true -\t\tSccProjectUniqueName1 = Test.vcxproj +\t\tSccProjectUniqueName1 = {project_file} \t\tSccLocalPath1 = . \t\tCanCheckoutShared = true \t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ \tEndGlobalSection +""".format(project_file=project_file) + + if major < 10: + # VC8 and VC9 used key-value pair format. + expected_vcproj_sccinfo = """\ +\tSccProjectName="Perforce Project" +\tSccLocalPath="." +\tSccProvider="MSSCCI:Perforce SCM" """ - -expected_vcproj_sccinfo = """\ + else: + # VC10 and later use XML format. + expected_vcproj_sccinfo = """\ \t\t<SccProjectName>Perforce Project</SccProjectName> \t\t<SccLocalPath>.</SccLocalPath> \t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider> """ -test.write('SConstruct', SConscript_contents) + test.write('SConstruct', SConscript_contents) -test.run(arguments="Test.vcxproj") + test.run(arguments=project_file) -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '10.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + test.must_exist(test.workpath(project_file)) + vcproj = test.read(project_file, 'r') + expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct', + vcproj_sccinfo=expected_vcproj_sccinfo) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '10.0', None, 'SConstruct', - sln_sccinfo=expected_sln_sccinfo) -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + test.must_exist(test.workpath('Test.sln')) + sln = test.read('Test.sln', 'r') + expect = test.msvs_substitute(expected_slnfile, vc_version, None, 'SConstruct', + sln_sccinfo=expected_sln_sccinfo) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) -test.pass_test() + test.pass_test() # Local Variables: # tab-width:4 diff --git a/test/MSVS/vs-14.0-scc-legacy-files.py b/test/MSVS/vs-scc-legacy-files.py index 904a103..8e2ca15 100644 --- a/test/MSVS/vs-14.0-scc-legacy-files.py +++ b/test/MSVS/vs-scc-legacy-files.py @@ -25,25 +25,28 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test that we can generate Visual Studio 14.0 project (.vcxproj) and +Test that we can generate Visual Studio 10.0 or later project (.vcxproj) and solution (.sln) files that contain SCC information and look correct. """ -import os - import TestSConsMSVS -test = TestSConsMSVS.TestSConsMSVS() - -# Make the test infrastructure think we have this version of MSVS installed. -test._msvs_versions = ['14.0'] +for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): + test = TestSConsMSVS.TestSConsMSVS() + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj' + filters_file = project_file + '.filters' + filters_file_expected = major >= 10 + expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file) + expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file) -expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 -expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 -SConscript_contents = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', + SConscript_contents = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='{vc_version}', CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], CPPPATH=['inc1', 'inc2'], MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects', @@ -55,7 +58,7 @@ testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] -env.MSVSProject(target = 'Test.vcxproj', +env.MSVSProject(target = '{project_file}', srcs = testsrc, incs = testincs, localincs = testlocalincs, @@ -63,33 +66,40 @@ env.MSVSProject(target = 'Test.vcxproj', misc = testmisc, buildtarget = 'Test.exe', variant = 'Release') -""" +""".format(vc_version=vc_version, project_file=project_file) -expected_vcproj_sccinfo = """\ + if major < 10: + # VC8 and VC9 used key-value pair format. + expected_vcproj_sccinfo = """\ +\tSccProjectName="Perforce Project" +\tSccLocalPath="C:\\MyMsVsProjects" +""" + else: + # VC10 and later use XML format. + expected_vcproj_sccinfo = """\ \t\t<SccProjectName>Perforce Project</SccProjectName> \t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath> """ + test.write('SConstruct', SConscript_contents) -test.write('SConstruct', SConscript_contents) - -test.run(arguments="Test.vcxproj") + test.run(arguments=project_file) -test.must_exist(test.workpath('Test.vcxproj')) -vcproj = test.read('Test.vcxproj', 'r') -expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', - vcproj_sccinfo=expected_vcproj_sccinfo) -# don't compare the pickled data -assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + test.must_exist(test.workpath(project_file)) + vcproj = test.read(project_file, 'r') + expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct', + vcproj_sccinfo=expected_vcproj_sccinfo) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) -test.must_exist(test.workpath('Test.sln')) -sln = test.read('Test.sln', 'r') -expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct') -# don't compare the pickled data -assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + test.must_exist(test.workpath('Test.sln')) + sln = test.read('Test.sln', 'r') + expect = test.msvs_substitute(expected_slnfile, vc_version, None, 'SConstruct') + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) -test.pass_test() + test.pass_test() # Local Variables: # tab-width:4 diff --git a/test/MSVS/vs-variant_dir.py b/test/MSVS/vs-variant_dir.py new file mode 100644 index 0000000..15b46e8 --- /dev/null +++ b/test/MSVS/vs-variant_dir.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that we can generate Visual Studio 8.0 project (.vcproj) and +solution (.sln) files that look correct when using a variant_dir. +""" + +import TestSConsMSVS + +for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): + test = TestSConsMSVS.TestSConsMSVS() + host_arch = test.get_vs_host_arch() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj' + expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file) + expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file) + + test.subdir('src') + + test.write('SConstruct', """\ +SConscript('src/SConscript', variant_dir='build') +""") + + test.write('SConstruct', """\ +SConscript('src/SConscript', variant_dir='build') +""") + + test.write(['src', 'SConscript'], test.get_expected_sconscript_file_contents(vc_version, project_file)) + + test.run(arguments=".") + + project_guid = "{25F6CE89-8E22-2910-8B6E-FFE6DC1E2792}" + vcproj = test.read(['src', project_file], 'r') + expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct', + project_guid=project_guid) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath('src', 'Test.sln')) + sln = test.read(['src', 'Test.sln'], 'r') + expect = test.msvs_substitute(expected_slnfile, '8.0', 'src', + project_guid=project_guid) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_match(['build', 'Test.vcproj'], """\ +This is just a placeholder file. +The real project file is here: +%s +""" % test.workpath('src', project_file), mode='r') + + test.must_match(['build', 'Test.sln'], """\ +This is just a placeholder file. +The real workspace file is here: +%s +""" % test.workpath('src', 'Test.sln'), mode='r') + + test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py index 348d7ed..4b05ddd 100644 --- a/testing/framework/TestSConsMSVS.py +++ b/testing/framework/TestSConsMSVS.py @@ -23,6 +23,7 @@ import platform import traceback from xml.etree import ElementTree +import SCons.Errors from TestSCons import * from TestSCons import __all__ @@ -435,31 +436,10 @@ env.MSVSProject(target = 'Test.vcproj', """ - -expected_slnfile_8_0 = """\ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "<PROJECT_GUID>" -EndProject -Global -<SCC_SLN_INFO> -\tGlobalSection(SolutionConfigurationPlatforms) = preSolution -\t\tRelease|Win32 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(ProjectConfigurationPlatforms) = postSolution -\t\t<PROJECT_GUID>.Release|Win32.ActiveCfg = Release|Win32 -\t\t<PROJECT_GUID>.Release|Win32.Build.0 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(SolutionProperties) = preSolution -\t\tHideSolutionNode = FALSE -\tEndGlobalSection -EndGlobal -""" - -expected_slnfile_9_0 = """\ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "<PROJECT_GUID>" +expected_slnfile_fmt = """\ +Microsoft Visual Studio Solution File, Format Version %(FORMAT_VERSION)s +# Visual Studio %(VS_NUMBER)s +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "%(PROJECT_NAME)s", "%(PROJECT_FILE)s", "<PROJECT_GUID>" EndProject Global <SCC_SLN_INFO> @@ -476,91 +456,11 @@ Global EndGlobal """ -expected_slnfile_10_0 = """\ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}" -EndProject -Global -<SCC_SLN_INFO> -\tGlobalSection(SolutionConfigurationPlatforms) = preSolution -\t\tRelease|Win32 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(ProjectConfigurationPlatforms) = postSolution -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32 -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(SolutionProperties) = preSolution -\t\tHideSolutionNode = FALSE -\tEndGlobalSection -EndGlobal -""" - -expected_slnfile_11_0 = """\ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 11 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}" -EndProject -Global -<SCC_SLN_INFO> -\tGlobalSection(SolutionConfigurationPlatforms) = preSolution -\t\tRelease|Win32 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(ProjectConfigurationPlatforms) = postSolution -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32 -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(SolutionProperties) = preSolution -\t\tHideSolutionNode = FALSE -\tEndGlobalSection -EndGlobal -""" - -expected_slnfile_14_0 = """\ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}" -EndProject -Global -<SCC_SLN_INFO> -\tGlobalSection(SolutionConfigurationPlatforms) = preSolution -\t\tRelease|Win32 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(ProjectConfigurationPlatforms) = postSolution -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32 -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(SolutionProperties) = preSolution -\t\tHideSolutionNode = FALSE -\tEndGlobalSection -EndGlobal -""" - -expected_slnfile_14_1 = """\ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}" -EndProject -Global -<SCC_SLN_INFO> -\tGlobalSection(SolutionConfigurationPlatforms) = preSolution -\t\tRelease|Win32 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(ProjectConfigurationPlatforms) = postSolution -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32 -\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32 -\tEndGlobalSection -\tGlobalSection(SolutionProperties) = preSolution -\t\tHideSolutionNode = FALSE -\tEndGlobalSection -EndGlobal -""" - -expected_vcprojfile_8_0 = """\ +expected_vcprojfile_fmt = """\ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject \tProjectType="Visual C++" -\tVersion="8.00" +\tVersion="%(TOOLS_VERSION)s" \tName="Test" \tProjectGUID="<PROJECT_GUID>" \tRootNamespace="Test" @@ -586,7 +486,7 @@ expected_vcprojfile_8_0 = """\ \t\t\t\tCleanCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"" \t\t\t\tOutput="Test.exe" \t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234" -\t\t\t\tIncludeSearchPath="inc1;inc2" +\t\t\t\tIncludeSearchPath="%(INCLUDE_DIRS)s" \t\t\t\tForcedIncludes="" \t\t\t\tAssemblySearchPath="" \t\t\t\tForcedUsingAssemblies="" @@ -601,7 +501,7 @@ expected_vcprojfile_8_0 = """\ \t\t\tName="Header Files" \t\t\tFilter="h;hpp;hxx;hm;inl"> \t\t\t<File -\t\t\t\tRelativePath="sdk.h"> +\t\t\t\tRelativePath="sdk_dir\\sdk.h"> \t\t\t</File> \t\t</Filter> \t\t<Filter @@ -644,97 +544,9 @@ expected_vcprojfile_8_0 = """\ </VisualStudioProject> """ -expected_vcprojfile_9_0 = """\ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject -\tProjectType="Visual C++" -\tVersion="9.00" -\tName="Test" -\tProjectGUID="<PROJECT_GUID>" -\tRootNamespace="Test" -<SCC_VCPROJ_INFO> -\tKeyword="MakeFileProj"> -\t<Platforms> -\t\t<Platform -\t\t\tName="Win32"/> -\t</Platforms> -\t<ToolFiles> -\t</ToolFiles> -\t<Configurations> -\t\t<Configuration -\t\t\tName="Release|Win32" -\t\t\tConfigurationType="0" -\t\t\tUseOfMFC="0" -\t\t\tATLMinimizesCRunTimeLibraryUsage="false" -\t\t\t> -\t\t\t<Tool -\t\t\t\tName="VCNMakeTool" -\t\t\t\tBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"" -\t\t\t\tReBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"" -\t\t\t\tCleanCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"" -\t\t\t\tOutput="Test.exe" -\t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234" -\t\t\t\tIncludeSearchPath="inc1;inc2" -\t\t\t\tForcedIncludes="" -\t\t\t\tAssemblySearchPath="" -\t\t\t\tForcedUsingAssemblies="" -\t\t\t\tCompileAsManaged="" -\t\t\t/> -\t\t</Configuration> -\t</Configurations> -\t<References> -\t</References> -\t<Files> -\t\t<Filter -\t\t\tName="Header Files" -\t\t\tFilter="h;hpp;hxx;hm;inl"> -\t\t\t<File -\t\t\t\tRelativePath="sdk.h"> -\t\t\t</File> -\t\t</Filter> -\t\t<Filter -\t\t\tName="Local Headers" -\t\t\tFilter="h;hpp;hxx;hm;inl"> -\t\t\t<File -\t\t\t\tRelativePath="test.h"> -\t\t\t</File> -\t\t</Filter> -\t\t<Filter -\t\t\tName="Other Files" -\t\t\tFilter=""> -\t\t\t<File -\t\t\t\tRelativePath="readme.txt"> -\t\t\t</File> -\t\t</Filter> -\t\t<Filter -\t\t\tName="Resource Files" -\t\t\tFilter="r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"> -\t\t\t<File -\t\t\t\tRelativePath="test.rc"> -\t\t\t</File> -\t\t</Filter> -\t\t<Filter -\t\t\tName="Source Files" -\t\t\tFilter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat"> -\t\t\t<File -\t\t\t\tRelativePath="test1.cpp"> -\t\t\t</File> -\t\t\t<File -\t\t\t\tRelativePath="test2.cpp"> -\t\t\t</File> -\t\t</Filter> -\t\t<File -\t\t\tRelativePath="<SCONSCRIPT>"> -\t\t</File> -\t</Files> -\t<Globals> -\t</Globals> -</VisualStudioProject> -""" - -expected_vcprojfile_10_0 = """\ +expected_vcxprojfile_fmt = """\ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="%(TOOLS_VERSION)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> \t<ItemGroup Label="ProjectConfigurations"> \t\t<ProjectConfiguration Include="Release|Win32"> \t\t\t<Configuration>Release</Configuration> @@ -746,6 +558,7 @@ expected_vcprojfile_10_0 = """\ <SCC_VCPROJ_INFO> \t\t<RootNamespace>Test</RootNamespace> \t\t<Keyword>MakeFileProj</Keyword> +\t\t<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName> \t</PropertyGroup> \t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> \t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> @@ -767,7 +580,7 @@ expected_vcprojfile_10_0 = """\ \t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"</NMakeCleanCommandLine> \t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput> \t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions> -\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath> +\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(INCLUDE_DIRS)s</NMakeIncludeSearchPath> \t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes> \t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> \t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> @@ -797,249 +610,8 @@ expected_vcprojfile_10_0 = """\ </Project> """ -expected_vcprojfile_11_0 = """\ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> -\t<ItemGroup Label="ProjectConfigurations"> -\t\t<ProjectConfiguration Include="Release|Win32"> -\t\t\t<Configuration>Release</Configuration> -\t\t\t<Platform>Win32</Platform> -\t\t</ProjectConfiguration> -\t</ItemGroup> -\t<PropertyGroup Label="Globals"> -\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid> -<SCC_VCPROJ_INFO> -\t\t<RootNamespace>Test</RootNamespace> -\t\t<Keyword>MakeFileProj</Keyword> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> -\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> -\t\t<ConfigurationType>Makefile</ConfigurationType> -\t\t<UseOfMfc>false</UseOfMfc> -\t\t<PlatformToolset>v110</PlatformToolset> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> -\t<ImportGroup Label="ExtensionSettings"> -\t</ImportGroup> -\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> -\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> -\t</ImportGroup> -\t<PropertyGroup Label="UserMacros" /> -\t<PropertyGroup> -\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> -\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeBuildCommandLine> -\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeReBuildCommandLine> -\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"</NMakeCleanCommandLine> -\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput> -\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions> -\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath> -\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes> -\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> -\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> -\t</PropertyGroup> -\t<ItemGroup> -\t\t<ClInclude Include="sdk_dir\\sdk.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClInclude Include="test.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="readme.txt" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="test.rc" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClCompile Include="test1.cpp" /> -\t\t<ClCompile Include="test2.cpp" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="SConstruct" /> -\t</ItemGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" /> -\t<ImportGroup Label="ExtensionTargets"> -\t</ImportGroup> -</Project> -""" - -expected_vcprojfile_14_0 = """\ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> -\t<ItemGroup Label="ProjectConfigurations"> -\t\t<ProjectConfiguration Include="Release|Win32"> -\t\t\t<Configuration>Release</Configuration> -\t\t\t<Platform>Win32</Platform> -\t\t</ProjectConfiguration> -\t</ItemGroup> -\t<PropertyGroup Label="Globals"> -\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid> -<SCC_VCPROJ_INFO> -\t\t<RootNamespace>Test</RootNamespace> -\t\t<Keyword>MakeFileProj</Keyword> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> -\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> -\t\t<ConfigurationType>Makefile</ConfigurationType> -\t\t<UseOfMfc>false</UseOfMfc> -\t\t<PlatformToolset>v140</PlatformToolset> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> -\t<ImportGroup Label="ExtensionSettings"> -\t</ImportGroup> -\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> -\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> -\t</ImportGroup> -\t<PropertyGroup Label="UserMacros" /> -\t<PropertyGroup> -\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> -\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeBuildCommandLine> -\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeReBuildCommandLine> -\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"</NMakeCleanCommandLine> -\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput> -\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions> -\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath> -\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes> -\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> -\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> -\t</PropertyGroup> -\t<ItemGroup> -\t\t<ClInclude Include="sdk_dir\\sdk.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClInclude Include="test.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="readme.txt" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="test.rc" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClCompile Include="test1.cpp" /> -\t\t<ClCompile Include="test2.cpp" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="SConstruct" /> -\t</ItemGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" /> -\t<ImportGroup Label="ExtensionTargets"> -\t</ImportGroup> -</Project> -""" - -expected_vcprojfile_14_1 = """\ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> -\t<ItemGroup Label="ProjectConfigurations"> -\t\t<ProjectConfiguration Include="Release|Win32"> -\t\t\t<Configuration>Release</Configuration> -\t\t\t<Platform>Win32</Platform> -\t\t</ProjectConfiguration> -\t</ItemGroup> -\t<PropertyGroup Label="Globals"> -\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid> -<SCC_VCPROJ_INFO> -\t\t<RootNamespace>Test</RootNamespace> -\t\t<Keyword>MakeFileProj</Keyword> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> -\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> -\t\t<ConfigurationType>Makefile</ConfigurationType> -\t\t<UseOfMfc>false</UseOfMfc> -\t\t<PlatformToolset>v141</PlatformToolset> -\t</PropertyGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> -\t<ImportGroup Label="ExtensionSettings"> -\t</ImportGroup> -\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> -\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> -\t</ImportGroup> -\t<PropertyGroup Label="UserMacros" /> -\t<PropertyGroup> -\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> -\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeBuildCommandLine> -\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeReBuildCommandLine> -\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"</NMakeCleanCommandLine> -\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput> -\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions> -\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath> -\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes> -\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> -\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> -\t</PropertyGroup> -\t<ItemGroup> -\t\t<ClInclude Include="sdk_dir\\sdk.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClInclude Include="test.h" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="readme.txt" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="test.rc" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<ClCompile Include="test1.cpp" /> -\t\t<ClCompile Include="test2.cpp" /> -\t</ItemGroup> -\t<ItemGroup> -\t\t<None Include="SConstruct" /> -\t</ItemGroup> -\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" /> -\t<ImportGroup Label="ExtensionTargets"> -\t</ImportGroup> -</Project> -""" - -SConscript_contents_8_0 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - slnguid = '{SLNGUID}', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -SConscript_contents_9_0 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='9.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = ['sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcproj', - slnguid = '{SLNGUID}', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -SConscript_contents_10_0 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='10.0', +SConscript_contents_fmt = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='%(MSVS_VERSION)s', CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], CPPPATH=['inc1', 'inc2'], HOST_ARCH='%(HOST_ARCH)s') @@ -1050,7 +622,7 @@ testlocalincs = ['test.h'] testresources = ['test.rc'] testmisc = ['readme.txt'] -env.MSVSProject(target = 'Test.vcxproj', +env.MSVSProject(target = '%(PROJECT_FILE)s', slnguid = '{SLNGUID}', srcs = testsrc, incs = testincs, @@ -1061,74 +633,13 @@ env.MSVSProject(target = 'Test.vcxproj', variant = 'Release') """ -SConscript_contents_11_0 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='11.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] +def get_tested_proj_file_vc_versions(): + """ + Returns all MSVC versions that we want to test project file creation for. + """ + return ['8.0', '9.0', '10.0', '11.0', '12.0', '14.0', '14.1', '14.2'] -env.MSVSProject(target = 'Test.vcxproj', - slnguid = '{SLNGUID}', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -SConscript_contents_14_0 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - slnguid = '{SLNGUID}', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" - -SConscript_contents_14_1 = """\ -env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.1', - CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], - CPPPATH=['inc1', 'inc2'], - HOST_ARCH='%(HOST_ARCH)s') - -testsrc = ['test1.cpp', 'test2.cpp'] -testincs = [r'sdk_dir\\sdk.h'] -testlocalincs = ['test.h'] -testresources = ['test.rc'] -testmisc = ['readme.txt'] - -env.MSVSProject(target = 'Test.vcxproj', - slnguid = '{SLNGUID}', - srcs = testsrc, - incs = testincs, - localincs = testlocalincs, - resources = testresources, - misc = testmisc, - buildtarget = 'Test.exe', - variant = 'Release') -""" class TestSConsMSVS(TestSCons): """Subclass for testing MSVS-specific portions of SCons.""" @@ -1276,6 +787,119 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions())) print("--------------------------------------------------------------") print("--------------------------------------------------------------") self.fail_test() + + def parse_vc_version(self, vc_version): + """ + Parses the string vc_version to determine the major and minor version + included. + """ + components = vc_version.split('.') + major = int(components[0]) + minor = 0 if len(components) < 2 else int(components[1]) + return major, minor + + def _get_solution_file_format_version(self, vc_version): + """ + Returns the Visual Studio format version expected in the .sln file. + """ + major, _ = self.parse_vc_version(vc_version) + if major == 8: + return '9.00' + elif major == 9: + return '10.00' + elif major == 10: + return '11.00' + elif major > 10: + return '12.00' + else: + raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version) + + def _get_solution_file_vs_number(self, vc_version): + """ + Returns the Visual Studio number expected in the .sln file. + """ + major, minor = self.parse_vc_version(vc_version) + if major == 8: + return '2005' + elif major == 9: + return '2008' + if major == 10: + return '2010' + elif major == 11: + return '11' + elif major == 12: + return '14' + elif major == 14 and (minor == 0 or minor == 1): + # Visual Studio 2015 and 2017 both use 15 in this entry. + return '15' + elif major == 14 and minor == 2: + return '16' + else: + raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version) + + def _get_vcxproj_file_tools_version(self, vc_version): + """ + Returns the version entry expected in the project file. + For .vcxproj files, this goes is ToolsVersion. + For .vcproj files, this goes in Version. + """ + major, minor = self.parse_vc_version(vc_version) + if major == 8: + # Version="8.00" + return '8.00' + elif major == 9: + # Version="9.00" + return '9.00' + elif major < 14: + # ToolsVersion='4.0' + return '4.0' + elif major == 14 and minor == 0: + # ToolsVersion='14.0' + return '14.0' + elif major == 14 and minor == 1: + # ToolsVersion='15.0' + return '15.0' + elif vc_version == '14.2': + # ToolsVersion='16' + return '16.0' + else: + raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version) + + def _get_vcxproj_file_cpp_path(self, dirs): + """Returns the include paths expected in the .vcxproj file""" + return ';'.join([self.workpath(dir) for dir in dirs]) + + def get_expected_sln_file_contents(self, vc_version, project_file): + """ + Returns the expected .sln file contents. + Currently this function only supports the newer VC versions that use + the .vcxproj file format. + """ + return expected_slnfile_fmt % { + 'FORMAT_VERSION': self._get_solution_file_format_version(vc_version), + 'VS_NUMBER': self._get_solution_file_vs_number(vc_version), + 'PROJECT_NAME': project_file.split('.')[0], + 'PROJECT_FILE': project_file, + } + + def get_expected_proj_file_contents(self, vc_version, dirs, project_file): + """Returns the expected .vcxproj file contents""" + if project_file.endswith('.vcxproj'): + fmt = expected_vcxprojfile_fmt + else: + fmt = expected_vcprojfile_fmt + return fmt % { + 'TOOLS_VERSION': self._get_vcxproj_file_tools_version(vc_version), + 'INCLUDE_DIRS': self._get_vcxproj_file_cpp_path(dirs), + } + + def get_expected_sconscript_file_contents(self, vc_version, project_file): + return SConscript_contents_fmt % { + 'HOST_ARCH': self.get_vs_host_arch(), + 'MSVS_VERSION': vc_version, + 'PROJECT_FILE': project_file, + } + # Local Variables: # tab-width:4 # indent-tabs-mode:nil |