OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright 2014 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. |
| 5 |
| 6 """Generate initPartialInterfacesInModules(), which registers partial interfaces
in modules to core interfaces.""" |
| 7 |
| 8 import cPickle as pickle |
| 9 from optparse import OptionParser |
| 10 import os |
| 11 import posixpath |
| 12 import sys |
| 13 from utilities import write_file |
| 14 |
| 15 from aggregate_generated_bindings import extract_meta_data |
| 16 from utilities import read_idl_files_list_from_file |
| 17 |
| 18 |
| 19 _COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved. |
| 20 // Use of this source code is governed by a BSD-style license that can be |
| 21 // found in the LICENSE file. |
| 22 |
| 23 """ |
| 24 |
| 25 _INIT_PARTIAL_INTERFACE = """%s |
| 26 #include "config.h" |
| 27 |
| 28 %s |
| 29 |
| 30 namespace blink { |
| 31 |
| 32 void initPartialInterfacesInModules() |
| 33 { |
| 34 %s |
| 35 } |
| 36 |
| 37 } // namespace blink |
| 38 """ |
| 39 |
| 40 |
| 41 def parse_options(): |
| 42 usage = 'Usage: %prog [options]' |
| 43 parser = OptionParser(usage=usage) |
| 44 parser.add_option('--idl-files-list', help="a text file containing the IDL f
ile paths, so the command line doesn't exceed OS length limits.") |
| 45 parser.add_option('--write-file-only-if-changed', type='int', help='if true,
do not write an output file if it would be identical to the existing one, which
avoids unnecessary rebuilds in ninja') |
| 46 parser.add_option('--output') |
| 47 |
| 48 options, args = parser.parse_args() |
| 49 if options.output is None: |
| 50 parser.error('Must specify output file using --output.') |
| 51 if options.idl_files_list is None: |
| 52 parser.error('Must specify a list of IDL files using --idl-files-list.') |
| 53 if options.write_file_only_if_changed is None: |
| 54 parser.error('Must specify whether file is only written if changed using
--write-file-only-if-changed.') |
| 55 options.write_file_only_if_changed = bool(options.write_file_only_if_changed
) |
| 56 return options |
| 57 |
| 58 |
| 59 def main(): |
| 60 options = parse_options() |
| 61 |
| 62 idl_file_names = read_idl_files_list_from_file(options.idl_files_list) |
| 63 |
| 64 meta_data_list = extract_meta_data(idl_file_names) |
| 65 interface_names = ['V8%sPartial' % meta_data['name'] |
| 66 for meta_data in meta_data_list] |
| 67 interface_names.sort() |
| 68 |
| 69 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name |
| 70 for interface_name in interface_names] |
| 71 initialize_calls = [' %s::initialize();' % interface_name |
| 72 for interface_name in interface_names] |
| 73 |
| 74 content = _INIT_PARTIAL_INTERFACE % ( |
| 75 _COPYRIGHT, |
| 76 '\n'.join(includes), |
| 77 '\n'.join(initialize_calls)) |
| 78 |
| 79 write_file(content, options.output, |
| 80 only_if_changed=options.write_file_only_if_changed) |
| 81 |
| 82 |
| 83 if __name__ == '__main__': |
| 84 sys.exit(main()) |
OLD | NEW |