Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: ppapi/generators/generator.py

Issue 11417010: Add support for generating thunk source from IDL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed dmichael's comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import os 6 import os
7 import sys 7 import sys
8 import traceback 8 import traceback
9 9
10 # Note: some of these files are imported to register cmdline options. 10 # Note: some of these files are imported to register cmdline options.
11 from idl_generator import Generator 11 from idl_generator import Generator
12 from idl_option import ParseOptions 12 from idl_option import ParseOptions
13 from idl_outfile import IDLOutFile 13 from idl_outfile import IDLOutFile
14 from idl_parser import ParseFiles 14 from idl_parser import ParseFiles
15 from idl_c_header import HGen 15 from idl_c_header import HGen
16 from idl_thunk import TGen
16 from idl_gen_pnacl import PnaclGen 17 from idl_gen_pnacl import PnaclGen
17 18
18 19
19 def Main(args): 20 def Main(args):
20 # If no arguments are provided, assume we are trying to rebuild the 21 # If no arguments are provided, assume we are trying to rebuild the
21 # C headers with warnings off. 22 # C headers with warnings off.
22 try: 23 try:
23 if not args: 24 if not args:
24 args = [ 25 args = [
25 '--wnone', '--cgen', '--range=start,end', 26 '--wnone', '--cgen', '--range=start,end',
26 '--pnacl', '--pnaclshim', 27 '--pnacl', '--pnaclshim',
27 '../native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c', 28 '../native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c',
29 '--tgen',
28 ] 30 ]
29 current_dir = os.path.abspath(os.getcwd()) 31 current_dir = os.path.abspath(os.getcwd())
30 script_dir = os.path.abspath(os.path.dirname(__file__)) 32 script_dir = os.path.abspath(os.path.dirname(__file__))
31 if current_dir != script_dir: 33 if current_dir != script_dir:
32 print '\nIncorrect CWD, default run skipped.' 34 print '\nIncorrect CWD, default run skipped.'
33 print 'When running with no arguments set CWD to the scripts directory:' 35 print 'When running with no arguments set CWD to the scripts directory:'
34 print '\t' + script_dir + '\n' 36 print '\t' + script_dir + '\n'
35 print 'This ensures correct default paths and behavior.\n' 37 print 'This ensures correct default paths and behavior.\n'
36 return 1 38 return 1
37 39
38 filenames = ParseOptions(args) 40 filenames = ParseOptions(args)
39 ast = ParseFiles(filenames) 41 ast = ParseFiles(filenames)
40 if ast.errors: 42 if ast.errors:
41 print 'Found %d errors. Aborting build.\n' % ast.errors 43 print 'Found %d errors. Aborting build.\n' % ast.errors
42 return 1 44 return 1
43 return Generator.Run(ast) 45 return Generator.Run(ast)
44 except SystemExit, ec: 46 except SystemExit, ec:
45 print 'Exiting with %d' % ec.code 47 print 'Exiting with %d' % ec.code
46 sys.exit(ec.code) 48 sys.exit(ec.code)
47 49
48 except: 50 except:
49 typeinfo, value, tb = sys.exc_info() 51 typeinfo, value, tb = sys.exc_info()
50 traceback.print_exception(typeinfo, value, tb) 52 traceback.print_exception(typeinfo, value, tb)
51 print 'Called with: ' + ' '.join(sys.argv) 53 print 'Called with: ' + ' '.join(sys.argv)
52 54
53 55
54 if __name__ == '__main__': 56 if __name__ == '__main__':
55 sys.exit(Main(sys.argv[1:])) 57 sys.exit(Main(sys.argv[1:]))
56
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698