forked from arana-db/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
30 lines (22 loc) · 889 Bytes
/
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
.PHONY: all parser clean
all: fmt parser
test: fmt parser
sh test.sh
parser: parser.go hintparser.go
%arser.go: prefix = $(@:parser.go=)
%arser.go: %arser.y bin/goyacc
@echo "bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $<"
@bin/goyacc -o $@ -p yy$(prefix) -t $(prefix)Parser $< || ( rm -f $@ && echo 'Please check y.output for more information' && exit 1 )
@rm -f y.output
%arser_golden.y: %arser.y
@bin/goyacc -fmt -fmtout $@ $<
@(git diff --no-index --exit-code $< $@ && rm $@) || (mv $@ $< && >&2 echo "formatted $<" && exit 1)
bin/goyacc: goyacc/main.go goyacc/format_yacc.go
GO111MODULE=on go build -o bin/goyacc goyacc/main.go goyacc/format_yacc.go
fmt: bin/goyacc parser_golden.y hintparser_golden.y
@echo "gofmt (simplify)"
@gofmt -s -l -w . 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
clean:
go clean -i ./...
rm -rf *.out
rm -f parser.go hintparser.go