mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-05 22:14:08 +00:00
Add support for "[file <filename>]" .sby sections
This commit is contained in:
parent
29968fcc58
commit
e69d39434a
|
@ -127,6 +127,7 @@ class SbyJob:
|
|||
self.engines = list()
|
||||
self.script = list()
|
||||
self.files = dict()
|
||||
self.verbatim_files = dict()
|
||||
self.models = dict()
|
||||
self.workdir = workdir
|
||||
self.status = "UNKNOWN"
|
||||
|
@ -154,6 +155,7 @@ class SbyJob:
|
|||
|
||||
with open(filename, "r") as f:
|
||||
for line in f:
|
||||
raw_line = line
|
||||
line = line.strip()
|
||||
# print(line)
|
||||
|
||||
|
@ -183,6 +185,14 @@ class SbyJob:
|
|||
assert len(entries) == 1
|
||||
continue
|
||||
|
||||
if entries[0] == "file":
|
||||
mode = "file"
|
||||
assert len(entries) == 2
|
||||
current_verbatim_file = entries[1]
|
||||
assert current_verbatim_file not in self.verbatim_files
|
||||
self.verbatim_files[current_verbatim_file] = list()
|
||||
continue
|
||||
|
||||
if entries[0] == "files":
|
||||
mode = "files"
|
||||
assert len(entries) == 1
|
||||
|
@ -215,6 +225,10 @@ class SbyJob:
|
|||
assert False
|
||||
continue
|
||||
|
||||
if mode == "file":
|
||||
self.verbatim_files[current_verbatim_file].append(raw_line)
|
||||
continue
|
||||
|
||||
assert False
|
||||
|
||||
def taskloop(self):
|
||||
|
@ -251,6 +265,14 @@ class SbyJob:
|
|||
def copy_src(self):
|
||||
os.makedirs(self.workdir + "/src")
|
||||
|
||||
for dstfile, lines in self.verbatim_files.items():
|
||||
dstfile = self.workdir + "/src/" + dstfile
|
||||
self.log("Writing '%s'." % dstfile)
|
||||
|
||||
with open(dstfile, "w") as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
|
||||
for dstfile, srcfile in self.files.items():
|
||||
dstfile = self.workdir + "/src/" + dstfile
|
||||
|
||||
|
|
Loading…
Reference in a new issue