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.
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
)
24 parser
= argparse
.ArgumentParser(description
= DESCRIPTION
)
25 parser
.add_argument('files', nargs
= '+', help = FILES_HELP
)
26 parser
.add_argument('--success-stamp', dest
= 'success_stamp',
28 options
= parser
.parse_args()
31 for file in options
.files
:
32 name
, extension
= os
.path
.splitext(file)
33 if extension
== '.js':
36 print >> sys
.stderr
, 'Unknown extension (' + extension
+ ') for ' + file
39 if not checkJavascript(js
):
42 if options
.success_stamp
:
43 with
open(options
.success_stamp
, 'w'):
44 os
.utime(options
.success_stamp
, None)
48 if __name__
== '__main__':