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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 def CVoxPath(path='.'): | 30 def CVoxPath(path='.'): |
31 '''Converts a path relative to the top-level chromevox directory to a | 31 '''Converts a path relative to the top-level chromevox directory to a |
32 path relative to the current directory. | 32 path relative to the current directory. |
33 ''' | 33 ''' |
34 return os.path.relpath(os.path.join(_SCRIPT_DIR, '..', path)) | 34 return os.path.relpath(os.path.join(_SCRIPT_DIR, '..', path)) |
35 | 35 |
36 | 36 |
37 # Externs common to many ChromeVox scripts. | 37 # Externs common to many ChromeVox scripts. |
38 _COMMON_EXTERNS = [ | 38 _COMMON_EXTERNS = [ |
39 CVoxPath('cvox2/background/externs.js'), | |
40 CVoxPath('common/externs.js'), | 39 CVoxPath('common/externs.js'), |
41 CVoxPath('common/chrome_extension_externs.js'), | 40 CVoxPath('common/chrome_extension_externs.js'), |
42 CVoxPath('chromevox/background/externs.js'), | 41 CVoxPath('chromevox/background/externs.js'), |
43 CVoxPath('chromevox/injected/externs.js'), | 42 CVoxPath('chromevox/injected/externs.js'), |
44 CVoxPath('liblouis_nacl/externs.js'), | 43 CVoxPath('liblouis_nacl/externs.js'), |
45 CVoxPath('host/chrome/externs.js')] | 44 CVoxPath('host/chrome/externs.js')] |
46 | 45 |
47 # List of top-level scripts and externs that we can check. | 46 # List of top-level scripts and externs that we can check. |
48 _TOP_LEVEL_SCRIPTS = [ | 47 _TOP_LEVEL_SCRIPTS = [ |
49 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], | 48 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], |
50 [CVoxPath('common/chrome_extension_externs.js')]], | 49 [CVoxPath('common/chrome_extension_externs.js')]], |
51 [[CVoxPath('chromevox/background/loader.js')], _COMMON_EXTERNS], | 50 [[CVoxPath('chromevox/background/loader.js')], _COMMON_EXTERNS], |
52 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], | 51 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], |
53 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], | 52 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], |
54 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], | |
55 ] | 53 ] |
56 | 54 |
57 | 55 |
58 def _Compile(js_files, externs): | 56 def _Compile(js_files, externs): |
59 try: | 57 try: |
60 return RunCompiler(js_files, externs) | 58 return RunCompiler(js_files, externs) |
61 except KeyboardInterrupt: | 59 except KeyboardInterrupt: |
62 return (False, 'KeyboardInterrupt') | 60 return (False, 'KeyboardInterrupt') |
63 | 61 |
64 | 62 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if len(args) > 0: | 120 if len(args) > 0: |
123 changed_paths = (os.path.relpath(p) for p in args) | 121 changed_paths = (os.path.relpath(p) for p in args) |
124 success, output = CheckChromeVox(changed_paths) | 122 success, output = CheckChromeVox(changed_paths) |
125 if len(output) > 0: | 123 if len(output) > 0: |
126 print output | 124 print output |
127 return int(not success) | 125 return int(not success) |
128 | 126 |
129 | 127 |
130 if __name__ == '__main__': | 128 if __name__ == '__main__': |
131 sys.exit(main()) | 129 sys.exit(main()) |
OLD | NEW |