Merge pull request #195 from jix/sbyproc-truncated-output
[SymbiYosys.git] / Makefile
index 62f452ad148e875e2f34862a4a5b4e9df32f0fb5..7a86f6be70a78972b41b8a94b7ad532a4cf31782 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 
 DESTDIR =
 PREFIX = /usr/local
+PROGRAM_PREFIX =
 
 # On Windows, manually setting absolute path to Python binary may be required
 # for launcher executable to work. From MSYS2, this can be done using the
@@ -9,6 +10,8 @@ ifeq ($(OS), Windows_NT)
 PYTHON = $(shell cygpath -w -m $(PREFIX)/bin/python3)
 endif
 
+.PHONY: help install ci test html clean
+
 help:
        @echo ""
        @echo "sudo make install"
@@ -17,6 +20,13 @@ help:
        @echo "make html"
        @echo "    build documentation in docs/build/html/"
        @echo ""
+       @echo "make test"
+       @echo "    run tests, skipping tests with missing dependencies"
+       @echo ""
+       @echo "make ci"
+       @echo "    run all tests, failing tests with missing dependencies"
+       @echo "    note: this requires a full Tabby CAD Suite or OSS CAD Suite install"
+       @echo ""
        @echo "make clean"
        @echo "    cleanup"
        @echo ""
@@ -25,6 +35,7 @@ install:
        mkdir -p $(DESTDIR)$(PREFIX)/bin
        mkdir -p $(DESTDIR)$(PREFIX)/share/yosys/python3
        cp sbysrc/sby_*.py $(DESTDIR)$(PREFIX)/share/yosys/python3/
+       sed -e 's|##yosys-program-prefix##|"'$(PROGRAM_PREFIX)'"|' < sbysrc/sby_core.py > $(DESTDIR)$(PREFIX)/share/yosys/python3/sby_core.py
 ifeq ($(OS), Windows_NT)
        sed -e 's|##yosys-sys-path##|sys.path += [os.path.dirname(__file__) + p for p in ["/share/python3", "/../share/yosys/python3"]]|;' \
                -e "s|#!/usr/bin/env python3|#!$(PYTHON)|" < sbysrc/sby.py > $(DESTDIR)$(PREFIX)/bin/sby-script.py
@@ -34,10 +45,39 @@ else
        chmod +x $(DESTDIR)$(PREFIX)/bin/sby
 endif
 
+.PHONY: check_cad_suite run_ci
+
+ci: check_cad_suite
+       @$(MAKE) run_ci
+
+run_ci:
+       $(MAKE) test NOSKIP=1
+       if yosys -qp 'read -verific' 2> /dev/null; then set -x; \
+               YOSYS_NOVERIFIC=1 $(MAKE) run_ci; \
+       fi
+
+check_cad_suite:
+       @if ! which tabbypip >/dev/null 2>&1; then \
+               echo "'make ci' requries the Tabby CAD Suite or the OSS CAD Suite"; \
+               echo "try 'make test' instead or run 'make run_ci' to proceed anyway."; \
+               exit 1; \
+       fi
+
+test_demo1:
+       cd sbysrc && python3 sby.py -f demo1.sby
+
+test_demo2:
+       cd sbysrc && python3 sby.py -f demo2.sby
+
+test_demo3:
+       cd sbysrc && python3 sby.py -f demo3.sby
+
+test:
+       $(MAKE) -C tests test
+
 html:
-       make -C docs html
+       $(MAKE) -C docs html
 
 clean:
-       make -C docs clean
+       $(MAKE) -C docs clean
        rm -rf docs/build sbysrc/sby sbysrc/__pycache__
-