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 | 9 |
10 import json | 10 import json |
(...skipping 18 matching lines...) Expand all Loading... |
29 (opts, args) = parser.parse_args() | 29 (opts, args) = parser.parse_args() |
30 | 30 |
31 if len(args) != 9: | 31 if len(args) != 9: |
32 parser.error('all arguments are required.') | 32 parser.error('all arguments are required.') |
33 (v8_shell, mock_js, test_api, js2webui, test_type, | 33 (v8_shell, mock_js, test_api, js2webui, test_type, |
34 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args | 34 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args |
35 cmd = [v8_shell] | 35 cmd = [v8_shell] |
36 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') | 36 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') |
37 if os.path.exists(icudatafile): | 37 if os.path.exists(icudatafile): |
38 cmd.extend(['--icu-data-file=%s' % icudatafile]) | 38 cmd.extend(['--icu-data-file=%s' % icudatafile]) |
| 39 v8nativesfile = os.path.join(os.path.dirname(v8_shell), 'natives_blob.bin') |
| 40 if os.path.exists(v8nativesfile): |
| 41 cmd.extend(['--natives_blob=%s' % v8nativesfile]) |
| 42 v8snapshotfile = os.path.join(os.path.dirname(v8_shell), 'snapshot_blob.bin') |
| 43 if os.path.exists(v8snapshotfile): |
| 44 cmd.extend(['--snapshot_blob=%s' % v8snapshotfile]) |
39 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, | 45 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, |
40 cxxoutfile, test_type] | 46 cxxoutfile, test_type] |
41 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, | 47 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, |
42 test_api, js2webui]) | 48 test_api, js2webui]) |
43 if opts.verbose or opts.impotent: | 49 if opts.verbose or opts.impotent: |
44 print cmd | 50 print cmd |
45 if not opts.impotent: | 51 if not opts.impotent: |
46 try: | 52 try: |
47 p = subprocess.Popen( | 53 p = subprocess.Popen( |
48 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) | 54 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) |
49 out, err = p.communicate() | 55 out, err = p.communicate() |
50 with open(cxxoutfile, 'wb') as f: | 56 with open(cxxoutfile, 'wb') as f: |
51 f.write(out) | 57 f.write(out) |
52 shutil.copyfile(inputfile, jsoutfile) | 58 shutil.copyfile(inputfile, jsoutfile) |
53 except Exception, ex: | 59 except Exception, ex: |
54 if os.path.exists(cxxoutfile): | 60 if os.path.exists(cxxoutfile): |
55 os.remove(cxxoutfile) | 61 os.remove(cxxoutfile) |
56 if os.path.exists(jsoutfile): | 62 if os.path.exists(jsoutfile): |
57 os.remove(jsoutfile) | 63 os.remove(jsoutfile) |
58 raise | 64 raise |
59 | 65 |
60 | 66 |
61 if __name__ == '__main__': | 67 if __name__ == '__main__': |
62 sys.exit(main()) | 68 sys.exit(main()) |
OLD | NEW |