| 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 braille ime.''' | 7 '''Uses the closure compiler to check the braille ime.''' |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 match = re.search(r'version "(?:\d+)\.(\d+)', output) | 53 match = re.search(r'version "(?:\d+)\.(\d+)', output) |
| 54 if match is None or int(match.group(1)) < 7: | 54 if match is None or int(match.group(1)) < 7: |
| 55 _error('Java 7 or later is required: \n%s' % output) | 55 _error('Java 7 or later is required: \n%s' % output) |
| 56 | 56 |
| 57 | 57 |
| 58 def _run_closure_compiler(): | 58 def _run_closure_compiler(): |
| 59 print 'Compiling Braille IME.' | 59 print 'Compiling Braille IME.' |
| 60 args = [_java_executable, '-jar', _CLOSURE_COMPILER_JAR] | 60 args = [_java_executable, '-jar', _CLOSURE_COMPILER_JAR] |
| 61 args.extend(['--compilation_level', 'SIMPLE_OPTIMIZATIONS']) | 61 args.extend(['--compilation_level', 'SIMPLE_OPTIMIZATIONS']) |
| 62 args.extend(['--jscomp_error=%s' % error for error in _JSCOMP_ERRORS]) | 62 args.extend(['--jscomp_error=%s' % error for error in _JSCOMP_ERRORS]) |
| 63 args.extend(['--externs', 'externs.js']) | 63 args.extend(['--externs', os.path.join(_SCRIPT_DIR, 'externs.js')]) |
| 64 args.extend(['--js', 'braille_ime.js']) | 64 args.extend(['--js', os.path.join(_SCRIPT_DIR, 'braille_ime.js')]) |
| 65 args.extend(['--js', 'main.js']) | 65 args.extend(['--js', os.path.join(_SCRIPT_DIR, 'main.js')]) |
| 66 args.extend(['--js_output_file', '/dev/null']) | 66 args.extend(['--js_output_file', '/dev/null']) |
| 67 output = _execute_command(args, ignore_exit_status=True) | 67 output = _execute_command(args, ignore_exit_status=True) |
| 68 success = len(output) == 0 | 68 success = len(output) == 0 |
| 69 return success, output | 69 return success, output |
| 70 | 70 |
| 71 | 71 |
| 72 def check_braille_ime(): | 72 def check_braille_ime(): |
| 73 _check_java() | 73 _check_java() |
| 74 return _run_closure_compiler() | 74 return _run_closure_compiler() |
| 75 | 75 |
| 76 | 76 |
| 77 def main(argv): | 77 def main(argv): |
| 78 success, output = check_braille_ime() | 78 success, output = check_braille_ime() |
| 79 print output | 79 print output |
| 80 return int(not success) | 80 return int(not success) |
| 81 | 81 |
| 82 | 82 |
| 83 if __name__ == '__main__': | 83 if __name__ == '__main__': |
| 84 sys.exit(main(sys.argv)) | 84 sys.exit(main(sys.argv)) |
| OLD | NEW |