-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
194 lines (143 loc) · 4.67 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Fandango Makefile. For development only.
# Settings
MAKEFLAGS=--warn-undefined-variables
# Programs
PYTHON = python
PYTEST = pytest
ANTLR = antlr
BLACK = black
PIP = pip
SED = sed
PAGELABELS = $(PYTHON) -m pagelabels
# Sources
SRC = src/fandango
PYTHON_SOURCES = $(wildcard $(SRC)/*.py $(SRC)/*/*.py $(SRC)/*/*/*.py)
# Default targets
web: parser html
all: web pdf
.PHONY: web all parser install dev-tools docs html latex pdf
## Requirements (no longer used)
# requirements.txt: pyproject.toml
# pip-compile $<
# Install tools for development
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
# Mac
SYSTEM_DEV_TOOLS = antlr pdftk-java graphviz
SYSTEM_DEV_INSTALL = brew install
else
# Linux
SYSTEM_DEV_TOOLS = antlr pdftk-java graphviz
SYSTEM_DEV_INSTALL = apt-get install
endif
dev-tools: system-dev-tools
pip install -U black
pip install -U jupyter-book pyppeteer ghp-import pagelabels
pip install -U graphviz
system-dev-tools:
$(SYSTEM_DEV_INSTALL) $(SYSTEM_DEV_TOOLS)
## Parser
PARSER = src/fandango/language/parser
LEXER_G4 = language/FandangoLexer.g4
PARSER_G4 = language/FandangoParser.g4
PARSERS = \
$(PARSER)/FandangoLexer.py \
$(PARSER)/FandangoParser.py \
$(PARSER)/FandangoParserVisitor.py \
$(PARSER)/FandangoParserListener.py
parser: $(PARSERS)
$(PARSERS) &: $(LEXER_G4) $(PARSER_G4)
$(ANTLR) -Dlanguage=Python3 -Xexact-output-dir -o $(PARSER) \
-visitor -listener $(LEXER_G4) $(PARSER_G4)
$(BLACK) src
## Documentation
DOCS = docs
DOCS_SOURCES = $(wildcard $(DOCS)/*.md $(DOCS)/*.fan $(DOCS)/*.ipynb $(DOCS)/*.yml $(DOCS)/*.bib)
JB = jupyter-book
HTML_MARKER = $(DOCS)/_build/html/marker.txt
ALL_HTML_MARKER = $(DOCS)/_build/html/all-marker.txt
LATEX_MARKER = $(DOCS)/_build/latex/marker.txt
PDF_RAW = $(DOCS)/_build/latex/fandango.pdf
PDF_TARGET = $(DOCS)/fandango.pdf
# Command to open and refresh the Web view (on a Mac)
HTML_INDEX = $(DOCS)/_build/html/index.html
VIEW_HTML = open $(HTML_INDEX)
REFRESH_HTML = \
osascript -e 'tell application "Safari" to set URL of document of window 1 to URL of document of window 1'
# Command to open the PDF (on a Mac)
VIEW_PDF = open $(PDF_TARGET)
# Command to check docs for failed assertions
CHECK_DOCS = grep -l AssertionError $(DOCS)/_build/html/*.html; if [ $$? == 0 ]; then echo 'Check the above files for failed assertions'; false; else true; fi
# Targets.
docs html: $(HTML_MARKER)
latex: $(LATEX_MARKER)
pdf: $(PDF_TARGET)
# Re-create the book in HTML
$(HTML_MARKER): $(DOCS_SOURCES) $(ALL_HTML_MARKER)
$(JB) build $(DOCS)
@$(CHECK_DOCS)
echo 'Success' > $@
-$(REFRESH_HTML)
@echo Output written to $(HTML_INDEX)
# If we change Python sources, _toc.yml, or _config.yml, all docs need to be rebuilt
$(ALL_HTML_MARKER): $(DOCS)/_toc.yml $(DOCS)/_config.yml $(PYTHON_SOURCES)
$(JB) build --all $(DOCS)
@$(CHECK_DOCS)
echo 'Success' > $@
# Same as above, but also clear the cache
clear-cache:
$(RM) -fr $(DOCS)/_build/
rebuild-docs: clear-cache $(ALL_HTML_MARKER)
# view HTML
view: $(HTML_MARKER)
$(VIEW_HTML)
# Refresh Safari
refresh watch: $(HTML_MARKER)
$(REFRESH_HTML)
# Re-create the book in PDF
$(LATEX_MARKER): $(DOCS_SOURCES) $(DOCS)/_book_toc.yml $(DOCS)/_book_config.yml
cd $(DOCS); $(JB) build --builder latex --toc _book_toc.yml --config _book_config.yml .
echo 'Success' > $@
$(DOCS)/_book_toc.yml: $(DOCS)/_toc.yml Makefile
echo '# Automatically generated from `$<`. Do not edit.' > $@
$(SED) s/Intro/BookIntro/ $< >> $@
$(DOCS)/_book_config.yml: $(DOCS)/_config.yml Makefile
echo '# Automatically generated from `$<`. Do not edit.' > $@
$(SED) s/BookIntro/Intro/ $< >> $@
$(PDF_RAW): $(LATEX_MARKER)
cd $(DOCS)/_build/latex && $(MAKE) && cd ../../.. && touch $@
PDF_BODY = $(DOCS)/_build/latex/_body.pdf
$(PDF_BODY): $(DOCS)/Title.pdf $(PDF_RAW)
pdftk $(PDF_RAW) cat 3-end output $@
$(PDF_TARGET): $(PDF_BODY)
pdftk $(DOCS)/Title.pdf $(PDF_BODY) cat output $@
$(PAGELABELS) --load $(PDF_RAW) $@
@echo Output written to $@
view-pdf: $(PDF_TARGET)
$(VIEW_PDF)
clean-docs:
$(JB) clean $(DOCS)
## Tests
TESTS = tests
TEST_SOURCES = $(wildcard $(TESTS)/*.py $(TESTS)/resources/*)
.PHONY: test tests
test tests:
$(PYTEST)
## Installation
.PHONY: install install-test install-tests
install:
$(PIP) install -e .
# We separate _installing_ from _running_ tests
# so we can run 'make tests' quickly (see above)
# without having to reinstall things
install-test install-tests:
$(PIP) install pytest
$(PIP) install -e ".[test]"
uninstall:
$(PIP) uninstall fandango-fuzzer -y
# python -m evaluation.vs_isla.run_evaluation
.PHONY: evaluation evaluate experiment experiments
evaluate evaluation:
$(PYTHON) -m evaluation.vs_isla.run_evaluation 1
experiment experiments:
$(PYTHON) -m evaluation.experiments.run_experiments