# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
-import os, sys, getopt, shutil
+import os, sys, getopt, shutil, tempfile
##yosys-sys-path##
from sby_core import SbyJob
def usage():
print("""
-sby [options] <jobname>.sby
+sby [options] [<jobname>.sby]
-d <dirname>
set workdir name. default: <jobname> (without .sby)
else:
usage()
-if len(args) != 1:
+if len(args) > 1:
usage()
-sbyfile = args[0]
+if len(args) == 1:
+ sbyfile = args[0]
+ assert sbyfile.endswith(".sby")
+
early_logmsgs = list()
def early_log(msg):
print(early_logmsgs[-1])
if workdir is None:
- assert sbyfile.endswith(".sby")
- workdir = sbyfile[:-4]
+ if sbyfile:
+ workdir = sbyfile[:-4]
+ else:
+ workdir = tempfile.mkdtemp()
if opt_backup:
backup_idx = 0
if opt_force:
early_log("Removing direcory '%s'." % (workdir))
- shutil.rmtree(workdir, ignore_errors=True)
+ if sbyfile:
+ shutil.rmtree(workdir, ignore_errors=True)
+
+if sbyfile:
+ os.makedirs(workdir)
job = SbyJob(sbyfile, workdir, early_logmsgs)
job.run()
+if not sbyfile:
+ shutil.rmtree(workdir, ignore_errors=True)
+
sys.exit(job.retcode)
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
-import os, re, resource
+import os, re, resource, sys
import subprocess, fcntl
from shutil import copyfile
from select import select
self.logprefix = "SBY [%s]" % self.workdir
self.summary = list()
- os.makedirs(workdir)
self.logfile = open("%s/logfile.txt" % workdir, "w")
for line in early_logs:
mode = None
key = None
- with open(filename, "r") as f:
+ with (open(filename, "r") if filename else sys.stdin) as f:
with open("%s/config.sby" % workdir, "w") as cfgfile:
pycode = None
for line in f: