From e0dda2155539f77024c852a0b8b9ec6e7ee8e0fd Mon Sep 17 00:00:00 2001
From: Jannis Harder <me@jix.one>
Date: Fri, 19 Apr 2024 16:40:30 +0200
Subject: [PATCH] abc: Support arbitrary prep abc commands

---
 sbysrc/sby_engine_abc.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sbysrc/sby_engine_abc.py b/sbysrc/sby_engine_abc.py
index 1fabe6f..3527035 100644
--- a/sbysrc/sby_engine_abc.py
+++ b/sbysrc/sby_engine_abc.py
@@ -69,6 +69,14 @@ def run(mode, task, engine_idx, engine):
     if task.opt_aigfolds:
         fold_command += " -s"
 
+    prep_commands = []
+
+    for i, arg in reversed(list(enumerate(engine[1:], 1))):
+        if arg.endswith(';'):
+            prep_commands = engine[1:i + 1]
+            engine[1:] = engine[i + 1:]
+            break
+
     abc_command, custom_options, toggles = abc_getopt(engine[1:], [
         "keep-going",
     ])
@@ -116,6 +124,8 @@ def run(mode, task, engine_idx, engine):
     else:
         task.error(f"Invalid ABC command {abc_command[0]}.")
 
+    abc_command[0:0] = prep_commands
+
     smtbmc_vcd = task.opt_vcd and not task.opt_vcd_sim
     run_aigsmt = smtbmc_vcd or (task.opt_append and task.opt_append_assume)
     smtbmc_append = 0