()
| 609 | |
| 610 | |
| 611 | def main(): |
| 612 | jinja_dir, config_file, config, deps_filename, stamp_filename = read_config() |
| 613 | |
| 614 | protocol = Protocol(config) |
| 615 | source_set = protocol.source_set |
| 616 | |
| 617 | if not config.exported and len(protocol.exported_domains): |
| 618 | sys.stderr.write(("Domains [%s] are exported, but config is missing export " |
| 619 | "entry\n\n") % ", ".join(protocol.exported_domains)) |
| 620 | exit(1) |
| 621 | |
| 622 | if not os.path.exists(config.protocol.output): |
| 623 | os.mkdir(config.protocol.output) |
| 624 | if len(protocol.exported_domains) and not os.path.exists( |
| 625 | config.exported.output): |
| 626 | os.mkdir(config.exported.output) |
| 627 | jinja_env = initialize_jinja_env(jinja_dir, config.protocol.output, config) |
| 628 | |
| 629 | inputs = [] |
| 630 | inputs.append(__file__) |
| 631 | inputs.append(config_file) |
| 632 | inputs.append(config.protocol.path) |
| 633 | if config.imported: |
| 634 | inputs.append(config.imported.path) |
| 635 | templates_dir = os.path.join(module_path, "templates") |
| 636 | inputs.append(os.path.join(templates_dir, "TypeBuilder_h.template")) |
| 637 | inputs.append(os.path.join(templates_dir, "TypeBuilder_cpp.template")) |
| 638 | inputs.append(os.path.join(templates_dir, "Exported_h.template")) |
| 639 | inputs.append(os.path.join(templates_dir, "Imported_h.template")) |
| 640 | |
| 641 | h_template = jinja_env.get_template("templates/TypeBuilder_h.template") |
| 642 | cpp_template = jinja_env.get_template("templates/TypeBuilder_cpp.template") |
| 643 | exported_template = jinja_env.get_template("templates/Exported_h.template") |
| 644 | imported_template = jinja_env.get_template("templates/Imported_h.template") |
| 645 | |
| 646 | outputs = dict() |
| 647 | |
| 648 | for domain in protocol.json_api["domains"]: |
| 649 | class_name = domain["domain"] |
| 650 | file_name = config.protocol.file_name_prefix + class_name |
| 651 | template_context = { |
| 652 | "protocol": protocol, |
| 653 | "config": config, |
| 654 | "domain": domain, |
| 655 | "join_arrays": join_arrays, |
| 656 | "format_include": functools.partial(format_include, config), |
| 657 | "format_domain_include": functools.partial(format_domain_include, config), |
| 658 | } |
| 659 | |
| 660 | if domain["domain"] in protocol.generate_domains: |
| 661 | output_h = os.path.join(config.protocol.output, to_file_name( |
| 662 | config, file_name + ".h")) |
| 663 | outputs[output_h] = h_template.render(template_context) |
| 664 | source_set.add(h_template.filename) |
| 665 | output_cpp = os.path.join(config.protocol.output, to_file_name( |
| 666 | config, file_name + ".cpp")) |
| 667 | outputs[output_cpp] = cpp_template.render(template_context) |
| 668 | source_set.add(cpp_template.filename) |
no test coverage detected
searching dependent graphs…