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