3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-05 06:04:06 +00:00

Minimum-modification change for stdin support

This commit is contained in:
Andrew Wygle 2017-11-24 09:39:41 -08:00
parent db9c7e97b8
commit b7c33a72e9
2 changed files with 21 additions and 10 deletions

View file

@ -17,7 +17,7 @@
# 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
@ -29,7 +29,7 @@ exe_paths = dict()
def usage():
print("""
sby [options] <jobname>.sby
sby [options] [<jobname>.sby]
-d <dirname>
set workdir name. default: <jobname> (without .sby)
@ -78,10 +78,13 @@ for o, a in opts:
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):
@ -89,8 +92,10 @@ 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
@ -101,7 +106,11 @@ if opt_backup:
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)
@ -110,5 +119,8 @@ for k, v in exe_paths.items():
job.run()
if not sbyfile:
shutil.rmtree(workdir, ignore_errors=True)
sys.exit(job.retcode)

View file

@ -16,7 +16,7 @@
# 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
@ -157,7 +157,6 @@ class SbyJob:
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:
@ -167,7 +166,7 @@ class SbyJob:
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: