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

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

Issue 2318933002: [Bindings] Remove aggregation of generated binding code (Closed)
Patch Set: Fix import order 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
14 from utilities import idl_filename_to_interface_name
15 from utilities import read_idl_files_list_from_file
16 from utilities import should_generate_impl_file_from_idl
13 from utilities import write_file 17 from utilities import write_file
14 18
15 from aggregate_generated_bindings import extract_meta_data
16 from utilities import read_idl_files_list_from_file
17
18 19
19 _COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved. 20 _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 // Use of this source code is governed by a BSD-style license that can be
21 // found in the LICENSE file. 22 // found in the LICENSE file.
22 23
23 """ 24 """
24 25
25 _INIT_PARTIAL_INTERFACE = """%s 26 _INIT_PARTIAL_INTERFACE = """%s
26 %s 27 %s
27 28
(...skipping 20 matching lines...) Expand all
48 if options.output is None: 49 if options.output is None:
49 parser.error('Must specify output file using --output.') 50 parser.error('Must specify output file using --output.')
50 if options.idl_files_list is None: 51 if options.idl_files_list is None:
51 parser.error('Must specify a list of IDL files using --idl-files-list.') 52 parser.error('Must specify a list of IDL files using --idl-files-list.')
52 if options.write_file_only_if_changed is None: 53 if options.write_file_only_if_changed is None:
53 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.') 54 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
54 options.write_file_only_if_changed = bool(options.write_file_only_if_changed ) 55 options.write_file_only_if_changed = bool(options.write_file_only_if_changed )
55 return options 56 return options
56 57
57 58
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
58 def main(): 86 def main():
59 options = parse_options() 87 options = parse_options()
60 88
61 idl_file_names = read_idl_files_list_from_file(options.idl_files_list, is_gy p_format=options.gyp_format_list) 89 idl_file_names = read_idl_files_list_from_file(options.idl_files_list, is_gy p_format=options.gyp_format_list)
62 90
63 meta_data_list = extract_meta_data(idl_file_names) 91 meta_data_list = extract_meta_data(idl_file_names)
64 interface_names = ['V8%sPartial' % meta_data['name'] 92 interface_names = ['V8%sPartial' % meta_data['name']
65 for meta_data in meta_data_list] 93 for meta_data in meta_data_list]
66 interface_names.sort() 94 interface_names.sort()
67 95
68 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name 96 includes = ['#include "bindings/modules/v8/%s.h"' % interface_name
69 for interface_name in interface_names] 97 for interface_name in interface_names]
70 initialize_calls = [' %s::initialize();' % interface_name 98 initialize_calls = [' %s::initialize();' % interface_name
71 for interface_name in interface_names] 99 for interface_name in interface_names]
72 100
73 content = _INIT_PARTIAL_INTERFACE % ( 101 content = _INIT_PARTIAL_INTERFACE % (
74 _COPYRIGHT, 102 _COPYRIGHT,
75 '\n'.join(includes), 103 '\n'.join(includes),
76 '\n'.join(initialize_calls)) 104 '\n'.join(initialize_calls))
77 105
78 write_file(content, options.output, 106 write_file(content, options.output,
79 only_if_changed=options.write_file_only_if_changed) 107 only_if_changed=options.write_file_only_if_changed)
80 108
81 109
82 if __name__ == '__main__': 110 if __name__ == '__main__':
83 sys.exit(main()) 111 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698