def map_interface(node_name, include_lst): cwd = Path(os.environ['UNITEST_build_DIR']) / node_name / "mapping" cwd.make_dirs() (cwd / 'structarray_interface.c').write_text(scade_interface_template) cmd = (["gcc", "-save-temps", "-std=c99", "-g"] + [f"-I{str(include_dir)}" for include_dir in include_lst] + ["structarray_interface.c", "-o", "structarray_interface.exe"]) ret = cwd.run(*cmd) if ret.returncode != 0: raise ValueError("gcc couldn't compile properly") ret = cwd.run("./structarray_interface.exe") for k in ["input", "output"]: u = structarray.StructInfo(cwd / 'structarray_interface.exe') u.parse(k) u.save(cwd, k)
def map_context(node_name, include_lst): cwd = Path(os.environ['UNITEST_build_DIR']) / node_name / "mapping" cwd.make_dirs() (cwd / 'structarray_context.c').write_text( scade_context_template.format(node_name=node_name)) cmd = (["gcc", "-save-temps", "-std=c99", "-g"] + [f"-I{str(include_dir)}" for include_dir in include_lst] + ["structarray_context.c", "-o", "structarray_context.exe"]) ret = cwd.run(*cmd) if ret.returncode != 0: raise ValueError("gcc couldn't compile properly") ret = cwd.run("./structarray_context.exe") txt = ret.stdout.decode(sys.stdout.encoding) (cwd / "structarray_ctype.json").write_text(txt.replace(',\n}', '\n}')) u = structarray.StructInfo(cwd / 'structarray_context.exe') u.parse('context') u.save(cwd, 'context') return u