| 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 syntax and semantics of a js module | 7 '''Uses the closure compiler to check syntax and semantics of a js module |
| 8 with dependencies.''' | 8 with dependencies.''' |
| 9 | 9 |
| 10 import os | 10 import os |
| 11 import re | 11 import re |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 16 _CHROME_SOURCE_DIR = os.path.normpath( | 16 _CHROME_SOURCE_DIR = os.path.normpath( |
| 17 os.path.join( | 17 os.path.join( |
| 18 _SCRIPT_DIR, *[os.path.pardir] * 6)) | 18 _SCRIPT_DIR, *[os.path.pardir] * 6)) |
| 19 | 19 |
| 20 # Compiler path. | 20 # Compiler path. |
| 21 _CLOSURE_COMPILER_JAR = os.path.join( | 21 _CLOSURE_COMPILER_JAR = os.path.join( |
| 22 _CHROME_SOURCE_DIR, 'third_party', 'WebKit', 'Source', 'devtools', | 22 _CHROME_SOURCE_DIR, 'third_party', 'closure_compiler', 'compiler', |
| 23 'scripts', 'closure', 'compiler.jar') | 23 'compiler.jar') |
| 24 | 24 |
| 25 # List of compilation errors to enable with the --jscomp_errors flag. | 25 # List of compilation errors to enable with the --jscomp_errors flag. |
| 26 _JSCOMP_ERRORS = [ 'accessControls', 'checkTypes', 'checkVars', 'invalidCasts', | 26 _JSCOMP_ERRORS = [ 'accessControls', 'checkTypes', 'checkVars', 'invalidCasts', |
| 27 'missingProperties', 'undefinedNames', 'undefinedVars', | 27 'missingProperties', 'undefinedNames', 'undefinedVars', |
| 28 'visibility' ] | 28 'visibility' ] |
| 29 | 29 |
| 30 _java_executable = 'java' | 30 _java_executable = 'java' |
| 31 | 31 |
| 32 | 32 |
| 33 def _Error(msg): | 33 def _Error(msg): |
| (...skipping 29 matching lines...) Expand all Loading... |
| 63 def RunCompiler(js_files, externs=[]): | 63 def RunCompiler(js_files, externs=[]): |
| 64 args = [_java_executable, '-jar', _CLOSURE_COMPILER_JAR] | 64 args = [_java_executable, '-jar', _CLOSURE_COMPILER_JAR] |
| 65 args.extend(['--compilation_level', 'SIMPLE_OPTIMIZATIONS']) | 65 args.extend(['--compilation_level', 'SIMPLE_OPTIMIZATIONS']) |
| 66 args.extend(['--jscomp_error=%s' % error for error in _JSCOMP_ERRORS]) | 66 args.extend(['--jscomp_error=%s' % error for error in _JSCOMP_ERRORS]) |
| 67 args.extend(['--externs=%s' % extern for extern in externs]) | 67 args.extend(['--externs=%s' % extern for extern in externs]) |
| 68 args.extend(['--js=%s' % js for js in js_files]) | 68 args.extend(['--js=%s' % js for js in js_files]) |
| 69 args.extend(['--js_output_file', '/dev/null']) | 69 args.extend(['--js_output_file', '/dev/null']) |
| 70 output = _ExecuteCommand(args, ignore_exit_status=True) | 70 output = _ExecuteCommand(args, ignore_exit_status=True) |
| 71 success = len(output) == 0 | 71 success = len(output) == 0 |
| 72 return success, output | 72 return success, output |
| OLD | NEW |