Chromium Code Reviews| OLD | NEW |
|---|---|
| (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('--defines') | |
|
haraken
2013/07/08 06:06:29
Is this still needed? Now we no longer need prepro
Nils Barth (inactive)
2013/07/09 08:48:16
Nope, we can remove it – done!
(Just checked with
| |
| 43 parser.add_option('--idl-attributes-file') | |
| 44 parser.add_option('--include', dest='idl_directories', action='append') | |
| 45 parser.add_option('--output-directory') | |
| 46 parser.add_option('--supplemental-dependency-file') | |
| 47 parser.add_option('--verbose', action='store_true', default=False) | |
| 48 parser.add_option('--write-file-only-if-changed', type='int') | |
| 49 # ensure output comes last, so command line easy to parse via regexes | |
| 50 parser.disable_interspersed_args() | |
| 51 | |
| 52 options, args = parser.parse_args() | |
| 53 if options.output_directory is None: | |
| 54 parser.error('Must specify output directory using --output-directory.') | |
| 55 if options.additional_idl_files is not None: | |
| 56 # additional_idl_files is passed as a string with varied (shell-style) | |
| 57 # quoting, hence needs parsing. | |
| 58 options.additional_idl_files = shlex.split(options.additional_idl_files) | |
| 59 if len(args) != 1: | |
| 60 parser.error('Must specify exactly 1 input file as argument, but %d give n.' % len(args)) | |
| 61 options.target_idl_filename = os.path.realpath(args[0]) | |
| 62 return options | |
| 63 | |
| 64 | |
| 65 def main(): | |
| 66 options = parse_options() | |
| 67 target_idl_filename = options.target_idl_filename | |
| 68 target_basename = os.path.basename(target_idl_filename) | |
| 69 target_interface_name, _ = os.path.splitext(target_basename) | |
| 70 if options.verbose: | |
| 71 print target_idl_filename | |
| 72 | |
| 73 try: | |
| 74 # FIXME: Currently read_merged_idl does not return, since just a stub | |
| 75 # Ignore E1111: Assigning to function call which doesn't return | |
| 76 # pylint: disable=E1111 | |
| 77 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) | |
| 78 except build_ir.IdlNotFoundError: | |
| 79 # We generate dummy .h and .cpp files just to tell build scripts | |
| 80 # that outputs have been created. | |
| 81 code_generator_v8.generate_dummy_header_and_cpp(target_interface_name, o ptions.output_directory) | |
| 82 return | |
| 83 # FIXME: currently IdlNotFoundError *must* be raised, and dummy .cpp and | |
| 84 # .h files generated, as actual code generator not present yet. | |
| 85 raise RuntimeError('Stub: real code generator not implemented yet') | |
| 86 | |
| 87 | |
| 88 if __name__ == '__main__': | |
| 89 sys.exit(main()) | |
| OLD | NEW |