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

Unified 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: Added --target-component instead of --genearte-partial 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 side-by-side diff with in-line comments
Download patch
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.
+"""
+
+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.
+// 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
+ 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.')
+ 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]
tasak 2014/10/14 05:28:20 (diff patchset 5) Removed conditional, because no
+
+ 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())

Powered by Google App Engine
This is Rietveld 408576698