| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This script is used by chrome_tests.gypi's js2webui action to maintain the | 6 """This script is used by chrome_tests.gypi's js2webui action to maintain the |
| 7 argument lists and to generate inlinable tests. | 7 argument lists and to generate inlinable tests. |
| 8 | 8 |
| 9 Usage: | 9 Usage: |
| 10 python tools/gypv8sh.py v8_shell js2webui.js inputfile outputfile | 10 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \ |
| 11 inputfile outputfile |
| 11 """ | 12 """ |
| 12 | 13 |
| 13 try: | 14 try: |
| 14 import json | 15 import json |
| 15 except ImportError: | 16 except ImportError: |
| 16 import simplejson as json | 17 import simplejson as json |
| 17 import optparse | 18 import optparse |
| 18 import os | 19 import os |
| 19 import subprocess | 20 import subprocess |
| 20 import sys | 21 import sys |
| 21 | 22 |
| 22 def main (): | 23 def main (): |
| 23 parser = optparse.OptionParser() | 24 parser = optparse.OptionParser() |
| 24 parser.set_usage("%prog v8_shell js2webui.js inputfile outputfile") | 25 parser.set_usage( |
| 26 "%prog v8_shell mock.js test_api.js js2webui.js inputfile outputfile") |
| 25 parser.add_option('-v', '--verbose', action='store_true') | 27 parser.add_option('-v', '--verbose', action='store_true') |
| 26 parser.add_option('-n', '--impotent', action='store_true', | 28 parser.add_option('-n', '--impotent', action='store_true', |
| 27 help="don't execute; just print (as if verbose)") | 29 help="don't execute; just print (as if verbose)") |
| 28 (opts, args) = parser.parse_args() | 30 (opts, args) = parser.parse_args() |
| 29 | 31 |
| 30 if len(args) != 4: | 32 if len(args) != 6: |
| 31 parser.error('all arguments are required.') | 33 parser.error('all arguments are required.') |
| 32 v8_shell, js2webui, inputfile, outputfile = args | 34 v8_shell, mock_js, test_api, js2webui, inputfile, outputfile = args |
| 33 arguments = [js2webui, inputfile, os.path.basename(inputfile), outputfile] | 35 arguments = [js2webui, inputfile, os.path.basename(inputfile), outputfile] |
| 34 cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), js2webui] | 36 cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), mock_js, |
| 37 test_api, js2webui] |
| 35 if opts.verbose or opts.impotent: | 38 if opts.verbose or opts.impotent: |
| 36 print cmd | 39 print cmd |
| 37 if not opts.impotent: | 40 if not opts.impotent: |
| 38 try: | 41 try: |
| 39 subprocess.check_call(cmd, stdout=open(outputfile,'w')) | 42 subprocess.check_call(cmd, stdout=open(outputfile,'w')) |
| 40 except Exception, ex: | 43 except Exception, ex: |
| 41 print ex | 44 print ex |
| 42 os.remove(outputfile) | 45 os.remove(outputfile) |
| 43 sys.exit(1) | 46 sys.exit(1) |
| 44 | 47 |
| 45 if __name__ == '__main__': | 48 if __name__ == '__main__': |
| 46 sys.exit(main()) | 49 sys.exit(main()) |
| OLD | NEW |