OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 '''Uses the closure compiler to check the ChromeVox javascript files. | 7 '''Uses the closure compiler to check the ChromeVox javascript files. |
8 | 8 |
9 With no arguments, checks all ChromeVox scripts. If any arguments are | 9 With no arguments, checks all ChromeVox scripts. If any arguments are |
10 specified, only scripts that include any of the specified files will be | 10 specified, only scripts that include any of the specified files will be |
11 compiled. A useful argument list is the output of the command | 11 compiled. A useful argument list is the output of the command |
12 'git diff --name-only --relative'. | 12 'git diff --name-only --relative'. |
13 ''' | 13 ''' |
14 | 14 |
15 import optparse | 15 import optparse |
16 import os | 16 import os |
| 17 import re |
17 import sys | 18 import sys |
18 | 19 |
19 from multiprocessing import pool | 20 from multiprocessing import pool |
20 | 21 |
21 from jsbundler import Bundle, CalcDeps, ReadSources | 22 from jsbundler import Bundle, CalcDeps, ReadSources |
22 from jscompilerwrapper import RunCompiler | 23 from jscompilerwrapper import RunCompiler |
23 | 24 |
24 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 25 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
25 _CHROME_SOURCE_DIR = os.path.normpath( | 26 _CHROME_SOURCE_DIR = os.path.normpath( |
26 os.path.join(_SCRIPT_DIR, *[os.path.pardir] * 6)) | 27 os.path.join(_SCRIPT_DIR, *[os.path.pardir] * 6)) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 else: | 69 else: |
69 changed_files_set = None | 70 changed_files_set = None |
70 ret_success = True | 71 ret_success = True |
71 ret_output = '' | 72 ret_output = '' |
72 roots = [CVoxPath(), | 73 roots = [CVoxPath(), |
73 os.path.relpath( | 74 os.path.relpath( |
74 os.path.join( | 75 os.path.join( |
75 _CHROME_SOURCE_DIR, | 76 _CHROME_SOURCE_DIR, |
76 'chrome/third_party/chromevox/third_party/closure-library/' | 77 'chrome/third_party/chromevox/third_party/closure-library/' |
77 'closure/goog'))] | 78 'closure/goog'))] |
78 sources = ReadSources(roots, need_source_text=True) | 79 sources = ReadSources(roots, need_source_text=True, |
| 80 exclude=[re.compile('testing')]) |
79 work_pool = pool.Pool(len(_TOP_LEVEL_SCRIPTS)) | 81 work_pool = pool.Pool(len(_TOP_LEVEL_SCRIPTS)) |
80 try: | 82 try: |
81 results = [] | 83 results = [] |
82 for top_level in _TOP_LEVEL_SCRIPTS: | 84 for top_level in _TOP_LEVEL_SCRIPTS: |
83 tl_files, externs = top_level | 85 tl_files, externs = top_level |
84 bundle = Bundle() | 86 bundle = Bundle() |
85 CalcDeps(bundle, sources, tl_files) | 87 CalcDeps(bundle, sources, tl_files) |
86 bundle.Add((sources[name] for name in tl_files)) | 88 bundle.Add((sources[name] for name in tl_files)) |
87 ordered_paths = list(bundle.GetInPaths()) | 89 ordered_paths = list(bundle.GetInPaths()) |
88 if (changed_files_set is not None and | 90 if (changed_files_set is not None and |
(...skipping 29 matching lines...) Expand all Loading... |
118 if len(args) > 0: | 120 if len(args) > 0: |
119 changed_paths = (os.path.relpath(p) for p in args) | 121 changed_paths = (os.path.relpath(p) for p in args) |
120 success, output = CheckChromeVox(changed_paths) | 122 success, output = CheckChromeVox(changed_paths) |
121 if len(output) > 0: | 123 if len(output) > 0: |
122 print output | 124 print output |
123 return int(not success) | 125 return int(not success) |
124 | 126 |
125 | 127 |
126 if __name__ == '__main__': | 128 if __name__ == '__main__': |
127 sys.exit(main()) | 129 sys.exit(main()) |
OLD | NEW |