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

Side by Side Diff: mojo/public/tools/bindings/mojom_bindings_generator_v2.py

Issue 1566203002: Only generate code for files that are specified, not their imports. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 86
87 # Some language-specific args may be found in remaining_args. See 87 # Some language-specific args may be found in remaining_args. See
88 # run_code_generators.py and look for GENERATOR_PREFIX for more information. 88 # run_code_generators.py and look for GENERATOR_PREFIX for more information.
89 cmd.extend(remaining_args) 89 cmd.extend(remaining_args)
90 if not args.no_gen_imports:
91 cmd.extend(args.filename)
90 92
91 process = subprocess.Popen(cmd, stdin=subprocess.PIPE) 93 process = subprocess.Popen(cmd, stdin=subprocess.PIPE)
92 process.communicate(serialized_file_graph) 94 process.communicate(serialized_file_graph)
93 return process.wait() 95 return process.wait()
94 96
95 97
96 def main(argv): 98 def main(argv):
97 parser = argparse.ArgumentParser( 99 parser = argparse.ArgumentParser(
98 description="Generate bindings from mojom files.") 100 description="Generate bindings from mojom files.")
99 parser.add_argument("filename", nargs="+", 101 parser.add_argument("filename", nargs="+",
(...skipping 12 matching lines...) Expand all
112 parser.add_argument("-I", dest="import_directories", action="append", 114 parser.add_argument("-I", dest="import_directories", action="append",
113 metavar="directory", default=[], 115 metavar="directory", default=[],
114 help="add a directory to be searched for import files") 116 help="add a directory to be searched for import files")
115 parser.add_argument("-mojom-parser", dest="mojom_parser", 117 parser.add_argument("-mojom-parser", dest="mojom_parser",
116 help="Location of the mojom parser.") 118 help="Location of the mojom parser.")
117 parser.add_argument("--use_bundled_pylibs", action="store_true", 119 parser.add_argument("--use_bundled_pylibs", action="store_true",
118 help="use Python modules bundled in the SDK") 120 help="use Python modules bundled in the SDK")
119 parser.add_argument("-p", "--python-sdk-dir", dest="python_sdk_dir", 121 parser.add_argument("-p", "--python-sdk-dir", dest="python_sdk_dir",
120 help="Location of the compiled python bindings", 122 help="Location of the compiled python bindings",
121 default="") 123 default="")
124 parser.add_argument("--no-gen-imports", action="store_true",
125 help="Generate code only for the files that are "
126 "specified on the command line. By default, code "
127 "is generated for all specified files and their "
128 "transitive imports.")
122 (args, remaining_args) = parser.parse_known_args(argv) 129 (args, remaining_args) = parser.parse_known_args(argv)
123 130
124 serialized_file_graph = RunParser(args) 131 serialized_file_graph = RunParser(args)
125 132
126 if serialized_file_graph: 133 if serialized_file_graph:
127 return RunGenerators(serialized_file_graph, args, remaining_args) 134 return RunGenerators(serialized_file_graph, args, remaining_args)
128 return 1 135 return 1
129 136
130 137
131 if __name__ == "__main__": 138 if __name__ == "__main__":
132 sys.exit(main(sys.argv[1:])) 139 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698