| OLD | NEW |
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 else: | 229 else: |
| 230 args.import_directories[idx] = RelativePath(tokens[0], args.depth) | 230 args.import_directories[idx] = RelativePath(tokens[0], args.depth) |
| 231 generator_modules = LoadGenerators(args.generators_string) | 231 generator_modules = LoadGenerators(args.generators_string) |
| 232 | 232 |
| 233 fileutil.EnsureDirectoryExists(args.output_dir) | 233 fileutil.EnsureDirectoryExists(args.output_dir) |
| 234 | 234 |
| 235 processor = MojomProcessor(lambda filename: filename in args.filename) | 235 processor = MojomProcessor(lambda filename: filename in args.filename) |
| 236 processor.LoadTypemaps(set(args.typemaps)) | 236 processor.LoadTypemaps(set(args.typemaps)) |
| 237 for filename in args.filename: | 237 for filename in args.filename: |
| 238 processor.ProcessFile(args, remaining_args, generator_modules, filename) | 238 processor.ProcessFile(args, remaining_args, generator_modules, filename) |
| 239 if args.depfile: |
| 240 assert args.depfile_target |
| 241 with open(args.depfile, 'w') as f: |
| 242 f.write('%s: %s' % ( |
| 243 args.depfile_target, |
| 244 ' '.join(processor._parsed_files.keys()))) |
| 239 | 245 |
| 240 return 0 | 246 return 0 |
| 241 | 247 |
| 242 | 248 |
| 243 def _Precompile(args, _): | 249 def _Precompile(args, _): |
| 244 generator_modules = LoadGenerators(",".join(_BUILTIN_GENERATORS.keys())) | 250 generator_modules = LoadGenerators(",".join(_BUILTIN_GENERATORS.keys())) |
| 245 | 251 |
| 246 template_expander.PrecompileTemplates(generator_modules, args.output_dir) | 252 template_expander.PrecompileTemplates(generator_modules, args.output_dir) |
| 247 return 0 | 253 return 0 |
| 248 | 254 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 "--export_attribute", type=str, default="", | 301 "--export_attribute", type=str, default="", |
| 296 help="Optional attribute to specify on class declaration to export it " | 302 help="Optional attribute to specify on class declaration to export it " |
| 297 "for the component build.") | 303 "for the component build.") |
| 298 generate_parser.add_argument( | 304 generate_parser.add_argument( |
| 299 "--export_header", type=str, default="", | 305 "--export_header", type=str, default="", |
| 300 help="Optional header to include in the generated headers to support the " | 306 help="Optional header to include in the generated headers to support the " |
| 301 "component build.") | 307 "component build.") |
| 302 generate_parser.add_argument( | 308 generate_parser.add_argument( |
| 303 "--generate_non_variant_code", action="store_true", | 309 "--generate_non_variant_code", action="store_true", |
| 304 help="Generate code that is shared by different variants.") | 310 help="Generate code that is shared by different variants.") |
| 311 generate_parser.add_argument( |
| 312 "--depfile", type=str, |
| 313 help="A file into which the list of input files will be written.") |
| 314 generate_parser.add_argument( |
| 315 "--depfile_target", type=str, |
| 316 help="The target name to use in the depfile.") |
| 305 generate_parser.set_defaults(func=_Generate) | 317 generate_parser.set_defaults(func=_Generate) |
| 306 | 318 |
| 307 precompile_parser = subparsers.add_parser("precompile", | 319 precompile_parser = subparsers.add_parser("precompile", |
| 308 description="Precompile templates for the mojom bindings generator.") | 320 description="Precompile templates for the mojom bindings generator.") |
| 309 precompile_parser.add_argument( | 321 precompile_parser.add_argument( |
| 310 "-o", "--output_dir", dest="output_dir", default=".", | 322 "-o", "--output_dir", dest="output_dir", default=".", |
| 311 help="output directory for precompiled templates") | 323 help="output directory for precompiled templates") |
| 312 precompile_parser.set_defaults(func=_Precompile) | 324 precompile_parser.set_defaults(func=_Precompile) |
| 313 | 325 |
| 314 args, remaining_args = parser.parse_known_args() | 326 args, remaining_args = parser.parse_known_args() |
| 315 return args.func(args, remaining_args) | 327 return args.func(args, remaining_args) |
| 316 | 328 |
| 317 | 329 |
| 318 if __name__ == "__main__": | 330 if __name__ == "__main__": |
| 319 sys.exit(main()) | 331 sys.exit(main()) |
| OLD | NEW |