| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """This script drives the mojom bindings generation.""" | 6 """This script drives the mojom bindings generation.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 "--output-dir": args.output_dir, | 76 "--output-dir": args.output_dir, |
| 77 "--generators": args.generators_string, | 77 "--generators": args.generators_string, |
| 78 "--depth": args.depth, | 78 "--depth": args.depth, |
| 79 } | 79 } |
| 80 | 80 |
| 81 if args.python_sdk_dir: | 81 if args.python_sdk_dir: |
| 82 cmd_args["--python-sdk-dir"] = args.python_sdk_dir | 82 cmd_args["--python-sdk-dir"] = args.python_sdk_dir |
| 83 | 83 |
| 84 for name, value in cmd_args.iteritems(): | 84 for name, value in cmd_args.iteritems(): |
| 85 cmd.extend([name, value]) | 85 cmd.extend([name, value]) |
| 86 if args.no_gen_imports: |
| 87 cmd.extend("--no-gen-imports") |
| 86 | 88 |
| 87 # Some language-specific args may be found in remaining_args. See | 89 # Some language-specific args may be found in remaining_args. See |
| 88 # run_code_generators.py and look for GENERATOR_PREFIX for more information. | 90 # run_code_generators.py and look for GENERATOR_PREFIX for more information. |
| 89 cmd.extend(remaining_args) | 91 cmd.extend(remaining_args) |
| 92 if not args.no_gen_imports: |
| 93 cmd.extend(args.filename) |
| 90 | 94 |
| 91 process = subprocess.Popen(cmd, stdin=subprocess.PIPE) | 95 process = subprocess.Popen(cmd, stdin=subprocess.PIPE) |
| 92 process.communicate(serialized_file_graph) | 96 process.communicate(serialized_file_graph) |
| 93 return process.wait() | 97 return process.wait() |
| 94 | 98 |
| 95 | 99 |
| 96 def main(argv): | 100 def main(argv): |
| 97 parser = argparse.ArgumentParser( | 101 parser = argparse.ArgumentParser( |
| 98 description="Generate bindings from mojom files.") | 102 description="Generate bindings from mojom files.") |
| 99 parser.add_argument("filename", nargs="+", | 103 parser.add_argument("filename", nargs="+", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 parser.add_argument("-I", dest="import_directories", action="append", | 116 parser.add_argument("-I", dest="import_directories", action="append", |
| 113 metavar="directory", default=[], | 117 metavar="directory", default=[], |
| 114 help="add a directory to be searched for import files") | 118 help="add a directory to be searched for import files") |
| 115 parser.add_argument("-mojom-parser", dest="mojom_parser", | 119 parser.add_argument("-mojom-parser", dest="mojom_parser", |
| 116 help="Location of the mojom parser.") | 120 help="Location of the mojom parser.") |
| 117 parser.add_argument("--use_bundled_pylibs", action="store_true", | 121 parser.add_argument("--use_bundled_pylibs", action="store_true", |
| 118 help="use Python modules bundled in the SDK") | 122 help="use Python modules bundled in the SDK") |
| 119 parser.add_argument("-p", "--python-sdk-dir", dest="python_sdk_dir", | 123 parser.add_argument("-p", "--python-sdk-dir", dest="python_sdk_dir", |
| 120 help="Location of the compiled python bindings", | 124 help="Location of the compiled python bindings", |
| 121 default="") | 125 default="") |
| 126 parser.add_argument("--no-gen-imports", action="store_true", |
| 127 help="Generate code only for the files that are " |
| 128 "specified on the command line. By default, code " |
| 129 "is generated for all specified files and their " |
| 130 "transitive imports.") |
| 122 (args, remaining_args) = parser.parse_known_args(argv) | 131 (args, remaining_args) = parser.parse_known_args(argv) |
| 123 | 132 |
| 124 serialized_file_graph = RunParser(args) | 133 serialized_file_graph = RunParser(args) |
| 125 | 134 |
| 126 if serialized_file_graph: | 135 if serialized_file_graph: |
| 127 return RunGenerators(serialized_file_graph, args, remaining_args) | 136 return RunGenerators(serialized_file_graph, args, remaining_args) |
| 128 return 1 | 137 return 1 |
| 129 | 138 |
| 130 | 139 |
| 131 if __name__ == "__main__": | 140 if __name__ == "__main__": |
| 132 sys.exit(main(sys.argv[1:])) | 141 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |