Permalink
Browse files

- Make gyptest.py set up the environment in case cl/link/etc. aren't …

…in the environment.

- Add ninja to Windows runs.
Review URL: https://chromiumcodereview.appspot.com/9433026

git-svn-id: http://gyp.googlecode.com/svn/trunk@1236 78cadc50-ecff-11dd-a971-7dbc132099af
  • Loading branch information...
scottmg@chromium.org
scottmg@chromium.org committed Feb 23, 2012
1 parent f2a88c8 commit 880525d606ba0b4b185351e379c25d74fbc2d326
Showing with 68 additions and 46 deletions.
  1. +1 −0 buildbot/buildbot_run.py
  2. +67 −46 test/lib/TestGyp.py
View
@@ -79,6 +79,7 @@ def GypBuild():
retcode += GypTestFormat('xcode')
retcode += GypTestFormat('make')
elif sys.platform == 'win32':
+ retcode += GypTestFormat('ninja')
retcode += GypTestFormat('msvs-2008', format='msvs', msvs_version='2008')
if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64':
retcode += GypTestFormat('msvs-2010', format='msvs', msvs_version='2010')
View
@@ -410,6 +410,57 @@ def built_file_path(self, name, type=None, **kw):
return self.workpath(*result)
+def FindVisualStudioInstallation():
+ """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 = ['C:\\Program Files (x86)', 'C:\\Program Files',
+ 'E:\\Program Files (x86)', 'E:\\Program Files']
+ possible_paths = {
+ '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com',
+ '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com',
+ '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'}
+ msvs_version = os.environ.get('GYP_MSVS_VERSION', 'auto')
+ 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
+ uses_msbuild = msvs_version >= '2010'
+ return build_tool, uses_msbuild
+ else:
+ print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
+ 'but corresponding "%s" was not found.' % (msvs_version, path))
+ if build_tool:
+ # We found 'devenv' on the path, use that and try to guess the version.
+ for version, path in possible_paths.iteritems():
+ if build_tool.find(path) >= 0:
+ uses_msbuild = version >= '2010'
+ return build_tool, uses_msbuild
+ else:
+ # If not, assume not MSBuild.
+ uses_msbuild = False
+ return build_tool, uses_msbuild
+ # Neither GYP_MSVS_VERSION nor the path help us out. Iterate through
+ # the choices looking for a match.
+ for version, path in possible_paths.iteritems():
+ for r in possible_roots:
+ bt = os.path.join(r, path)
+ if os.path.exists(bt):
+ build_tool = bt
+ uses_msbuild = msvs_version >= '2010'
+ return build_tool, uses_msbuild
+ print 'Error: could not find devenv'
+ sys.exit(1)
+
+
class TestGypNinja(TestGypBase):
"""
Subclass for testing the GYP Ninja generator.
@@ -419,6 +470,18 @@ class TestGypNinja(TestGypBase):
ALL = 'all'
DEFAULT = 'all'
+ def initialize_build_tool(self):
+ super(TestGypNinja, self).initialize_build_tool()
+ if sys.platform == 'win32':
+ # Compiler and linker aren't in the path by default on Windows, so we
+ # make our "build tool" be set up + run ninja.
+ devenv_path, _ = FindVisualStudioInstallation()
+ devenv_dir = os.path.split(devenv_path)[0]
+ vsvars_path = os.path.join(devenv_path, '../../Tools/vsvars32.bat')
+ vsvars_path = os.path.normpath(vsvars_path)
+ self.build_tool = os.environ.get('COMSPEC', 'cmd.exe')
+ self.helper_args = ['/c', vsvars_path, '&&', 'ninja']
+
def run_gyp(self, gyp_file, *args, **kw):
TestGypBase.run_gyp(self, gyp_file, *args, **kw)
@@ -433,6 +496,9 @@ def build(self, gyp_file, target=None, **kw):
target = 'all'
arguments.append(target)
+ if sys.platform == 'win32':
+ arguments = self.helper_args + arguments
+
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
@@ -492,53 +558,8 @@ class TestGypMSVS(TestGypBase):
build_tool_list = [None, 'devenv.com']
def initialize_build_tool(self):
- """ Initializes the Visual Studio .build_tool and .uses_msbuild parameters.
-
- 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.
- """
super(TestGypMSVS, self).initialize_build_tool()
- possible_roots = ['C:\\Program Files (x86)', 'C:\\Program Files',
- 'E:\\Program Files (x86)', 'E:\\Program Files']
- possible_paths = {
- '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com',
- '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com',
- '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'}
- msvs_version = os.environ.get('GYP_MSVS_VERSION', 'auto')
- 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):
- self.build_tool = bt
- self.uses_msbuild = msvs_version >= '2010'
- return
- else:
- print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
- 'but corresponding "%s" was not found.' % (msvs_version, path))
- if self.build_tool:
- # We found 'devenv' on the path, use that and try to guess the version.
- for version, path in possible_paths.iteritems():
- if self.build_tool.find(path) >= 0:
- self.uses_msbuild = version >= '2010'
- return
- else:
- # If not, assume not MSBuild.
- self.uses_msbuild = False
- return
- # Neither GYP_MSVS_VERSION nor the path help us out. Iterate through
- # the choices looking for a match.
- for version, path in possible_paths.iteritems():
- for r in possible_roots:
- bt = os.path.join(r, path)
- if os.path.exists(bt):
- self.build_tool = bt
- self.uses_msbuild = msvs_version >= '2010'
- return
- print 'Error: could not find devenv'
- sys.exit(1)
+ self.build_tool, self.uses_msbuild = FindVisualStudioInstallation()
def build(self, gyp_file, target=None, rebuild=False, **kw):
"""
Runs a Visual Studio build using the configuration generated

0 comments on commit 880525d

Please sign in to comment.