-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
37 lines (29 loc) · 1.17 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
WORKDIR=build
ANTLR_VERSION=4.10
ANTLR_JAR=antlr-$(ANTLR_VERSION)-complete.jar
PROJECT=grammars-v4
[email protected]:facetoe/$(PROJECT).git
GRAMMAR_COMMIT=44d956ad79598dea81b13aad5275e55e698595e8
$(WORKDIR)/$(ANTLR_JAR):
mkdir -p $(WORKDIR)
curl https://www.antlr.org/download/$(ANTLR_JAR) -o $(WORKDIR)/$(ANTLR_JAR)
$(WORKDIR)/$(PROJECT):
git clone $(GITHUB_URL) $(WORKDIR)/$(PROJECT)
generate-parser: $(WORKDIR)/$(ANTLR_JAR) $(WORKDIR)/$(PROJECT)
git -C $(WORKDIR)/$(PROJECT) reset --hard "$(GRAMMAR_COMMIT)"
(cd $(WORKDIR)/$(PROJECT)/promql && java -jar $(CURDIR)/$(WORKDIR)/$(ANTLR_JAR) -Dlanguage=Python3 PromQLLexer.g4 -visitor -o $(CURDIR)/promformat/parser)
(cd $(WORKDIR)/$(PROJECT)/promql && java -jar $(CURDIR)/$(WORKDIR)/$(ANTLR_JAR) -Dlanguage=Python3 PromQLParser.g4 -visitor -o $(CURDIR)/promformat/parser)
clean:
rm -rf $(WORKDIR)
test:
PYTHONPATH=. pytest-3 tests/
reformat:
black promformat tests
validate-style:
$(eval CHANGES_BEFORE := $(shell mktemp))
git diff > $(CHANGES_BEFORE)
$(MAKE) reformat
$(eval CHANGES_AFTER := $(shell mktemp))
git diff > $(CHANGES_AFTER)
diff $(CHANGES_BEFORE) $(CHANGES_AFTER)
-rm $(CHANGES_BEFORE) $(CHANGES_AFTER)