makefile (955B)
1 SHELL := /bin/bash 2 RAGEL := ragel 3 GOFMT := go fmt 4 5 export GO_TEST=env GOTRACEBACK=all go test $(GO_ARGS) 6 7 .PHONY: build 8 build: machine.go 9 10 .PHONY: clean 11 clean: 12 @rm -rf docs 13 @rm -f machine.go 14 15 .PHONY: images 16 images: docs/urn.png 17 18 .PHONY: removecomments 19 removecomments: 20 @cd ./tools/removecomments; go build -o ../../removecomments . 21 22 machine.go: machine.go.rl 23 24 machine.go: removecomments 25 26 machine.go: 27 $(RAGEL) -Z -G2 -e -o $@ $< 28 @./removecomments $@ 29 $(MAKE) -s file=$@ snake2camel 30 $(GOFMT) $@ 31 32 docs/urn.dot: machine.go.rl 33 @mkdir -p docs 34 $(RAGEL) -Z -e -Vp $< -o $@ 35 36 docs/urn.png: docs/urn.dot 37 dot $< -Tpng -o $@ 38 39 .PHONY: bench 40 bench: *_test.go machine.go 41 go test -bench=. -benchmem -benchtime=5s ./... 42 43 .PHONY: tests 44 tests: *_test.go 45 $(GO_TEST) ./... 46 47 .PHONY: snake2camel 48 snake2camel: 49 @awk -i inplace '{ \ 50 while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \ 51 $$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \ 52 print \ 53 }' $(file)