yosys 615 B

1234567891011121314151617181920
  1. #!/usr/bin/python3
  2. import os
  3. import subprocess
  4. import sys
  5. from pathlib import Path
  6. args = list(sys.argv[1:])
  7. temporary = None
  8. for index, value in enumerate(args):
  9. path = Path(value)
  10. if path.suffix == ".ys" and path.is_file():
  11. temporary = path.with_name(path.stem + ".compat.ys")
  12. temporary.write_text(path.read_text(encoding="utf-8").replace("read_ilang", "read_rtlil"), encoding="utf-8")
  13. args[index] = str(temporary)
  14. break
  15. try:
  16. raise SystemExit(subprocess.call(["/usr/bin/yosys", *args]))
  17. finally:
  18. if temporary is not None:
  19. temporary.unlink(missing_ok=True)