| 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 import os |
| 6 import sys | 7 import sys |
| 7 | 8 |
| 8 # Note: some of these files are imported to register cmdline options. | 9 # Note: some of these files are imported to register cmdline options. |
| 9 from idl_generator import Generator | 10 from idl_generator import Generator |
| 10 from idl_option import ParseOptions | 11 from idl_option import ParseOptions |
| 11 from idl_outfile import IDLOutFile | 12 from idl_outfile import IDLOutFile |
| 12 from idl_parser import ParseFiles | 13 from idl_parser import ParseFiles |
| 13 from idl_c_header import HGen | 14 from idl_c_header import HGen |
| 14 from idl_gen_pnacl import PnaclGen | 15 from idl_gen_pnacl import PnaclGen |
| 15 | 16 |
| 16 | 17 |
| 17 def Main(): | 18 def Main(): |
| 18 args = sys.argv[1:] | 19 args = sys.argv[1:] |
| 19 # If no arguments are provided, assume we are tring to rebuild the | 20 # If no arguments are provided, assume we are trying to rebuild the |
| 20 # C headers with warnings off. | 21 # C headers with warnings off. |
| 21 if not args: | 22 if not args: |
| 22 args = ['--wnone', '--cgen', '--range=start,end'] | 23 args = ['--wnone', '--cgen', '--range=start,end'] |
| 24 current_dir = os.path.abspath(os.getcwd()) |
| 25 script_dir = os.path.abspath(os.path.dirname(__file__)) |
| 26 if current_dir != script_dir: |
| 27 print '\nIncorrect CWD, default run skipped.' |
| 28 print 'When running with no arguments set CWD to the scripts directory:' |
| 29 print '\t' + script_dir + '\n' |
| 30 print 'This ensures correct default paths and behavior.\n' |
| 31 return 1 |
| 23 | 32 |
| 24 filenames = ParseOptions(args) | 33 filenames = ParseOptions(args) |
| 25 ast = ParseFiles(filenames) | 34 ast = ParseFiles(filenames) |
| 26 return Generator.Run(ast) | 35 return Generator.Run(ast) |
| 27 | 36 |
| 28 | 37 |
| 29 if __name__ == '__main__': | 38 if __name__ == '__main__': |
| 30 sys.exit(Main()) | 39 sys.exit(Main()) |
| OLD | NEW |