From: Claire Wolf Date: Tue, 14 Apr 2020 17:55:14 +0000 (+0200) Subject: Add task pattern matching, closes #76 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=69ef444464ef6b79ce4279234898e355d4c41e44;p=SymbiYosys.git Add task pattern matching, closes #76 Signed-off-by: Claire Wolf --- diff --git a/sbysrc/sby.py b/sbysrc/sby.py index e546c9c..82f6eae 100644 --- a/sbysrc/sby.py +++ b/sbysrc/sby.py @@ -17,7 +17,7 @@ # 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## from sby_core import SbyJob, SbyAbort, process_filename from time import localtime @@ -149,6 +149,7 @@ def early_log(workdir, msg): def read_sbyconfig(sbydata, taskname): cfgdata = list() tasklist = list() + task_matched = False pycode = None tasks_section = False @@ -159,7 +160,7 @@ def read_sbyconfig(sbydata, taskname): def handle_line(line): 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("\r") @@ -230,11 +231,23 @@ def read_sbyconfig(sbydata, taskname): return line = line.split() if len(line) > 0: - tasklist.append(line[0]) - for t in line: - if taskname == line[0]: - task_tags_active.add(t) - task_tags_all.add(t) + tname = line[0] + tpattern = False + 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_all.add(t) + else: + for t in line[1:]: + task_tags_all.add(t) elif line == "[tasks]": if taskname is None: @@ -247,6 +260,10 @@ def read_sbyconfig(sbydata, taskname): for line in sbydata: 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