def run_step(context: Context): print("common_hdl_build") if "MKDV_TOOL" in os.environ.keys(): tool = os.environ["MKDV_TOOL"] elif "MKDV_TOOL" in context.keys(): tool = context["MKDV_TOOL"] else: raise Exception("MKDV_TOOL not specified") hdl_tool_mgr = HdlToolMgr.inst() cfg = HdlToolConfig(tool, context["MKDV_CACHEDIR"], context["MKDV_RUNDIR"]) for key in [ 'MKDV_VL_DEFINES', 'MKDV_VL_INCDIRS', 'MKDV_VL_SRCS', 'MKDV_VPI_LIBS', 'MKDV_DPI_LIBS' ]: if key in context.keys(): val = context[key] print("key=%s val=%s" % (key, str(val))) if isinstance(val, list): for p in val: cfg.append(key, p) elif isinstance(val, str): print("TODO: is a string") pass else: print("TODO: is unknown") pass hdl_tool_mgr.setup(cfg)
def run_step(context : Context): if "MKDV_TOOL" in os.environ.keys(): tool = os.environ["MKDV_TOOL"] elif "MKDV_TOOL" in context.keys(): tool = context["MKDV_TOOL"] else: raise Exception("MKDV_TOOL not specified") hdl_tool_mgr = HdlToolMgr.inst() cfg = HdlToolConfig(tool, os.path.abspath(context["MKDV_CACHEDIR"]), os.path.abspath(context["MKDV_RUNDIR"])) for key in [ 'MKDV_VL_DEFINES', 'MKDV_VL_INCDIRS', 'MKDV_VL_SRCS', 'MKDV_VPI_LIBS', 'MKDV_DPI_LIBS', 'MKDV_TOP_MODULE', 'MKDV_RUN_ARGS']: if key in context.keys(): val = context[key] print("key=%s val=%s" % (key, str(val))) if isinstance(val, list): for p in val: cfg.append(key, p) elif isinstance(val, str): for p in val.split(): cfg.append(key, p) else: print("TODO: is unknown") pass hdl_tool_mgr.run(cfg)
def run_step(context: Context): print("filespec: %s" % str(context)) context.assert_key_has_value("vlnv", "filespec") context.assert_key_exists("out", "filespec") vlnv = context.get_formatted("vlnv") dbm = CoreDbMgr.inst() deps = dbm.get_depends(vlnv) for e in context["out"]: if "name" not in e.keys(): raise KeyNotInContextError("Missing 'name'") if "type" not in e.keys(): raise KeyNotInContextError("Missing 'type'") name = e["name"] file_types = set() for t in e["type"]: file_types.add(t.strip()) flags = {} if "flags" in e.keys(): for f in e["flags"]: flags[f] = True is_include = False if "include" in e.keys(): is_include = bool(e["include"]) files = dbm.collect_files(deps, file_types, flags, is_include) if name in context.keys(): if isinstance(context[name], list): context[name].extend(files) elif isinstance(context[name], str): context[name] += " ".join(files) else: raise Exception("Target for files is an unsupported type %s" % str(type(context[name]))) else: context[name] = files
def run_step(context: Context): context.assert_key_exists("cmd", "run_step") cmd_r = context.get_formatted("cmd") print("cmd=%s" % cmd_r) cmd_l = cmd_r.split() print("cmd_l=%s" % str(cmd_l)) cmd = [sys.executable, '-m'] for a in cmd_l: if a[0] == '"': cmd.append(a[1:len(a) - 1]) else: cmd.append(a) print("cmd=%s" % str(cmd)) if "out" in context.keys(): try: out = subprocess.check_output(cmd) except Exception as e: print("Exception: %s" % str(e)) traceback.print_exc() raise e context[context["out"]] = out.decode().strip() else: try: res = subprocess.run(cmd, stdout=sys.stdout, stderr=sys.stderr) except Exception as e: raise e if res.returncode != 0: raise Exception("Run failed") pass