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 | 8 |
9 Usage: | 9 Usage: |
10 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \ | 10 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \ |
(...skipping 15 matching lines...) Expand all Loading... |
26 "testtype inputfile inputrelfile cxxoutfile jsoutfile") | 26 "testtype inputfile inputrelfile cxxoutfile jsoutfile") |
27 parser.add_option('-v', '--verbose', action='store_true') | 27 parser.add_option('-v', '--verbose', action='store_true') |
28 parser.add_option('-n', '--impotent', action='store_true', | 28 parser.add_option('-n', '--impotent', action='store_true', |
29 help="don't execute; just print (as if verbose)") | 29 help="don't execute; just print (as if verbose)") |
30 (opts, args) = parser.parse_args() | 30 (opts, args) = parser.parse_args() |
31 | 31 |
32 if len(args) != 10: | 32 if len(args) != 10: |
33 parser.error('all arguments are required.') | 33 parser.error('all arguments are required.') |
34 (v8_shell, mock_js, axs_testing_js, test_api, js2webui, test_type, | 34 (v8_shell, mock_js, axs_testing_js, test_api, js2webui, test_type, |
35 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args | 35 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args |
| 36 cmd = [v8_shell] |
| 37 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') |
| 38 if os.path.exists(icudatafile): |
| 39 cmd.extend(['--icu-data-file=%s' % icudatafile]) |
36 arguments = [js2webui, inputfile, inputrelfile, cxxoutfile, test_type] | 40 arguments = [js2webui, inputfile, inputrelfile, cxxoutfile, test_type] |
37 cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), mock_js, | 41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, |
38 axs_testing_js, test_api, js2webui] | 42 axs_testing_js, test_api, js2webui]) |
39 if opts.verbose or opts.impotent: | 43 if opts.verbose or opts.impotent: |
40 print cmd | 44 print cmd |
41 if not opts.impotent: | 45 if not opts.impotent: |
42 try: | 46 try: |
43 with open(cxxoutfile, 'w') as f: | 47 with open(cxxoutfile, 'w') as f: |
44 subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f) | 48 subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f) |
45 shutil.copyfile(inputfile, jsoutfile) | 49 shutil.copyfile(inputfile, jsoutfile) |
46 except Exception, ex: | 50 except Exception, ex: |
47 if os.path.exists(cxxoutfile): | 51 if os.path.exists(cxxoutfile): |
48 os.remove(cxxoutfile) | 52 os.remove(cxxoutfile) |
49 if os.path.exists(jsoutfile): | 53 if os.path.exists(jsoutfile): |
50 os.remove(jsoutfile) | 54 os.remove(jsoutfile) |
51 raise | 55 raise |
52 | 56 |
53 | 57 |
54 if __name__ == '__main__': | 58 if __name__ == '__main__': |
55 sys.exit(main()) | 59 sys.exit(main()) |
OLD | NEW |