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 Nov 30, 2022
1 parent 6e952ce commit 8f65697
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 @@ -636,7 +636,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 @@ -677,6 +677,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 @@ -867,7 +870,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 @@ -1098,6 +1101,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 @@ -1128,6 +1133,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 @@ -1261,3 +1272,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 8f65697

Please sign in to comment.