-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
59 lines (44 loc) · 1.55 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
default: build
GIT_VERSION=$(shell git describe HEAD 2>/dev/null || git describe --tags HEAD)
.PHONY: default version clean build test install integration get-deps
peg=$(shell which peg \
|| ([ -x $(GOPATH)/bin/peg ] && echo $(GOPATH)/bin/peg) \
|| ([ -x /home/travis/gopath/bin/peg ] && echo /home/travis/gopath/bin/peg) \
|| echo peg)
get-deps:
go get github.com/pointlander/peg
go get github.com/stretchr/testify/assert
go get github.com/pebbe/util
gherkin.peg.go: gherkin.peg
# pre-process peg file
cat gherkin.peg | sed \
-e 's/{{++\([^}]*\)}}/{ p.\1 = p.\1 + buffer[begin:end] }/g' \
-e 's/{{\[\]\([^}]*\)}}/{ p.\1 = append(p.\1, buffer[begin:end]) }/g' \
-e 's/{{\([^}]*\)}}/{ p.\1 = buffer[begin:end] }/g' \
> gherkin.peg.pp
$(peg) -switch -inline gherkin.peg.pp
# dirty way to not export PEG specific types, constants or variables
cat gherkin.peg.pp.go | sed \
-e 's/State/state/g' \
-e 's/TokenTree/tokenTree/g' \
-e 's/Rul3s/rul3s/g' \
-e 's/Rule/rule/g' \
-e 's/END_SYMBOL/end_symbol/' \
> $@
rm gherkin.peg.pp gherkin.peg.pp.go
version:
@echo "version: $(GIT_VERSION)" >&2
@cat version.go | sed -e 's/\(VERSION = "\)[^\"]*\("\)/\1'$(GIT_VERSION)'\2/' > version.go.tmp
@diff version.go.tmp version.go || (cat version.go.tmp > version.go)
@rm version.go.tmp
build: version gherkin.peg.go
go build ./ ./formater
install: version gherkin.peg.go
go install
test: version gherkin.peg.go
go test ./ ./formater
integration: get-deps clean build test
@echo "done: $(GIT_VERSION)" >&2
clean:
- rm gherkin.peg.go
go clean