mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-12 16:28:17 +00:00
Add ":"-syntax for [tasks] section
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
This commit is contained in:
parent
b409b1179e
commit
ab9d4fd3cf
104
sbysrc/sby.py
104
sbysrc/sby.py
|
@ -66,6 +66,8 @@ parser.add_argument("--pono", metavar="<path_to_executable>",
|
||||||
help="configure which executable to use for the respective tool")
|
help="configure which executable to use for the respective tool")
|
||||||
parser.add_argument("--dumpcfg", action="store_true", dest="dump_cfg",
|
parser.add_argument("--dumpcfg", action="store_true", dest="dump_cfg",
|
||||||
help="print the pre-processed configuration file")
|
help="print the pre-processed configuration file")
|
||||||
|
parser.add_argument("--dumptags", action="store_true", dest="dump_tags",
|
||||||
|
help="print the list of task tags")
|
||||||
parser.add_argument("--dumptasks", action="store_true", dest="dump_tasks",
|
parser.add_argument("--dumptasks", action="store_true", dest="dump_tasks",
|
||||||
help="print the list of tasks")
|
help="print the list of tasks")
|
||||||
parser.add_argument("--dumpfiles", action="store_true", dest="dump_files",
|
parser.add_argument("--dumpfiles", action="store_true", dest="dump_files",
|
||||||
|
@ -95,6 +97,7 @@ opt_tmpdir = args.tmpdir
|
||||||
exe_paths = args.exe_paths
|
exe_paths = args.exe_paths
|
||||||
throw_err = args.throw_err
|
throw_err = args.throw_err
|
||||||
dump_cfg = args.dump_cfg
|
dump_cfg = args.dump_cfg
|
||||||
|
dump_tags = args.dump_tags
|
||||||
dump_tasks = args.dump_tasks
|
dump_tasks = args.dump_tasks
|
||||||
dump_files = args.dump_files
|
dump_files = args.dump_files
|
||||||
reusedir = False
|
reusedir = False
|
||||||
|
@ -200,62 +203,77 @@ def read_sbyconfig(sbydata, taskname):
|
||||||
task_skiping_blocks = False
|
task_skiping_blocks = False
|
||||||
return
|
return
|
||||||
|
|
||||||
found_task_tag = False
|
if not tasks_section:
|
||||||
task_skip_line = False
|
found_task_tag = False
|
||||||
|
task_skip_line = False
|
||||||
|
|
||||||
for t in task_tags_all:
|
for t in task_tags_all:
|
||||||
if line.startswith(t+":"):
|
if line.startswith(t+":"):
|
||||||
line = line[len(t)+1:].lstrip()
|
line = line[len(t)+1:].lstrip()
|
||||||
match = t in task_tags_active
|
match = t in task_tags_active
|
||||||
elif line.startswith("~"+t+":"):
|
elif line.startswith("~"+t+":"):
|
||||||
line = line[len(t)+2:].lstrip()
|
line = line[len(t)+2:].lstrip()
|
||||||
match = t not in task_tags_active
|
match = t not in task_tags_active
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line == "":
|
if line == "":
|
||||||
task_skiping_blocks = True
|
task_skiping_blocks = True
|
||||||
task_skip_block = not match
|
task_skip_block = not match
|
||||||
task_skip_line = True
|
task_skip_line = True
|
||||||
else:
|
else:
|
||||||
task_skip_line = not match
|
task_skip_line = not match
|
||||||
|
|
||||||
found_task_tag = True
|
found_task_tag = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if len(task_tags_all) and not found_task_tag:
|
if len(task_tags_all) and not found_task_tag:
|
||||||
tokens = line.split()
|
tokens = line.split()
|
||||||
if len(tokens) > 0 and tokens[0][0] == line[0] and tokens[0].endswith(":"):
|
if len(tokens) > 0 and tokens[0][0] == line[0] and tokens[0].endswith(":"):
|
||||||
print(f"ERROR: Invalid task specifier \"{tokens[0]}\".", file=sys.stderr)
|
print(f"ERROR: Invalid task specifier \"{tokens[0]}\".", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if task_skip_line or task_skip_block:
|
if task_skip_line or task_skip_block:
|
||||||
return
|
return
|
||||||
|
|
||||||
if tasks_section:
|
if tasks_section:
|
||||||
if taskname is None:
|
if taskname is None:
|
||||||
cfgdata.append(line)
|
cfgdata.append(line)
|
||||||
if line.startswith("#"):
|
if line.startswith("#"):
|
||||||
return
|
return
|
||||||
line = line.split()
|
|
||||||
if len(line) > 0:
|
line = line.split(":")
|
||||||
tname = line[0]
|
if len(line) == 1:
|
||||||
|
tnames, line = line[:1], line[1:]
|
||||||
|
elif len(line) == 2:
|
||||||
|
tnames, line = line[0].split(), line[1].split()
|
||||||
|
else:
|
||||||
|
print("ERROR: Syntax error in tasks block.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for tname in tnames:
|
||||||
|
if tname == "":
|
||||||
|
continue
|
||||||
tpattern = False
|
tpattern = False
|
||||||
for c in tname:
|
for c in tname:
|
||||||
if c in "(?*.[]|)":
|
if c in "(?*.[]|)":
|
||||||
tpattern = True
|
tpattern = True
|
||||||
if not tpattern:
|
if not tpattern:
|
||||||
tasklist.append(tname)
|
if tname not in tasklist:
|
||||||
|
tasklist.append(tname)
|
||||||
task_tags_all.add(tname)
|
task_tags_all.add(tname)
|
||||||
if taskname is not None and re.fullmatch(tname, taskname):
|
if taskname is not None and re.fullmatch(tname, taskname):
|
||||||
task_matched = True
|
task_matched = True
|
||||||
task_tags_active.add(tname)
|
task_tags_active.add(tname)
|
||||||
for t in line[1:]:
|
for t in line:
|
||||||
|
if t == "":
|
||||||
|
continue
|
||||||
task_tags_active.add(t)
|
task_tags_active.add(t)
|
||||||
task_tags_all.add(t)
|
|
||||||
else:
|
for t in line:
|
||||||
for t in line[1:]:
|
if t == "":
|
||||||
task_tags_all.add(t)
|
continue
|
||||||
|
task_tags_all.add(t)
|
||||||
|
|
||||||
elif line == "[tasks]":
|
elif line == "[tasks]":
|
||||||
if taskname is None:
|
if taskname is None:
|
||||||
|
@ -272,7 +290,7 @@ def read_sbyconfig(sbydata, taskname):
|
||||||
print(f"ERROR: Task name '{taskname}' didn't match any lines in [tasks].", file=sys.stderr)
|
print(f"ERROR: Task name '{taskname}' didn't match any lines in [tasks].", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return cfgdata, tasklist
|
return cfgdata, tasklist, sorted(list(task_tags_all))
|
||||||
|
|
||||||
|
|
||||||
sbydata = list()
|
sbydata = list()
|
||||||
|
@ -282,7 +300,7 @@ with (open(sbyfile, "r") if sbyfile is not None else sys.stdin) as f:
|
||||||
|
|
||||||
if dump_cfg:
|
if dump_cfg:
|
||||||
assert len(tasknames) < 2
|
assert len(tasknames) < 2
|
||||||
sbyconfig, _ = read_sbyconfig(sbydata, tasknames[0] if len(tasknames) else None)
|
sbyconfig, _, _ = read_sbyconfig(sbydata, tasknames[0] if len(tasknames) else None)
|
||||||
print("\n".join(sbyconfig))
|
print("\n".join(sbyconfig))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -290,7 +308,7 @@ if dump_files:
|
||||||
file_set = set()
|
file_set = set()
|
||||||
|
|
||||||
def find_files(taskname):
|
def find_files(taskname):
|
||||||
sbyconfig, _ = read_sbyconfig(sbydata, taskname)
|
sbyconfig, _, _ = read_sbyconfig(sbydata, taskname)
|
||||||
|
|
||||||
start_index = -1
|
start_index = -1
|
||||||
for i in range(len(sbyconfig)):
|
for i in range(len(sbyconfig)):
|
||||||
|
@ -319,10 +337,16 @@ if dump_files:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if len(tasknames) == 0:
|
if len(tasknames) == 0:
|
||||||
_, tasknames = read_sbyconfig(sbydata, None)
|
_, tasknames, _ = read_sbyconfig(sbydata, None)
|
||||||
if len(tasknames) == 0:
|
if len(tasknames) == 0:
|
||||||
tasknames = [None]
|
tasknames = [None]
|
||||||
|
|
||||||
|
if dump_tags:
|
||||||
|
_, _, tagnames = read_sbyconfig(sbydata, None)
|
||||||
|
for tag in tagnames:
|
||||||
|
print(tag)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
if dump_tasks:
|
if dump_tasks:
|
||||||
for task in tasknames:
|
for task in tasknames:
|
||||||
if task is not None:
|
if task is not None:
|
||||||
|
@ -386,7 +410,7 @@ def run_job(taskname):
|
||||||
else:
|
else:
|
||||||
junit_filename = "junit"
|
junit_filename = "junit"
|
||||||
|
|
||||||
sbyconfig, _ = read_sbyconfig(sbydata, taskname)
|
sbyconfig, _, _ = read_sbyconfig(sbydata, taskname)
|
||||||
job = SbyJob(sbyconfig, my_workdir, early_logmsgs, reusedir)
|
job = SbyJob(sbyconfig, my_workdir, early_logmsgs, reusedir)
|
||||||
|
|
||||||
for k, v in exe_paths.items():
|
for k, v in exe_paths.items():
|
||||||
|
|
Loading…
Reference in a new issue