blob: 918368cbbfc991799f27e9be25c43b92888db4f2 [file] [log] [blame]
[email protected]982899492011-07-01 20:46:171#!/usr/bin/env python
[email protected]4f6b1db02012-05-18 18:15:192# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]982899492011-07-01 20:46:173# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""This script is used by chrome_tests.gypi's js2webui action to maintain the
7argument lists and to generate inlinable tests.
8
9Usage:
[email protected]bf8feaa2011-07-12 00:17:3610 python tools/gypv8sh.py v8_shell mock.js test_api.js js2webui.js \
[email protected]4ba1dbc2011-10-22 01:46:0311 inputfile inputrelfile cxxoutfile jsoutfile
[email protected]982899492011-07-01 20:46:1712"""
13
[email protected]4f6b1db02012-05-18 18:15:1914import json
[email protected]982899492011-07-01 20:46:1715import optparse
16import os
17import subprocess
18import sys
[email protected]4ba1dbc2011-10-22 01:46:0319import shutil
[email protected]982899492011-07-01 20:46:1720
[email protected]4f6b1db02012-05-18 18:15:1921
[email protected]982899492011-07-01 20:46:1722def main ():
23 parser = optparse.OptionParser()
[email protected]bf8feaa2011-07-12 00:17:3624 parser.set_usage(
[email protected]805dfc4a2013-01-17 23:08:3825 "%prog v8_shell mock.js axs_testing.js test_api.js js2webui.js "
[email protected]26d47582011-11-05 04:24:2026 "testtype inputfile inputrelfile cxxoutfile jsoutfile")
[email protected]982899492011-07-01 20:46:1727 parser.add_option('-v', '--verbose', action='store_true')
28 parser.add_option('-n', '--impotent', action='store_true',
29 help="don't execute; just print (as if verbose)")
30 (opts, args) = parser.parse_args()
31
[email protected]805dfc4a2013-01-17 23:08:3832 if len(args) != 10:
[email protected]982899492011-07-01 20:46:1733 parser.error('all arguments are required.')
[email protected]805dfc4a2013-01-17 23:08:3834 (v8_shell, mock_js, axs_testing_js, test_api, js2webui, test_type,
[email protected]26d47582011-11-05 04:24:2035 inputfile, inputrelfile, cxxoutfile, jsoutfile) = args
36 arguments = [js2webui, inputfile, inputrelfile, cxxoutfile, test_type]
[email protected]bf8feaa2011-07-12 00:17:3637 cmd = [v8_shell, '-e', "arguments=" + json.dumps(arguments), mock_js,
[email protected]805dfc4a2013-01-17 23:08:3838 axs_testing_js, test_api, js2webui]
[email protected]982899492011-07-01 20:46:1739 if opts.verbose or opts.impotent:
40 print cmd
41 if not opts.impotent:
42 try:
[email protected]4f6b1db02012-05-18 18:15:1943 with open(cxxoutfile, 'w') as f:
44 subprocess.check_call(cmd, stdin=subprocess.PIPE, stdout=f)
[email protected]4ba1dbc2011-10-22 01:46:0345 shutil.copyfile(inputfile, jsoutfile)
[email protected]982899492011-07-01 20:46:1746 except Exception, ex:
[email protected]4f6b1db02012-05-18 18:15:1947 if os.path.exists(cxxoutfile):
48 os.remove(cxxoutfile)
49 if os.path.exists(jsoutfile):
50 os.remove(jsoutfile)
51 raise
52
[email protected]982899492011-07-01 20:46:1753
54if __name__ == '__main__':
55 sys.exit(main())