mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-07 14:45:18 +00:00
Add task pattern matching, closes #76
Signed-off-by: Claire Wolf <claire@symbioticeda.com>
This commit is contained in:
parent
c91efe15a3
commit
69ef444464
|
@ -17,7 +17,7 @@
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
import argparse, os, sys, shutil, tempfile
|
import argparse, os, sys, shutil, tempfile, re
|
||||||
##yosys-sys-path##
|
##yosys-sys-path##
|
||||||
from sby_core import SbyJob, SbyAbort, process_filename
|
from sby_core import SbyJob, SbyAbort, process_filename
|
||||||
from time import localtime
|
from time import localtime
|
||||||
|
@ -149,6 +149,7 @@ def early_log(workdir, msg):
|
||||||
def read_sbyconfig(sbydata, taskname):
|
def read_sbyconfig(sbydata, taskname):
|
||||||
cfgdata = list()
|
cfgdata = list()
|
||||||
tasklist = list()
|
tasklist = list()
|
||||||
|
task_matched = False
|
||||||
|
|
||||||
pycode = None
|
pycode = None
|
||||||
tasks_section = False
|
tasks_section = False
|
||||||
|
@ -159,7 +160,7 @@ def read_sbyconfig(sbydata, taskname):
|
||||||
|
|
||||||
def handle_line(line):
|
def handle_line(line):
|
||||||
nonlocal pycode, tasks_section, task_tags_active, task_tags_all
|
nonlocal pycode, tasks_section, task_tags_active, task_tags_all
|
||||||
nonlocal task_skip_block, task_skiping_blocks
|
nonlocal task_skip_block, task_skiping_blocks, task_matched
|
||||||
|
|
||||||
line = line.rstrip("\n")
|
line = line.rstrip("\n")
|
||||||
line = line.rstrip("\r")
|
line = line.rstrip("\r")
|
||||||
|
@ -230,11 +231,23 @@ def read_sbyconfig(sbydata, taskname):
|
||||||
return
|
return
|
||||||
line = line.split()
|
line = line.split()
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
tasklist.append(line[0])
|
tname = line[0]
|
||||||
for t in line:
|
tpattern = False
|
||||||
if taskname == line[0]:
|
for c in tname:
|
||||||
|
if c in "(?*.[]|)":
|
||||||
|
tpattern = True
|
||||||
|
if not tpattern:
|
||||||
|
tasklist.append(tname)
|
||||||
|
task_tags_all.add(tname)
|
||||||
|
if taskname is not None and re.fullmatch(tname, taskname):
|
||||||
|
task_matched = True
|
||||||
|
task_tags_active.add(tname)
|
||||||
|
for t in line[1:]:
|
||||||
task_tags_active.add(t)
|
task_tags_active.add(t)
|
||||||
task_tags_all.add(t)
|
task_tags_all.add(t)
|
||||||
|
else:
|
||||||
|
for t in line[1:]:
|
||||||
|
task_tags_all.add(t)
|
||||||
|
|
||||||
elif line == "[tasks]":
|
elif line == "[tasks]":
|
||||||
if taskname is None:
|
if taskname is None:
|
||||||
|
@ -247,6 +260,10 @@ def read_sbyconfig(sbydata, taskname):
|
||||||
for line in sbydata:
|
for line in sbydata:
|
||||||
handle_line(line)
|
handle_line(line)
|
||||||
|
|
||||||
|
if taskname is not None and not task_matched:
|
||||||
|
print("ERROR: Task name '{}' didn't match any lines in [tasks].".format(taskname), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
return cfgdata, tasklist
|
return cfgdata, tasklist
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue