Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: Source/bindings/scripts/generate_init_partial_interfaces.py

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 initialize .cpp file for modules' partial interfaces of core interfa ces.
haraken 2014/10/16 04:24:08 Generate initPartialInterfacesInModules(), which r
tasak 2014/10/17 07:38:17 Done.
7 """
8
9 import cPickle as pickle
10 from optparse import OptionParser
11 import os
12 import posixpath
13 import sys
14 from utilities import write_file
15
16 from aggregate_generated_bindings import extract_meta_data
17 from utilities import read_idl_files_list_from_file
18
19
20 _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.
21 // Use of this source code is governed by a BSD-style license that can be
22 // found in the LICENSE file.
23
24 """
25
26 _INIT_PARTIAL_INTERFACE = """%s
27 #include "config.h"
28
29 %s
30
31 namespace blink {
32
33 void initModulesPartialInterfaces()
34 {
35 %s
36 }
37
38 } // namespace blink
39 """
40
41
42 def parse_options():
43 usage = 'Usage: %prog [options]'
44 parser = OptionParser(usage=usage)
45 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.")
46 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')
47 parser.add_option('--output')
48 # 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.
49 parser.disable_interspersed_args()
50
51 options, args = parser.parse_args()
52 if options.output is None:
53 parser.error('Must specify output file using --output.')
54 if options.idl_files_list is None:
55 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.
56 if options.write_file_only_if_changed is None:
57 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
58 options.write_file_only_if_changed = bool(options.write_file_only_if_changed )
59 return options
60
61
62 def main():
63 options = parse_options()
64
65 idl_file_names = read_idl_files_list_from_file(options.idl_files_list)
66
67 meta_data_list = extract_meta_data(idl_file_names)
68 interface_names = ['V8%sPartial' % meta_data['name']
69 for meta_data in meta_data_list]
70 interface_names.sort()
71
72 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name
73 for interface_name in interface_names]
74 initialize_calls = [' %s::initialize();' % interface_name
75 for interface_name in interface_names]
76
77 content = _INIT_PARTIAL_INTERFACE % (
78 _COPYRIGHT,
79 '\n'.join(includes),
80 '\n'.join(initialize_calls))
81
82 write_file(content, options.output,
83 only_if_changed=options.write_file_only_if_changed)
84
85
86 if __name__ == '__main__':
87 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698