makefile 772 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. SHELL := /bin/bash
  2. build: machine.go
  3. images: docs/urn.png
  4. machine.go: machine.go.rl
  5. ragel -Z -G2 -e -o $@ $<
  6. @sed -i '/^\/\/line/d' $@
  7. @$(MAKE) -s file=$@ snake2camel
  8. @gofmt -w -s $@
  9. docs/urn.dot: machine.go.rl
  10. @mkdir -p docs
  11. ragel -Z -e -Vp $< -o $@
  12. docs/urn.png: docs/urn.dot
  13. dot $< -Tpng -o $@
  14. .PHONY: bench
  15. bench: *_test.go machine.go
  16. go test -bench=. -benchmem -benchtime=5s ./...
  17. .PHONY: tests
  18. tests: *_test.go machine.go
  19. go test -race -timeout 10s -coverprofile=coverage.out -covermode=atomic -v ./...
  20. .PHONY: clean
  21. clean:
  22. @rm -rf docs
  23. @rm -f machine.go
  24. .PHONY: snake2camel
  25. snake2camel:
  26. @awk -i inplace '{ \
  27. while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \
  28. $$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \
  29. print \
  30. }' $(file)