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 27 matching lines...) Expand all Loading... |
38 "optional.")) | 38 "optional.")) |
39 parser.add_option('--external', action='store', | 39 parser.add_option('--external', action='store', |
40 help="Load V8's initial snapshot from external files (y/n)") | 40 help="Load V8's initial snapshot from external files (y/n)") |
41 (opts, args) = parser.parse_args() | 41 (opts, args) = parser.parse_args() |
42 | 42 |
43 if len(args) != 9: | 43 if len(args) != 9: |
44 parser.error('all arguments are required.') | 44 parser.error('all arguments are required.') |
45 (v8_shell, mock_js, test_api, js2webui, test_type, | 45 (v8_shell, mock_js, test_api, js2webui, test_type, |
46 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args | 46 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args |
47 cmd = [v8_shell] | 47 cmd = [v8_shell] |
48 icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat') | |
49 if os.path.exists(icudatafile): | |
50 cmd.extend(['--icu-data-file=%s' % icudatafile]) | |
51 v8nativesfile = os.path.join(os.path.dirname(v8_shell), 'natives_blob.bin') | |
52 if opts.external == 'y' and os.path.exists(v8nativesfile): | |
53 cmd.extend(['--natives_blob=%s' % v8nativesfile]) | |
54 v8snapshotfile = os.path.join(os.path.dirname(v8_shell), 'snapshot_blob.bin') | |
55 if opts.external == 'y' and os.path.exists(v8snapshotfile): | |
56 cmd.extend(['--snapshot_blob=%s' % v8snapshotfile]) | |
57 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, | 48 arguments = [js2webui, inputfile, inputrelfile, opts.deps_js, |
58 cxxoutfile, test_type] | 49 cxxoutfile, test_type] |
59 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, | 50 cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js, |
60 test_api, js2webui]) | 51 test_api, js2webui]) |
61 if opts.verbose or opts.impotent: | 52 if opts.verbose or opts.impotent: |
62 print cmd | 53 print cmd |
63 if not opts.impotent: | 54 if not opts.impotent: |
64 try: | 55 try: |
65 p = subprocess.Popen( | 56 p = subprocess.Popen( |
66 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) | 57 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) |
67 out, err = p.communicate() | 58 out, err = p.communicate() |
68 if p.returncode != 0: | 59 if p.returncode != 0: |
69 sys.stderr.write(out + err); | 60 sys.stderr.write(out + err); |
70 return 1 | 61 return 1 |
71 if not HasSameContent(cxxoutfile, out): | 62 if not HasSameContent(cxxoutfile, out): |
72 with open(cxxoutfile, 'wb') as f: | 63 with open(cxxoutfile, 'wb') as f: |
73 f.write(out) | 64 f.write(out) |
74 shutil.copyfile(inputfile, jsoutfile) | 65 shutil.copyfile(inputfile, jsoutfile) |
75 except Exception, ex: | 66 except Exception, ex: |
76 if os.path.exists(cxxoutfile): | 67 if os.path.exists(cxxoutfile): |
77 os.remove(cxxoutfile) | 68 os.remove(cxxoutfile) |
78 if os.path.exists(jsoutfile): | 69 if os.path.exists(jsoutfile): |
79 os.remove(jsoutfile) | 70 os.remove(jsoutfile) |
80 raise | 71 raise |
81 | 72 |
82 | 73 |
83 if __name__ == '__main__': | 74 if __name__ == '__main__': |
84 sys.exit(main()) | 75 sys.exit(main()) |
OLD | NEW |