7b0cda3759d8e30030526721bdc8c7ffcde8c619
1 from pathlib
import Path
7 SAFE_PATH
= re
.compile(r
"^[a-zA-Z0-9_./]*$")
10 # don't pick up any paths that need escaping nor any sby workdirs
11 if not SAFE_PATH
.match(str(path
)) or (path
/ "config.sby").exists():
14 checked_dirs
.append(path
)
15 for entry
in path
.glob("*.sby"):
17 if not SAFE_PATH
.match(filename
):
19 if not re
.match(r
"^[a-zA-Z0-9_./]*$", filename
):
20 print(f
"skipping {filename!r}, use only [a-zA-Z0-9_./] in filenames")
23 for entry
in path
.glob("*"):
30 out_file
= Path("make/rules/collect.mk")
31 out_file
.parent
.mkdir(exist_ok
=True)
33 with out_file
.open("w") as output
:
36 for checked_dir
in checked_dirs
:
37 print(f
"{out_file}: {checked_dir}", file=output
)
40 print(f
"make/rules/test/{test}.mk: {test} make/rules/found_tools", file=output
)
41 for ext
in [".sh", ".py"]:
42 script_file
= test
.parent
/ (test
.stem
+ ext
)
43 if script_file
.exists():
44 print(f
"make/rules/test/{test}.mk: {script_file}", file=output
)
45 print(f
"make/rules/test/{test}.mk: make/test_rules.py", file=output
)
47 print(f
"-include make/rules/test/{test}.mk", file=output
)