Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: test/lib/TestGyp.py

Issue 245923003: Fix msvs-ninja OutputDirectory path. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Can now run just msvs-ninja. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/ios/gyptest-xcode-ninja.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/lib/TestGyp.py
===================================================================
--- test/lib/TestGyp.py (revision 1924)
+++ test/lib/TestGyp.py (working copy)
@@ -78,6 +78,7 @@
configuration and to run executables generated by those builds.
"""
+ formats = []
build_tool = None
build_tool_list = []
@@ -113,6 +114,8 @@
self.gyp = os.path.abspath(gyp)
self.no_parallel = False
+ self.formats = [self.format]
+
self.initialize_build_tool()
kw.setdefault('match', TestCommon.match_exact)
@@ -130,10 +133,11 @@
super(TestGypBase, self).__init__(*args, **kw)
+ realFormat = self.format.split('-')[-1]
scottmg 2014/05/30 16:41:37 realFormat -> real_format
bungeman-chromium 2014/05/30 22:18:09 Done.
excluded_formats = set([f for f in formats if f[0] == '!'])
included_formats = set(formats) - excluded_formats
- if ('!'+self.format in excluded_formats or
- included_formats and self.format not in included_formats):
+ if ('!'+realFormat in excluded_formats or
+ included_formats and realFormat not in included_formats):
msg = 'Invalid test for %r format; skipping test.\n'
self.skip_test(msg % self.format)
@@ -272,9 +276,13 @@
# TODO: --depth=. works around Chromium-specific tree climbing.
depth = kw.pop('depth', '.')
- run_args = ['--depth='+depth, '--format='+self.format, gyp_file]
+ run_args = ['--depth='+depth]
+ run_args.extend(['--format='+f for f in self.formats]);
+ run_args.append(gyp_file)
if self.no_parallel:
run_args += ['--no-parallel']
+ # TODO: if extra_args contains a '--build' flag
+ # we really want that to only apply to the last format (self.format).
run_args.extend(self.extra_args)
run_args.extend(args)
return self.run(program=self.gyp, arguments=run_args, **kw)
@@ -1002,6 +1010,126 @@
return self.workpath(*result)
+def FindMSBuildInstallation():
scottmg 2014/05/30 16:41:37 This looks very similar to FindVisualStudioInstall
bungeman-chromium 2014/05/30 22:18:09 It is, but it needn't be. I think I shied away fro
+ """Returns appropriate values for .build_tool and .uses_msbuild fields
+ of TestGypBase for Visual Studio.
+
+ We use the value specified by GYP_MSVS_VERSION. If not specified, we
+ search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable.
+ Failing that, we search for likely deployment paths.
+ """
+ possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix)
+ for drive in range(ord('C'), ord('Z') + 1)
+ for suffix in ['', ' (x86)']]
+ possible_roots.extend(['%s:\\Windows' % (chr(drive),)
+ for drive in range(ord('C'), ord('Z') + 1)])
+ possible_paths = {
+ '2013': r'MSBuild\12.0\Bin\MSBuild.exe', #Program Files
+ '2012': r'Microsoft.NET\Framework\v4.0.30319\MSBuild.exe', #Windows
+ '2010': r'Microsoft.NET\Framework\v4.0\MSBuild.exe',
+ '2008': r'Microsoft.NET\Framework\v3.5\MSBuild.exe'}
+ #The reccommended way to find this is
+ #reg.exe query "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0" /v MSBuildToolsPath
+ #2013 : 12.0
+ #2012 : 4.0 (really v4.0.30319 which comes with 4.5)
+ #2010 : 4.0
+ #2008 : 3.5
+
+ possible_roots = [ConvertToCygpath(r) for r in possible_roots]
+
+ msvs_version = 'auto'
+ for flag in (f for f in sys.argv if f.startswith('msvs_version=')):
+ msvs_version = flag.split('=')[-1]
+ msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version)
+
+ build_tool = None
+ if msvs_version in possible_paths:
+ # Check that the path to the specified GYP_MSVS_VERSION exists.
+ path = possible_paths[msvs_version]
+ for r in possible_roots:
+ bt = os.path.join(r, path)
+ if os.path.exists(bt):
+ build_tool = bt
+ return build_tool
+ else:
+ print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
+ 'but corresponding "%s" was not found.' % (msvs_version, path))
+ if build_tool:
+ # We found 'MSBuild' on the path, use that and try to guess the version.
+ for version, path in possible_paths.iteritems():
+ if build_tool.find(path) >= 0:
+ return build_tool
+ return build_tool
+ # Neither GYP_MSVS_VERSION nor the path help us out. Iterate through
+ # the choices looking for a match.
+ for version in sorted(possible_paths, reverse=True):
+ path = possible_paths[version]
+ for r in possible_roots:
+ bt = os.path.join(r, path)
+ if os.path.exists(bt):
+ build_tool = bt
+ return build_tool
+ print 'Error: could not find MSBuild'
+ sys.exit(1)
+
+
+class TestGypMSVSNinja(TestGypNinja):
+ """
+ Subclass for testing the GYP Visual Studio Ninja generator.
+ """
+ format = 'msvs-ninja'
+
+ def initialize_build_tool(self):
+ super(TestGypMSVSNinja, self).initialize_build_tool()
+ self.msbuild_path = FindMSBuildInstallation()
+ # When using '--build', make sure ninja is first in the format list.
+ self.formats.insert(0, 'ninja')
+
+ def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
+ """
+ Runs a Visual Studio build using the configuration generated
+ from the specified gyp_file.
+ """
+ arguments = kw.get('arguments', [])[:]
+ if target not in (None, self.ALL, self.DEFAULT):
+ # MSBuild documentation claims that one can specify a sln but then build a
+ # project target like 'msbuild a.sln /t:proj:target' but this format only
+ # supports 'Clean', 'Rebuild', and 'Publish' (with none meaning Default).
+ # This limitation is due to the .sln -> .sln.metaproj conversion.
+ # The ':' is not special, 'proj:target' is a target in the metaproj.
+ arguments.extend([target+'.vcxproj'])
+ else:
+ # Note: the Visual Studio generator doesn't add an explicit 'all' target.
+ if 1:
+ # This will build each project. This will work if projects are hermetic,
+ # but may fail if they are not (a project may run more than once).
+ # It would be nice to supply an all.metaproj for MSBuild.
+ arguments.extend([gyp_file.replace('.gyp', '.sln')])
+ else:
+ # This is a cheat which just runs ninja's 'all' target directly.
+ # However, this doesn't test what we want to test here,
+ # which is that the thin msbuild projects call ninja correctly.
+ return super(TestGypMSVSNinja, self).build(gyp_file, target=target, **kw)
+
+ if clean:
+ build = 'Clean'
+ elif rebuild:
+ build = 'Rebuild'
+ else:
+ build = 'Build'
+ arguments.extend(['/target:'+build])
+ configuration = self.configuration_buildname()
+ config = configuration.split('|')
+ arguments.extend(['/property:Configuration='+config[0]])
+ if len(config) > 1:
+ arguments.extend(['/property:Platform='+config[1]])
+ arguments.extend(['/property:BuildInParallel=false'])
+ arguments.extend(['/verbosity:minimal'])
+
+ kw['arguments'] = arguments
+ return self.run(program=self.msbuild_path, **kw)
+
+
class TestGypXcode(TestGypBase):
"""
Subclass for testing the GYP Xcode generator.
@@ -1118,6 +1246,7 @@
TestGypCMake,
TestGypMake,
TestGypMSVS,
+ TestGypMSVSNinja,
TestGypNinja,
TestGypXcode,
]
« no previous file with comments | « test/ios/gyptest-xcode-ninja.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698