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

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

Issue 18190004: Add Python flow to bindings generation, move dummy-generating IDL files over (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 5 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 (C) 2013 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 import optparse
31 import os
32 import shlex
33 import sys
34
35 import build_ir
36 import code_generator_v8
37
38
39 def parse_options():
40 parser = optparse.OptionParser()
41 parser.add_option('--additional-idl-files')
42 parser.add_option('--idl-attributes-file')
43 parser.add_option('--include', dest='idl_directories', action='append')
44 parser.add_option('--output-directory')
45 parser.add_option('--supplemental-dependency-file')
haraken 2013/07/09 11:16:48 --interface-dependency-file ?
Nils Barth (inactive) 2013/07/10 02:38:32 Oops (>,<). Fixed (throughout, plus rebase).
46 parser.add_option('--verbose', action='store_true', default=False)
47 parser.add_option('--write-file-only-if-changed', type='int')
48 # ensure output comes last, so command line easy to parse via regexes
49 parser.disable_interspersed_args()
50
51 options, args = parser.parse_args()
52 if options.output_directory is None:
53 parser.error('Must specify output directory using --output-directory.')
54 if options.additional_idl_files is not None:
55 # additional_idl_files is passed as a string with varied (shell-style)
56 # quoting, hence needs parsing.
57 options.additional_idl_files = shlex.split(options.additional_idl_files)
58 if len(args) != 1:
59 parser.error('Must specify exactly 1 input file as argument, but %d give n.' % len(args))
60 options.target_idl_filename = os.path.realpath(args[0])
61 return options
62
63
64 def main():
65 options = parse_options()
66 target_idl_filename = options.target_idl_filename
67 target_basename = os.path.basename(target_idl_filename)
68 target_interface_name, _ = os.path.splitext(target_basename)
69 if options.verbose:
70 print target_idl_filename
71
72 try:
73 # FIXME: Currently read_merged_idl does not return, since just a stub
74 # Ignore E1111: Assigning to function call which doesn't return
75 # pylint: disable=E1111
haraken 2013/07/09 11:16:48 Remove the part after "Ignore E111...". This part
Nils Barth (inactive) 2013/07/10 02:38:32 We don't need this anymore now that we return a du
76 blink_ir = build_ir.read_merged_idl(target_idl_filename, supplemental_de pendency_file=options.supplemental_dependency_file, additional_idl_files=options .additional_idl_files)
haraken 2013/07/09 11:16:48 I feel that read_merged_idl() and methods in read_
Nils Barth (inactive) 2013/07/10 02:38:32 Got it, changed; how does it look? I wanted to ha
77 except build_ir.IdlNotFoundError:
78 # We generate dummy .h and .cpp files just to tell build scripts
79 # that outputs have been created.
80 code_generator_v8.generate_dummy_header_and_cpp(target_interface_name, o ptions.output_directory)
81 return
82 # FIXME: currently IdlNotFoundError *must* be raised, and dummy .cpp and
83 # .h files generated, as actual code generator not present yet.
84 raise RuntimeError('Stub: real code generator not implemented yet')
85
86
87 if __name__ == '__main__':
88 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698