From 44bd9ed04be1fe5415b578a9da4f08d6a26594d9 Mon Sep 17 00:00:00 2001 From: Aki Van Ness Date: Mon, 21 Nov 2022 22:05:34 -0500 Subject: [PATCH] sby: core: backported changes from #212 for sby-stages integration --- sbysrc/sby_core.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 70079903..d7e5a8d9 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -642,7 +642,7 @@ def run(self): self.tasks = [] for task in tasks: task.check_timeout() - if task.procs_pending or task.procs_running: + if task.procs_pending or task.procs_running or task.stage_running: self.tasks.append(task) else: task.exit_callback() @@ -876,6 +876,9 @@ def __init__(self, sbyconfig, workdir, early_logs, reusedir, taskloop=None, logf self.taskloop = taskloop or SbyTaskloop() self.taskloop.tasks.append(self) + self.base_dependencies = [] + self.stages_running = [] + self.procs_running = [] self.procs_pending = [] @@ -1075,7 +1078,7 @@ def make_model(self, model_name): proc = SbyProc( self, model_name, - [], + self.base_dependencies, "cd {}/src; {} -ql ../model/design.log ../model/design.ys".format(self.workdir, self.exe_paths["yosys"]) ) proc.checkretcode = True @@ -1329,6 +1332,8 @@ def setup_procs(self, setupmode): self.retcode = 0 return + # TODO: Stage stuff + if self.opt_make_model is not None: for name in self.opt_make_model.split(","): self.model(name.strip()) @@ -1359,6 +1364,12 @@ def setup_procs(self, setupmode): if opt not in self.used_options: self.error(f"Unused option: {opt}") + def setup_stage(self, setupmode, config, name, depends): + stage = SbyStage(config, self, name) + stage.base_dependencies.extend(depends) + self.stages_running.append(stage) + stage.setup_procs(setupmode) + def summarize(self): total_clock_time = int(monotonic() - self.start_clock_time) @@ -1492,3 +1503,23 @@ def print_junit_result(self, f, junit_ts_name, junit_tc_name, junit_format_stric print('', file=f) print(f'', file=f) print(f'', file=f) + +class SbyStage(SbyTask): + def __init__(self, sbyconfig, main_task, name): + self.main_task = main_task + self.name = name + workdir = f'{main_task.workdir}/stage_{name}' + os.mkdir(workdir) + + super().__init__( + sbyconfig, workdir, + early_logs = [], reusedir = False, + taskloop = main_task.taskloop, logfile = main_task.logfile + ) + + self.exit_callback = self.handle_stage_exit + + def handle_stage_exit(self): + self.main_task.stages_running.remove(self) + + # TODO pass the status back to the main task