Updating trunk VERSION from 874.0 to 875.0
[chromium-blink-merge.git] / tools / gypv8sh.py
blobedb14020cae767bf2954def5acf60a09fdd70b2c
1 #!/usr/bin/env python
2 # Copyright (c) 2011 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 """This script is used by chrome_tests.gypi's js2webui action to maintain the
7 argument lists and to generate inlinable tests.
9 Usage:
10 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \
11 inputfile outputfile
12 """
14 try:
15 import json
16 except ImportError:
17 import simplejson as json
18 import optparse
19 import os
20 import subprocess
21 import sys
23 def main ():
24 parser = optparse.OptionParser()
25 parser.set_usage(
26 "%prog v8_shell mock.js test_api.js js2webui.js inputfile outputfile")
27 parser.add_option('-v', '--verbose', action='store_true')
28 parser.add_option('-n', '--impotent', action='store_true',
29 help="don't execute; just print (as if verbose)")
30 (opts, args) = parser.parse_args()
32 if len(args) != 6:
33 parser.error('all arguments are required.')
34 v8_shell, mock_js, test_api, js2webui, inputfile, outputfile = args
35 arguments = [js2webui, inputfile, os.path.basename(inputfile), outputfile]
36 cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), mock_js,
37 test_api, js2webui]
38 if opts.verbose or opts.impotent:
39 print cmd
40 if not opts.impotent:
41 try:
42 subprocess.check_call(cmd, stdout=open(outputfile,'w'))
43 except Exception, ex:
44 print ex
45 os.remove(outputfile)
46 sys.exit(1)
48 if __name__ == '__main__':
49 sys.exit(main())