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
4 # found in the LICENSE file.
10 # Note: some of these files are imported to register cmdline options.
11 from idl_generator
import Generator
12 from idl_option
import ParseOptions
13 from idl_outfile
import IDLOutFile
14 from idl_parser
import ParseFiles
15 from idl_c_header
import HGen
16 from idl_thunk
import TGen
17 from idl_gen_pnacl
import PnaclGen
21 # If no arguments are provided, assume we are trying to rebuild the
22 # C headers with warnings off.
26 '--wnone', '--cgen', '--range=start,end',
27 '--pnacl', '--pnaclshim',
28 '../native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c',
31 current_dir
= os
.path
.abspath(os
.getcwd())
32 script_dir
= os
.path
.abspath(os
.path
.dirname(__file__
))
33 if current_dir
!= script_dir
:
34 print '\nIncorrect CWD, default run skipped.'
35 print 'When running with no arguments set CWD to the scripts directory:'
36 print '\t' + script_dir
+ '\n'
37 print 'This ensures correct default paths and behavior.\n'
40 filenames
= ParseOptions(args
)
41 ast
= ParseFiles(filenames
)
43 print 'Found %d errors. Aborting build.\n' % ast
.errors
45 return Generator
.Run(ast
)
46 except SystemExit, ec
:
47 print 'Exiting with %d' % ec
.code
51 typeinfo
, value
, tb
= sys
.exc_info()
52 traceback
.print_exception(typeinfo
, value
, tb
)
53 print 'Called with: ' + ' '.join(sys
.argv
)
56 if __name__
== '__main__':
57 sys
.exit(Main(sys
.argv
[1:]))