.PHONY: test clean refresh help
+OS_NAME := $(shell python3 -c "import os;print(os.name)")
+ifeq (nt,$(OS_NAME))
+ifeq (quoted,$(shell echo "quoted"))
+OS_NAME := nt-unix-like
+endif
+endif
+
+ifeq (nt,$(OS_NAME))
+$(error This Makefile requires unix-like tools and shell, e.g. MSYS2.)
+endif
+
help:
@cat make/help.txt
-export SBY_WORKDIR_GITIGNORE=1
-export SBY_MAIN=$(realpath $(dir $(firstword $(MAKEFILE_LIST)))/../sbysrc/sby.py)
+export SBY_WORKDIR_GITIGNORE := 1
+
+SBY_MAIN := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/../sbysrc/sby.py)
+ifeq (nt-unix-like,$(OS_NAME))
+SBY_MAIN := $(shell cygpath -w $(SBY_MAIN))
+endif
+export SBY_MAIN
make/rules/collect.mk: make/collect_tests.py
python3 make/collect_tests.py
tests = []
checked_dirs = []
-SAFE_PATH = re.compile(r"^[a-zA-Z0-9_./]*$")
+SAFE_PATH = re.compile(r"^[a-zA-Z0-9_./\\]*$")
+
def collect(path):
# don't pick up any paths that need escaping nor any sby workdirs
for entry in path.glob("*.sby"):
filename = str(entry)
if not SAFE_PATH.match(filename):
- continue
- if not re.match(r"^[a-zA-Z0-9_./]*$", filename):
print(f"skipping {filename!r}, use only [a-zA-Z0-9_./] in filenames")
continue
tests.append(entry)
collect(entry)
+def unix_path(path):
+ return "/".join(path.parts)
+
+
collect(Path("."))
collect(Path("../docs/examples"))
with out_file.open("w") as output:
-
for checked_dir in checked_dirs:
print(f"{out_file}: {checked_dir}", file=output)
for test in tests:
- print(f"make/rules/test/{test}.mk: {test}", file=output)
+ test_unix = unix_path(test)
+ print(f"make/rules/test/{test_unix}.mk: {test_unix}", file=output)
for ext in [".sh", ".py"]:
script_file = test.parent / (test.stem + ext)
if script_file.exists():
- print(f"make/rules/test/{test}.mk: {script_file}", file=output)
- print(f"make/rules/test/{test}.mk: make/test_rules.py", file=output)
+ script_file_unix = unix_path(script_file)
+ print(f"make/rules/test/{test_unix}.mk: {script_file_unix}", file=output)
+ print(f"make/rules/test/{test_unix}.mk: make/test_rules.py", file=output)
for test in tests:
- print(f"-include make/rules/test/{test}.mk", file=output)
+ test_unix = unix_path(test)
+ print(f"-include make/rules/test/{test_unix}.mk", file=output)
from required_tools import REQUIRED_TOOLS
+
+def unix_path(path):
+ return "/".join(path.parts)
+
+
sby_file = Path(sys.argv[1])
sby_dir = sby_file.parent
solvers.add(solver)
engine_solvers.add((engine, solver))
- if any(line.startswith("read -verific") or line.startswith("verific") for line in info["script"]):
+ if any(
+ line.startswith("read -verific") or line.startswith("verific")
+ for line in info["script"]
+ ):
required_tools.add("verific")
required_tools = sorted(required_tools)
shell_script = sby_dir / f"{sby_file.stem}.sh"
+ sby_dir_unix = unix_path(sby_dir)
+
if shell_script.exists():
- command = f"cd {sby_dir} && SBY_FILE={sby_file.name} WORKDIR={workdirname} TASK={task} bash {shell_script.name}"
+ command = f"cd {sby_dir_unix} && env SBY_FILE={sby_file.name} WORKDIR={workdirname} TASK={task} bash {shell_script.name}"
else:
- command = f"cd {sby_dir} && python3 $(SBY_MAIN) -f {sby_file.name} {task}"
+ command = f"cd {sby_dir_unix} && python3 $(SBY_MAIN) -f {sby_file.name} {task}"
- print(f"\t@python3 make/required_tools.py run {target} {shlex.quote(command)} {shlex.join(required_tools)}", file=rules)
+ print(
+ f"\t@python3 make/required_tools.py run {target} {shlex.quote(command)} {shlex.join(required_tools)}",
+ file=rules,
+ )
print(f".PHONY: clean-{target}", file=rules)
print(f"clean-{target}:", file=rules)