Chromium Code Reviews| Index: Source/bindings/scripts/generate_init_partial_interfaces.py |
| diff --git a/Source/bindings/scripts/generate_init_partial_interfaces.py b/Source/bindings/scripts/generate_init_partial_interfaces.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..298e391e2161d0640361c12d0d5f10b80e3b9d64 |
| --- /dev/null |
| +++ b/Source/bindings/scripts/generate_init_partial_interfaces.py |
| @@ -0,0 +1,87 @@ |
| +#!/usr/bin/python |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Generate initialize .cpp file for modules' partial interfaces of core interfaces. |
|
haraken
2014/10/16 04:24:08
Generate initPartialInterfacesInModules(), which r
tasak
2014/10/17 07:38:17
Done.
|
| +""" |
| + |
| +import cPickle as pickle |
| +from optparse import OptionParser |
| +import os |
| +import posixpath |
| +import sys |
| +from utilities import write_file |
| + |
| +from aggregate_generated_bindings import extract_meta_data |
| +from utilities import read_idl_files_list_from_file |
| + |
| + |
| +_COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved. |
|
haraken
2014/10/16 04:24:08
Consider using a jinja template for this. You can
tasak
2014/10/17 07:38:17
I will try this in another CL.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +""" |
| + |
| +_INIT_PARTIAL_INTERFACE = """%s |
| +#include "config.h" |
| + |
| +%s |
| + |
| +namespace blink { |
| + |
| +void initModulesPartialInterfaces() |
| +{ |
| +%s |
| +} |
| + |
| +} // namespace blink |
| +""" |
| + |
| + |
| +def parse_options(): |
| + usage = 'Usage: %prog [options]' |
| + parser = OptionParser(usage=usage) |
| + parser.add_option('--idl-files-list', help="a text file containing the IDL file paths, so the command line doesn't exceed OS length limits.") |
| + 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') |
| + parser.add_option('--output') |
| + # ensure output comes last, so command line easy to parse via regexes |
|
haraken
2014/10/16 04:24:08
Is this comment still valid?
tasak
2014/10/17 07:38:17
Done.
|
| + parser.disable_interspersed_args() |
| + |
| + options, args = parser.parse_args() |
| + if options.output is None: |
| + parser.error('Must specify output file using --output.') |
| + if options.idl_files_list is None: |
| + parser.error('Must specify idl files list file using --idl-files-list.') |
|
haraken
2014/10/16 04:24:07
Must specify a list of IDL files using --idl-files
tasak
2014/10/17 07:38:17
Done.
|
| + if options.write_file_only_if_changed is None: |
| + parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.') |
| + options.write_file_only_if_changed = bool(options.write_file_only_if_changed) |
| + return options |
| + |
| + |
| +def main(): |
| + options = parse_options() |
| + |
| + idl_file_names = read_idl_files_list_from_file(options.idl_files_list) |
| + |
| + meta_data_list = extract_meta_data(idl_file_names) |
| + interface_names = ['V8%sPartial' % meta_data['name'] |
| + for meta_data in meta_data_list] |
| + interface_names.sort() |
| + |
| + includes = ['#include "bindings/modules/v8/%s.h"' % interface_name |
| + for interface_name in interface_names] |
| + initialize_calls = [' %s::initialize();' % interface_name |
| + for interface_name in interface_names] |
| + |
| + content = _INIT_PARTIAL_INTERFACE % ( |
| + _COPYRIGHT, |
| + '\n'.join(includes), |
| + '\n'.join(initialize_calls)) |
| + |
| + write_file(content, options.output, |
| + only_if_changed=options.write_file_only_if_changed) |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |