Skip to content

Commit

Permalink
sby: core: backported changes from #212 for sby-stages integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lethalbit committed Feb 9, 2023
1 parent b53bcf8 commit 44bd9ed
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions sbysrc/sby_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1492,3 +1503,23 @@ def print_junit_result(self, f, junit_ts_name, junit_tc_name, junit_format_stric
print('</system-err>', file=f)
print(f'</testsuite>', file=f)
print(f'</testsuites>', 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

0 comments on commit 44bd9ed

Please sign in to comment.