def run_backend( cm, export, do_configure, do_build, do_run, flags, system_name, system, backendargs, build_root_arg, ): tool_error = ( "No tool was supplied on command line or found in '{}' core description" ) core = _get_core(cm, system) try: tool = core.get_tool(flags) except SyntaxError as e: logger.error(str(e)) exit(1) if not tool: logger.error(tool_error.format(system)) exit(1) flags["tool"] = tool build_root = build_root_arg or os.path.join(cm.config.build_root, core.name.sanitized_name) logger.debug("Setting build_root to {}".format(build_root)) if export: export_root = os.path.join(build_root, "src") else: export_root = None try: work_root = os.path.join(build_root, core.get_work_root(flags)) except SyntaxError as e: logger.error(e.msg) exit(1) eda_api_file = os.path.join(work_root, core.name.sanitized_name + ".eda.yml") if not os.path.exists(eda_api_file): do_configure = True if do_configure: try: cores = cm.get_depends(core.name, flags) except DependencyError as e: logger.error( e.msg + "\nFailed to resolve dependencies for {}".format(system)) exit(1) except SyntaxError as e: logger.error(e.msg) exit(1) try: edalizer = Edalizer( core.name, flags, cores, cache_root=cm.config.cache_root, work_root=work_root, export_root=export_root, system_name=system_name, ) backend_class = get_edatool(tool) edalizer.parse_args(backend_class, backendargs) except SyntaxError as e: logger.error(e.msg) exit(1) except RuntimeError as e: logger.error("Setup failed : {}".format(str(e))) exit(1) edalizer.to_yaml(eda_api_file) # Frontend/backend separation try: if do_configure: edam = edalizer.edalize else: import yaml edam = yaml.safe_load(open(eda_api_file)) backend = get_edatool(tool)(edam=edam, work_root=work_root) except ImportError: logger.error('Backend "{}" not found'.format(tool)) exit(1) except RuntimeError as e: logger.error(str(e)) exit(1) except FileNotFoundError as e: logger.error('Could not find EDA API file "{}"'.format(e.filename)) exit(1) if do_configure: try: backend.configure([]) print("") except RuntimeError as e: logger.error("Failed to configure the system") logger.error(str(e)) exit(1) if do_build: try: backend.build() except RuntimeError as e: logger.error("Failed to build {} : {}".format( str(core.name), str(e))) exit(1) if do_run: try: backend.run(backendargs) except RuntimeError as e: logger.error("Failed to run {} : {}".format( str(core.name), str(e))) exit(1)
def run_backend( cm, export, do_configure, do_build, do_run, flags, system_name, system, backendargs, build_root_arg, verbose, ): tool_error = ( "No tool was supplied on command line or found in '{}' core description" ) core = _get_core(cm, system) try: tool = core.get_tool(flags) except SyntaxError as e: logger.error(str(e)) exit(1) if not tool: logger.error(tool_error.format(system)) exit(1) flags["tool"] = tool build_root = build_root_arg or os.path.join(cm.config.build_root, core.name.sanitized_name) logger.debug(f"Setting build_root to {build_root}") if export: export_root = os.path.join(build_root, "src") else: export_root = None try: work_root = os.path.join(build_root, core.get_work_root(flags)) except SyntaxError as e: logger.error(e.msg) exit(1) eda_api_file = os.path.join(work_root, core.name.sanitized_name + ".eda.yml") if not os.path.exists(eda_api_file): do_configure = True try: backend_class = get_edatool(tool) except ImportError: logger.error(f"Backend {tool!r} not found") exit(1) edalizer = Edalizer( toplevel=core.name, flags=flags, core_manager=cm, cache_root=cm.config.cache_root, work_root=work_root, export_root=export_root, system_name=system_name, ) if do_configure: try: edalizer.run() edam = edalizer.edalize parsed_args = edalizer.parse_args(backend_class, backendargs, edam) edalizer.add_parsed_args(backend_class, parsed_args) except SyntaxError as e: logger.error(e.msg) exit(1) except RuntimeError as e: logger.error("Setup failed : {}".format(str(e))) exit(1) edalizer.to_yaml(eda_api_file) else: edam = yaml_fread(eda_api_file) parsed_args = edalizer.parse_args(backend_class, backendargs, edam) # Frontend/backend separation try: backend = backend_class(edam=edam, work_root=work_root, verbose=verbose) except RuntimeError as e: logger.error(str(e)) exit(1) except FileNotFoundError as e: logger.error(f'Could not find EDA API file "{e.filename}"') exit(1) if do_configure: try: backend.configure([]) print("") except RuntimeError as e: logger.error("Failed to configure the system") logger.error(str(e)) exit(1) if do_build: try: backend.build() except RuntimeError as e: logger.error("Failed to build {} : {}".format( str(core.name), str(e))) exit(1) if do_run: try: backend.run(parsed_args) except RuntimeError as e: logger.error("Failed to run {} : {}".format( str(core.name), str(e))) exit(1)