-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
86 lines (67 loc) · 2.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
PREFIX := $(shell echo $(PREFIX))
ANTLR4 := java -Xmx500M -cp "/usr/local/lib/antlr-4.7.1-complete.jar:$(CLASSPATH)" org.antlr.v4.Tool
GRUN := java org.antlr.v4.gui.TestRig
PYTHON3 := $(shell which python3 2>/dev/null)
PYTHON := python3
COVERAGE := --cov=blackbird_python/blackbird --cov-report term --cov-report=html:coverage_html_report
TESTRUNNER := -m pytest blackbird_python/blackbird/tests
GRAMMAR := blackbird.g4
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " install to install Blackbird"
@echo " wheel to build the Blackbird wheel"
@echo " dist to package the source distribution"
@echo " clean to delete all temporary, cache, and build files"
@echo " clean-docs to delete all built documentation"
@echo " test to run the Python test suite"
@echo " test-grammar to run the grammar test suite"
@echo " coverage to generate a coverage report"
install: build/libblackbird.so
cd build && make install
build/libblackbird.so: blackbird-cpp
.PHONY: wheel
wheel:
$(PYTHON) setup.py bdist_wheel
.PHONY: dist
dist:
$(PYTHON) setup.py sdist
.PHONY : clean
clean:
rm -rf blackbird_python/blackbird/__pycache__
rm -rf blackbird_python/blackbird/tests/__pycache__
rm -rf dist
rm -rf build
rm -rf build_examples
rm -rf .coverage coverage_html_report/
docs:
make -C doc html
rm -rf doc/doxyoutput
rm -rf doc/blackbird_cpp_api
.PHONY : clean-docs
clean-docs:
make -C doc clean
grammar: grammar-python grammar-cpp
grammar-python: src/$(GRAMMAR)
cd src && $(ANTLR4) -Dlanguage=Python3 $(GRAMMAR) -o ../blackbird_python/blackbird
grammar-cpp: src/$(GRAMMAR)
cd src && $(ANTLR4) -Dlanguage=Cpp -visitor -no-listener $(GRAMMAR) -o ../blackbird_cpp
blackbird-cpp:
mkdir -p build
ifeq ($(PREFIX),)
cd build && cmake ../blackbird_cpp && make -j4
else
cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) ../blackbird_cpp && make -j4
endif
cpp-examples:
mkdir -p build_examples
cd build_examples && cmake ../cpp_examples && make -j4
test-grammar: src/$(GRAMMAR)
mkdir -p _test
cd src && $(ANTLR4) $(GRAMMAR) -o ../_test
cd _test && javac *.java
cd _test && $(GRUN) blackbird start ../examples/state_teleportation.xbb -gui
rm -rf _test
coverage:
@echo "Generating coverage report..."
$(PYTHON) $(TESTRUNNER) $(COVERAGE)