Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 | |
| 9 Usage: | |
|
dmazzoni
2014/05/30 17:03:42
Removing this because the usage is below in the co
| |
| 10 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \ | |
| 11 inputfile inputrelfile cxxoutfile jsoutfile | |
| 12 """ | 8 """ |
| 13 | 9 |
| 14 import json | 10 import json |
| 15 import optparse | 11 import optparse |
| 16 import os | 12 import os |
| 17 import subprocess | 13 import subprocess |
| 18 import sys | 14 import sys |
| 19 import shutil | 15 import shutil |
| 20 | 16 |
| 21 | 17 |
| 22 def main (): | 18 def main (): |
| 23 parser = optparse.OptionParser() | 19 parser = optparse.OptionParser() |
| 24 parser.set_usage( | 20 parser.set_usage( |
| 25 "%prog v8_shell mock.js axs_testing.js test_api.js js2webui.js " | 21 "%prog v8_shell mock.js test_api.js js2webui.js " |
| 26 "testtype inputfile inputrelfile cxxoutfile jsoutfile") | 22 "testtype inputfile inputrelfile cxxoutfile jsoutfile") |
| 27 parser.add_option('-v', '--verbose', action='store_true') | 23 parser.add_option('-v', '--verbose', action='store_true') |
| 28 parser.add_option('-n', '--impotent', action='store_true', | 24 parser.add_option('-n', '--impotent', action='store_true', |
| 29 help="don't execute; just print (as if verbose)") | 25 help="don't execute; just print (as if verbose)") |
| 26 parser.add_option('--deps_js', action="store", | |
| 27 help=("Path to deps.js for dependency resolution, " + | |
| 28 "optional.")) | |
| 30 (opts, args) = parser.parse_args() | 29 (opts, args) = parser.parse_args() |
| 31 | 30 |
| 32 if len(args) != 10: | 31 if len(args) != 9: |
| 33 parser.error('all arguments are required.') | 32 parser.error('all arguments are required.') |
| 34 (v8_shell, mock_js, axs_testing_js, test_api, js2webui, test_type, | 33 (v8_shell, mock_js, test_api, js2webui, test_type, |
| 35 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args | 34 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args |
| 36 cmd = [v8_shell] | 35 cmd = [v8_shell] |
| 37 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') | 36 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') |
| 38 if os.path.exists(icudatafile): | 37 if os.path.exists(icudatafile): |
| 39 cmd.extend(['--icu-data-file=%s' % icudatafile]) | 38 cmd.extend(['--icu-data-file=%s' % icudatafile]) |
| 40 arguments = [js2webui, inputfile, inputrelfile, cxxoutfile, test_type] | 39 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, |
| 40 cxxoutfile, test_type] | |
| 41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, | 41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, |
| 42 axs_testing_js, test_api, js2webui]) | 42 test_api, js2webui]) |
| 43 if opts.verbose or opts.impotent: | 43 if opts.verbose or opts.impotent: |
| 44 print cmd | 44 print cmd |
| 45 if not opts.impotent: | 45 if not opts.impotent: |
| 46 try: | 46 try: |
| 47 with open(cxxoutfile, 'w') as f: | 47 with open(cxxoutfile, 'w') as f: |
| 48 subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f) | 48 subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f) |
| 49 shutil.copyfile(inputfile, jsoutfile) | 49 shutil.copyfile(inputfile, jsoutfile) |
| 50 except Exception, ex: | 50 except Exception, ex: |
| 51 if os.path.exists(cxxoutfile): | 51 if os.path.exists(cxxoutfile): |
| 52 # The contents of the output file will include the error message. | 52 # The contents of the output file will include the error message. |
| 53 print open(cxxoutfile).read() | 53 print open(cxxoutfile).read() |
| 54 os.remove(cxxoutfile) | 54 os.remove(cxxoutfile) |
| 55 if os.path.exists(jsoutfile): | 55 if os.path.exists(jsoutfile): |
| 56 os.remove(jsoutfile) | 56 os.remove(jsoutfile) |
| 57 raise | 57 raise |
| 58 | 58 |
| 59 | 59 |
| 60 if __name__ == '__main__': | 60 if __name__ == '__main__': |
| 61 sys.exit(main()) | 61 sys.exit(main()) |
| OLD | NEW |