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

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

Issue 291903003: Generate java bindings for constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dir creation? Created 6 years, 6 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
« no previous file with comments | « mojo/public/tools/bindings/mojom_bindings_generator.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """The frontend for the Mojo bindings system.""" 6 """The frontend for the Mojo bindings system."""
7 7
8 8
9 import argparse 9 import argparse
10 import imp 10 import imp
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 script_dir = os.path.dirname(os.path.abspath(__file__)) 46 script_dir = os.path.dirname(os.path.abspath(__file__))
47 generators = [] 47 generators = []
48 for generator_name in [s.strip() for s in generators_string.split(",")]: 48 for generator_name in [s.strip() for s in generators_string.split(",")]:
49 # "Built-in" generators: 49 # "Built-in" generators:
50 if generator_name.lower() == "c++": 50 if generator_name.lower() == "c++":
51 generator_name = os.path.join(script_dir, "generators", 51 generator_name = os.path.join(script_dir, "generators",
52 "mojom_cpp_generator.py") 52 "mojom_cpp_generator.py")
53 elif generator_name.lower() == "javascript": 53 elif generator_name.lower() == "javascript":
54 generator_name = os.path.join(script_dir, "generators", 54 generator_name = os.path.join(script_dir, "generators",
55 "mojom_js_generator.py") 55 "mojom_js_generator.py")
56 elif generator_name.lower() == "java":
57 generator_name = os.path.join(script_dir, "generators",
58 "mojom_java_generator.py")
56 # Specified generator python module: 59 # Specified generator python module:
57 elif generator_name.endswith(".py"): 60 elif generator_name.endswith(".py"):
58 pass 61 pass
59 else: 62 else:
60 print "Unknown generator name %s" % generator_name 63 print "Unknown generator name %s" % generator_name
61 sys.exit(1) 64 sys.exit(1)
62 generator_module = imp.load_source(os.path.basename(generator_name)[:-3], 65 generator_module = imp.load_source(os.path.basename(generator_name)[:-3],
63 generator_name) 66 generator_name)
64 generators.append(generator_module) 67 generators.append(generator_module)
65 return generators 68 return generators
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 def main(): 149 def main():
147 parser = argparse.ArgumentParser( 150 parser = argparse.ArgumentParser(
148 description="Generate bindings from mojom files.") 151 description="Generate bindings from mojom files.")
149 parser.add_argument("filename", nargs="+", 152 parser.add_argument("filename", nargs="+",
150 help="mojom input file") 153 help="mojom input file")
151 parser.add_argument("-d", "--depth", dest="depth", default=".", 154 parser.add_argument("-d", "--depth", dest="depth", default=".",
152 help="depth from source root") 155 help="depth from source root")
153 parser.add_argument("-o", "--output_dir", dest="output_dir", default=".", 156 parser.add_argument("-o", "--output_dir", dest="output_dir", default=".",
154 help="output directory for generated files") 157 help="output directory for generated files")
155 parser.add_argument("-g", "--generators", dest="generators_string", 158 parser.add_argument("-g", "--generators", dest="generators_string",
156 metavar="GENERATORS", default="c++,javascript", 159 metavar="GENERATORS", default="c++,javascript,java",
157 help="comma-separated list of generators") 160 help="comma-separated list of generators")
158 parser.add_argument("--debug_print_intermediate", action="store_true", 161 parser.add_argument("--debug_print_intermediate", action="store_true",
159 help="print the intermediate representation") 162 help="print the intermediate representation")
160 parser.add_argument("--use_chromium_bundled_pylibs", action="store_true", 163 parser.add_argument("--use_chromium_bundled_pylibs", action="store_true",
161 help="use Python modules bundled in the Chromium source") 164 help="use Python modules bundled in the Chromium source")
162 (args, remaining_args) = parser.parse_known_args() 165 (args, remaining_args) = parser.parse_known_args()
163 166
164 generator_modules = LoadGenerators(args.generators_string) 167 generator_modules = LoadGenerators(args.generators_string)
165 168
166 if not os.path.exists(args.output_dir): 169 if not os.path.exists(args.output_dir):
167 os.makedirs(args.output_dir) 170 os.makedirs(args.output_dir)
168 171
169 for filename in args.filename: 172 for filename in args.filename:
170 ProcessFile(args, remaining_args, generator_modules, filename) 173 ProcessFile(args, remaining_args, generator_modules, filename)
171 174
172 return 0 175 return 0
173 176
174 177
175 if __name__ == "__main__": 178 if __name__ == "__main__":
176 sys.exit(main()) 179 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/mojom_bindings_generator.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698