Roll src/third_party/WebKit 3529d49:06e8485 (svn 202554:202555)
[chromium-blink-merge.git] / remoting / tools / jscompile.py
blob0f06964696e185b1dbdd63af960091233f4b40b0
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.
6 import argparse
7 import subprocess
8 import sys
9 import os
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.'
17 def checkJavascript(js_files):
18 args = ['jscompile'] + js_files
19 result = subprocess.call(args)
20 return result == 0
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()
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
39 if not checkJavascript(js):
40 return 1
42 if options.success_stamp:
43 with open(options.success_stamp, 'w'):
44 os.utime(options.success_stamp, None)
46 return 0
48 if __name__ == '__main__':
49 sys.exit(main())