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