OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 TestGyp.py: a testing framework for GYP integration tests. | 6 TestGyp.py: a testing framework for GYP integration tests. |
7 """ | 7 """ |
8 | 8 |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 ALL = '__all__' | 75 ALL = '__all__' |
76 DEFAULT = '__default__' | 76 DEFAULT = '__default__' |
77 | 77 |
78 # Constants for different target types. | 78 # Constants for different target types. |
79 EXECUTABLE = '__executable__' | 79 EXECUTABLE = '__executable__' |
80 STATIC_LIB = '__static_lib__' | 80 STATIC_LIB = '__static_lib__' |
81 SHARED_LIB = '__shared_lib__' | 81 SHARED_LIB = '__shared_lib__' |
82 | 82 |
83 def __init__(self, gyp=None, *args, **kw): | 83 def __init__(self, gyp=None, *args, **kw): |
84 self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) | 84 self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) |
| 85 self.extra_args = sys.argv[1:] |
85 | 86 |
86 if not gyp: | 87 if not gyp: |
87 gyp = os.environ.get('TESTGYP_GYP') | 88 gyp = os.environ.get('TESTGYP_GYP') |
88 if not gyp: | 89 if not gyp: |
89 if sys.platform == 'win32': | 90 if sys.platform == 'win32': |
90 gyp = 'gyp.bat' | 91 gyp = 'gyp.bat' |
91 else: | 92 else: |
92 gyp = 'gyp' | 93 gyp = 'gyp' |
93 self.gyp = os.path.abspath(gyp) | 94 self.gyp = os.path.abspath(gyp) |
94 | 95 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 Runs gyp against the specified gyp_file with the specified args. | 238 Runs gyp against the specified gyp_file with the specified args. |
238 """ | 239 """ |
239 | 240 |
240 # When running gyp, and comparing its output we use a comparitor | 241 # When running gyp, and comparing its output we use a comparitor |
241 # that ignores the line numbers that gyp logs in its debug output. | 242 # that ignores the line numbers that gyp logs in its debug output. |
242 if kw.pop('ignore_line_numbers', False): | 243 if kw.pop('ignore_line_numbers', False): |
243 kw.setdefault('match', match_modulo_line_numbers) | 244 kw.setdefault('match', match_modulo_line_numbers) |
244 | 245 |
245 # TODO: --depth=. works around Chromium-specific tree climbing. | 246 # TODO: --depth=. works around Chromium-specific tree climbing. |
246 depth = kw.pop('depth', '.') | 247 depth = kw.pop('depth', '.') |
247 args = ('--depth='+depth, '--format='+self.format, gyp_file) + args | 248 run_args = ['--depth='+depth, '--format='+self.format, gyp_file] |
248 return self.run(program=self.gyp, arguments=args, **kw) | 249 run_args.extend(self.extra_args) |
| 250 run_args.extend(args) |
| 251 return self.run(program=self.gyp, arguments=run_args, **kw) |
249 | 252 |
250 def run(self, *args, **kw): | 253 def run(self, *args, **kw): |
251 """ | 254 """ |
252 Executes a program by calling the superclass .run() method. | 255 Executes a program by calling the superclass .run() method. |
253 | 256 |
254 This exists to provide a common place to filter out keyword | 257 This exists to provide a common place to filter out keyword |
255 arguments implemented in this layer, without having to update | 258 arguments implemented in this layer, without having to update |
256 the tool-specific subclasses or clutter the tests themselves | 259 the tool-specific subclasses or clutter the tests themselves |
257 with platform-specific code. | 260 with platform-specific code. |
258 """ | 261 """ |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 We use the value specified by GYP_MSVS_VERSION. If not specified, we | 611 We use the value specified by GYP_MSVS_VERSION. If not specified, we |
609 search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable. | 612 search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable. |
610 Failing that, we search for likely deployment paths. | 613 Failing that, we search for likely deployment paths. |
611 """ | 614 """ |
612 possible_roots = ['C:\\Program Files (x86)', 'C:\\Program Files', | 615 possible_roots = ['C:\\Program Files (x86)', 'C:\\Program Files', |
613 'E:\\Program Files (x86)', 'E:\\Program Files'] | 616 'E:\\Program Files (x86)', 'E:\\Program Files'] |
614 possible_paths = { | 617 possible_paths = { |
615 '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com', | 618 '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com', |
616 '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com', | 619 '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com', |
617 '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'} | 620 '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'} |
618 msvs_version = os.environ.get('GYP_MSVS_VERSION', 'auto') | 621 |
| 622 msvs_version = 'auto' |
| 623 for flag in (f for f in sys.argv if f.startswith('msvs_version=')): |
| 624 msvs_version = flag.split('=')[-1] |
| 625 msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version) |
| 626 |
619 build_tool = None | 627 build_tool = None |
620 if msvs_version in possible_paths: | 628 if msvs_version in possible_paths: |
621 # Check that the path to the specified GYP_MSVS_VERSION exists. | 629 # Check that the path to the specified GYP_MSVS_VERSION exists. |
622 path = possible_paths[msvs_version] | 630 path = possible_paths[msvs_version] |
623 for r in possible_roots: | 631 for r in possible_roots: |
624 bt = os.path.join(r, path) | 632 bt = os.path.join(r, path) |
625 if os.path.exists(bt): | 633 if os.path.exists(bt): |
626 build_tool = bt | 634 build_tool = bt |
627 uses_msbuild = msvs_version >= '2010' | 635 uses_msbuild = msvs_version >= '2010' |
628 return build_tool, uses_msbuild | 636 return build_tool, uses_msbuild |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 | 1030 |
1023 def TestGyp(*args, **kw): | 1031 def TestGyp(*args, **kw): |
1024 """ | 1032 """ |
1025 Returns an appropriate TestGyp* instance for a specified GYP format. | 1033 Returns an appropriate TestGyp* instance for a specified GYP format. |
1026 """ | 1034 """ |
1027 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) | 1035 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) |
1028 for format_class in format_class_list: | 1036 for format_class in format_class_list: |
1029 if format == format_class.format: | 1037 if format == format_class.format: |
1030 return format_class(*args, **kw) | 1038 return format_class(*args, **kw) |
1031 raise Exception, "unknown format %r" % format | 1039 raise Exception, "unknown format %r" % format |
OLD | NEW |