OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import argparse |
| 7 import subprocess |
| 8 import sys |
| 9 import os |
| 10 |
| 11 DESCRIPTION = '''Run the given JavaScript files through jscompile.''' |
| 12 FILES_HELP = '''A list of Javascript files. The Javascript files should include |
| 13 files that contain definitions of types or functions that are known to Chrome |
| 14 but not to jscompile.''' |
| 15 STAMP_HELP = 'Timestamp file to update on success.' |
| 16 |
| 17 def checkJavascript(js_files): |
| 18 args = ['jscompile'] + js_files |
| 19 result = subprocess.call(args) |
| 20 return result == 0 |
| 21 |
| 22 |
| 23 def main(): |
| 24 parser = argparse.ArgumentParser(description = DESCRIPTION) |
| 25 parser.add_argument('files', nargs = '+', help = FILES_HELP) |
| 26 parser.add_argument('--success-stamp', dest = 'success_stamp', |
| 27 help = STAMP_HELP) |
| 28 options = parser.parse_args() |
| 29 |
| 30 js = [] |
| 31 for file in options.files: |
| 32 name, extension = os.path.splitext(file) |
| 33 if extension == '.js': |
| 34 js.append(file) |
| 35 else: |
| 36 print >> sys.stderr, 'Unknown extension (' + extension + ') for ' + file |
| 37 return 1 |
| 38 |
| 39 if not checkJavascript(js): |
| 40 return 1 |
| 41 |
| 42 if options.success_stamp: |
| 43 with open(options.success_stamp, 'w'): |
| 44 os.utime(options.success_stamp, None) |
| 45 |
| 46 return 0 |
| 47 |
| 48 if __name__ == '__main__': |
| 49 sys.exit(main()) |
OLD | NEW |