mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-09 01:11:58 +00:00
pyosys: rewrite using pybind11
- Rewrite all Python features to use the pybind11 library instead of boost::python. Unlike boost::python, pybind11 is a header-only library that is just included by Pyosys code, saving a lot of compile time on wheels. - Factor out as much "translation" code from the generator into proper C++ files - Fix running the embedded interpreter not supporting "from pyosys import libyosys as ys" like wheels - Move Python-related elements to `pyosys` directory at the root of the repo - Slight shift in bridging semantics: - Containers are declared as "opaque types" and are passed by reference to Python - many methods have been implemented to make them feel right at home without the overhead/ambiguity of copying to Python and then copying back after mutation - Monitor/Pass use "trampoline" pattern to support virual methods overridable in Python: virtual methods no longer require `py_` prefix - Create really short test set for pyosys that just exercises basic functionality
This commit is contained in:
parent
f7120e9c2a
commit
88be728353
27 changed files with 2879 additions and 2674 deletions
39
tests/pyosys/run_tests.py
Normal file
39
tests/pyosys/run_tests.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
__file_dir__ = Path(__file__).absolute().parent
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} {sys.argv[1]}")
|
||||
exit(64)
|
||||
|
||||
binary = []
|
||||
if sys.argv[1] in ["yosys"]:
|
||||
binary = [__file_dir__.parents[1] / "yosys", "-Qy"]
|
||||
else:
|
||||
binary = [sys.argv[1]]
|
||||
|
||||
tests = __file_dir__.glob("test_*.py")
|
||||
errors = False
|
||||
log_dir = __file_dir__ / "logs"
|
||||
try:
|
||||
shutil.rmtree(log_dir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
for test in tests:
|
||||
print(f"* {test.name} ", end="")
|
||||
log_dir.mkdir(parents=True, exist_ok=True)
|
||||
log = log_dir / (test.stem + ".log")
|
||||
result = subprocess.run([
|
||||
*binary,
|
||||
test
|
||||
], stdout=open(log, "w"), stderr=subprocess.STDOUT)
|
||||
if result.returncode == 0:
|
||||
print("OK!")
|
||||
else:
|
||||
print(f"FAILED: {log}")
|
||||
errors = True
|
||||
if errors:
|
||||
exit(1)
|
Loading…
Add table
Add a link
Reference in a new issue