| 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 23 matching lines...) Expand all Loading... |
| 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 def ChromeRootPath(path='.'): | 37 def ChromeRootPath(path='.'): |
| 38 '''Converts a path relative to the top-level chromevox directory to a | 38 '''Converts a path relative to the top-level chromevox directory to a |
| 39 path relative to the current directory. | 39 path relative to the current directory. |
| 40 ''' | 40 ''' |
| 41 return os.path.relpath(os.path.join(_CHROME_SOURCE_DIR, path)) | 41 return os.path.relpath(os.path.join(_CHROME_SOURCE_DIR, path)) |
| 42 | 42 |
| 43 | 43 |
| 44 # AccessibilityPrivate externs file. |
| 45 _ACCESSIBILITY_PRIVATE_EXTERNS = ( |
| 46 ChromeRootPath( |
| 47 'third_party/closure_compiler/externs/accessibility_private.js')) |
| 48 |
| 44 # Automation API externs file. | 49 # Automation API externs file. |
| 45 _AUTOMATION_EXTERNS = ( | 50 _AUTOMATION_EXTERNS = ( |
| 46 ChromeRootPath('third_party/closure_compiler/externs/automation.js')) | 51 ChromeRootPath('third_party/closure_compiler/externs/automation.js')) |
| 47 | 52 |
| 48 # MetricsPrivate externs file. | 53 # MetricsPrivate externs file. |
| 49 _METRICS_PRIVATE_EXTERNS = ( | 54 _METRICS_PRIVATE_EXTERNS = ( |
| 50 ChromeRootPath('third_party/closure_compiler/externs/metrics_private.js')) | 55 ChromeRootPath('third_party/closure_compiler/externs/metrics_private.js')) |
| 51 | 56 |
| 52 # Additional chrome extension api externs file. | 57 # Additional chrome extension api externs file. |
| 53 _CHROME_EXTENSIONS_EXTERNS = ( | 58 _CHROME_EXTENSIONS_EXTERNS = ( |
| 54 ChromeRootPath('third_party/closure_compiler/externs/chrome_extensions.js')) | 59 ChromeRootPath('third_party/closure_compiler/externs/chrome_extensions.js')) |
| 55 | 60 |
| 56 | 61 |
| 57 # Externs common to many ChromeVox scripts. | 62 # Externs common to many ChromeVox scripts. |
| 58 _COMMON_EXTERNS = [ | 63 _COMMON_EXTERNS = [ |
| 59 CVoxPath('common/externs.js'), | 64 CVoxPath('common/externs.js'), |
| 60 CVoxPath('common/chrome_extension_externs.js'), | 65 CVoxPath('common/chrome_extension_externs.js'), |
| 61 CVoxPath('chromevox/background/externs.js'), | 66 CVoxPath('chromevox/background/externs.js'), |
| 62 CVoxPath('chromevox/injected/externs.js'), | 67 CVoxPath('chromevox/injected/externs.js'), |
| 63 CVoxPath('host/chrome/externs.js'), | 68 CVoxPath('host/chrome/externs.js'), |
| 69 _ACCESSIBILITY_PRIVATE_EXTERNS, |
| 64 _AUTOMATION_EXTERNS, | 70 _AUTOMATION_EXTERNS, |
| 65 _CHROME_EXTENSIONS_EXTERNS, | 71 _CHROME_EXTENSIONS_EXTERNS, |
| 66 _METRICS_PRIVATE_EXTERNS] | 72 _METRICS_PRIVATE_EXTERNS] |
| 67 | 73 |
| 68 # List of top-level scripts and externs that we can check. | 74 # List of top-level scripts and externs that we can check. |
| 69 _TOP_LEVEL_SCRIPTS = [ | 75 _TOP_LEVEL_SCRIPTS = [ |
| 70 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], _COMMON_EXTERNS], | 76 [[CVoxPath('chromevox/background/kbexplorer_loader.js')], _COMMON_EXTERNS], |
| 71 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], | 77 [[CVoxPath('chromevox/background/options_loader.js')], _COMMON_EXTERNS], |
| 72 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], | 78 [[CVoxPath('chromevox/injected/loader.js')], _COMMON_EXTERNS], |
| 73 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], | 79 [[CVoxPath('cvox2/background/loader.js')], _COMMON_EXTERNS], |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if len(args) > 0: | 148 if len(args) > 0: |
| 143 changed_paths = (os.path.relpath(p) for p in args) | 149 changed_paths = (os.path.relpath(p) for p in args) |
| 144 success, output = CheckChromeVox(changed_paths) | 150 success, output = CheckChromeVox(changed_paths) |
| 145 if len(output) > 0: | 151 if len(output) > 0: |
| 146 print output | 152 print output |
| 147 return int(not success) | 153 return int(not success) |
| 148 | 154 |
| 149 | 155 |
| 150 if __name__ == '__main__': | 156 if __name__ == '__main__': |
| 151 sys.exit(main()) | 157 sys.exit(main()) |
| OLD | NEW |