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

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

Issue 2325583002: Revert of [Bindings] Remove aggregation of generated binding code (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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 get_file_contents 13 from utilities import write_file
14 from utilities import idl_filename_to_interface_name 14
15 from aggregate_generated_bindings import extract_meta_data
15 from utilities import read_idl_files_list_from_file 16 from utilities import read_idl_files_list_from_file
16 from utilities import should_generate_impl_file_from_idl
17 from utilities import write_file
18 17
19 18
20 _COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved. 19 _COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved.
21 // 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
22 // found in the LICENSE file. 21 // found in the LICENSE file.
23 22
24 """ 23 """
25 24
26 _INIT_PARTIAL_INTERFACE = """%s 25 _INIT_PARTIAL_INTERFACE = """%s
27 %s 26 %s
(...skipping 21 matching lines...) Expand all
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 extract_meta_data(file_paths):
60 """Extracts interface name from each IDL file."""
61 meta_data_list = []
62
63 for file_path in file_paths:
64 if not file_path.endswith('.idl'):
65 print 'WARNING: non-IDL file passed: "%s"' % file_path
66 continue
67 if not os.path.exists(file_path):
68 print 'WARNING: file not found: "%s"' % file_path
69 continue
70
71 idl_file_contents = get_file_contents(file_path)
72 if not should_generate_impl_file_from_idl(idl_file_contents):
73 continue
74
75 # Extract interface name from file name
76 interface_name = idl_filename_to_interface_name(file_path)
77
78 meta_data = {
79 'name': interface_name,
80 }
81 meta_data_list.append(meta_data)
82
83 return meta_data_list
84
85
86 def main(): 58 def main():
87 options = parse_options() 59 options = parse_options()
88 60
89 idl_file_names = read_idl_files_list_from_file(options.idl_files_list, is_gy p_format=options.gyp_format_list) 61 idl_file_names = read_idl_files_list_from_file(options.idl_files_list, is_gy p_format=options.gyp_format_list)
90 62
91 meta_data_list = extract_meta_data(idl_file_names) 63 meta_data_list = extract_meta_data(idl_file_names)
92 interface_names = ['V8%sPartial' % meta_data['name'] 64 interface_names = ['V8%sPartial' % meta_data['name']
93 for meta_data in meta_data_list] 65 for meta_data in meta_data_list]
94 interface_names.sort() 66 interface_names.sort()
95 67
96 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name 68 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name
97 for interface_name in interface_names] 69 for interface_name in interface_names]
98 initialize_calls = [' %s::initialize();' % interface_name 70 initialize_calls = [' %s::initialize();' % interface_name
99 for interface_name in interface_names] 71 for interface_name in interface_names]
100 72
101 content = _INIT_PARTIAL_INTERFACE % ( 73 content = _INIT_PARTIAL_INTERFACE % (
102 _COPYRIGHT, 74 _COPYRIGHT,
103 '\n'.join(includes), 75 '\n'.join(includes),
104 '\n'.join(initialize_calls)) 76 '\n'.join(initialize_calls))
105 77
106 write_file(content, options.output, 78 write_file(content, options.output,
107 only_if_changed=options.write_file_only_if_changed) 79 only_if_changed=options.write_file_only_if_changed)
108 80
109 81
110 if __name__ == '__main__': 82 if __name__ == '__main__':
111 sys.exit(main()) 83 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698