4d06e100081f340bfaa403480c430d489f79951f
[SymbiYosys.git] / tests / make / required_tools.py
1 import shutil
2
3 REQUIRED_TOOLS = {
4 ("smtbmc", "yices"): ["yices-smt2"],
5 ("smtbmc", "z3"): ["z3"],
6 ("smtbmc", "cvc4"): ["cvc4"],
7 ("smtbmc", "mathsat"): ["mathsat"],
8 ("smtbmc", "boolector"): ["boolector"],
9 ("smtbmc", "bitwuzla"): ["bitwuzla"],
10 ("smtbmc", "abc"): ["yosys-abc"],
11 ("aiger", "suprove"): ["suprove", "yices"],
12 ("aiger", "avy"): ["avy", "yices"],
13 ("aiger", "aigbmc"): ["aigbmc", "yices"],
14 ("btor", "btormc"): ["btormc", "btorsim"],
15 ("btor", "pono"): ["pono", "btorsim"],
16 ("abc"): ["yices"],
17 }
18
19
20 if __name__ == "__main__":
21 import subprocess
22 import sys
23 from pathlib import Path
24
25 found_tools = []
26 check_tools = set()
27 for tools in REQUIRED_TOOLS.values():
28 check_tools.update(tools)
29
30 for tool in sorted(check_tools):
31 if not shutil.which(tool):
32 continue
33
34 if tool == "btorsim":
35 error_msg = subprocess.run(
36 ["btorsim", "--vcd"],
37 capture_output=True,
38 text=True,
39 ).stderr
40 if "invalid command line option" in error_msg:
41 print(
42 "found `btorsim` binary is too old "
43 "to support the `--vcd` option, ignoring"
44 )
45 continue
46
47 found_tools.append(tool)
48
49 found_tools = "\n".join(found_tools + [""])
50
51 try:
52 with open("make/rules/found_tools") as found_tools_file:
53 if found_tools_file.read() == found_tools:
54 exit(0)
55 except FileNotFoundError:
56 pass
57
58 Path("make/rules").mkdir(exist_ok=True)
59
60 with open("make/rules/found_tools", "w") as found_tools_file:
61 found_tools_file.write(found_tools)
62 else:
63 with open("make/rules/found_tools") as found_tools_file:
64 found_tools = [tool.strip() for tool in found_tools_file.readlines()]