Chromium Code Reviews| 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'), | |
| 39 CVoxPath('common/externs.js'), | 40 CVoxPath('common/externs.js'), |
| 40 CVoxPath('common/chrome_extension_externs.js'), | 41 CVoxPath('common/chrome_extension_externs.js'), |
| 41 CVoxPath('chromevox/background/externs.js'), | 42 CVoxPath('chromevox/background/externs.js'), |
| 42 CVoxPath('chromevox/injected/externs.js'), | 43 CVoxPath('chromevox/injected/externs.js'), |
| 43 CVoxPath('liblouis_nacl/externs.js'), | 44 CVoxPath('liblouis_nacl/externs.js'), |
| 44 CVoxPath('host/chrome/externs.js')] | 45 CVoxPath('host/chrome/externs.js')] |
| 45 | 46 |
| 46 # List of top-level scripts and externs that we can check. | 47 # List of top-level scripts and externs that we can check. |
| 47 _TOP_LEVEL_SCRIPTS = [ | 48 _TOP_LEVEL_SCRIPTS = [ |
| 48 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], | 49 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], |
| 49 [CVoxPath('common/chrome_extension_externs.js')]], | 50 [CVoxPath('common/chrome_extension_externs.js')]], |
| 50 [[CVoxPath('chromevox/background/loader.js')], _COMMON_EXTERNS], | 51 [[CVoxPath('chromevox/background/loader.js')], _COMMON_EXTERNS], |
| 51 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], | 52 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], |
| 52 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], | 53 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], |
| 54 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], | |
|
dmazzoni
2014/09/30 22:09:30
nit: indentation
David Tseng
2014/09/30 22:16:42
Done.
| |
| 53 ] | 55 ] |
| 54 | 56 |
| 55 | 57 |
| 56 def _Compile(js_files, externs): | 58 def _Compile(js_files, externs): |
| 57 try: | 59 try: |
| 58 return RunCompiler(js_files, externs) | 60 return RunCompiler(js_files, externs) |
| 59 except KeyboardInterrupt: | 61 except KeyboardInterrupt: |
| 60 return (False, 'KeyboardInterrupt') | 62 return (False, 'KeyboardInterrupt') |
| 61 | 63 |
| 62 | 64 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 if len(args) > 0: | 122 if len(args) > 0: |
| 121 changed_paths = (os.path.relpath(p) for p in args) | 123 changed_paths = (os.path.relpath(p) for p in args) |
| 122 success, output = CheckChromeVox(changed_paths) | 124 success, output = CheckChromeVox(changed_paths) |
| 123 if len(output) > 0: | 125 if len(output) > 0: |
| 124 print output | 126 print output |
| 125 return int(not success) | 127 return int(not success) |
| 126 | 128 |
| 127 | 129 |
| 128 if __name__ == '__main__': | 130 if __name__ == '__main__': |
| 129 sys.exit(main()) | 131 sys.exit(main()) |
| OLD | NEW |