2021-08-12 20:03:24 +01:00
|
|
|
SHELL := /bin/bash
|
2023-03-20 10:05:46 +00:00
|
|
|
RAGEL := ragel
|
|
|
|
GOFMT := go fmt
|
2021-08-12 20:03:24 +01:00
|
|
|
|
2023-03-20 10:05:46 +00:00
|
|
|
export GO_TEST=env GOTRACEBACK=all go test $(GO_ARGS)
|
|
|
|
|
|
|
|
.PHONY: build
|
2021-08-12 20:03:24 +01:00
|
|
|
build: machine.go
|
|
|
|
|
2023-03-20 10:05:46 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@rm -rf docs
|
|
|
|
@rm -f machine.go
|
|
|
|
|
|
|
|
.PHONY: images
|
2021-08-12 20:03:24 +01:00
|
|
|
images: docs/urn.png
|
|
|
|
|
2023-03-20 10:05:46 +00:00
|
|
|
.PHONY: removecomments
|
|
|
|
removecomments:
|
|
|
|
@go build ./tools/removecomments
|
|
|
|
|
2021-08-12 20:03:24 +01:00
|
|
|
machine.go: machine.go.rl
|
2023-03-20 10:05:46 +00:00
|
|
|
|
|
|
|
machine.go: removecomments
|
|
|
|
|
|
|
|
machine.go:
|
|
|
|
$(RAGEL) -Z -G2 -e -o $@ $<
|
|
|
|
@./removecomments $@
|
|
|
|
$(MAKE) -s file=$@ snake2camel
|
|
|
|
$(GOFMT) $@
|
2021-08-12 20:03:24 +01:00
|
|
|
|
|
|
|
docs/urn.dot: machine.go.rl
|
|
|
|
@mkdir -p docs
|
2023-03-20 10:05:46 +00:00
|
|
|
$(RAGEL) -Z -e -Vp $< -o $@
|
2021-08-12 20:03:24 +01:00
|
|
|
|
|
|
|
docs/urn.png: docs/urn.dot
|
|
|
|
dot $< -Tpng -o $@
|
|
|
|
|
|
|
|
.PHONY: bench
|
|
|
|
bench: *_test.go machine.go
|
|
|
|
go test -bench=. -benchmem -benchtime=5s ./...
|
|
|
|
|
|
|
|
.PHONY: tests
|
2023-03-20 10:05:46 +00:00
|
|
|
tests: *_test.go
|
|
|
|
$(GO_TEST) ./...
|
2021-08-12 20:03:24 +01:00
|
|
|
|
|
|
|
.PHONY: snake2camel
|
|
|
|
snake2camel:
|
|
|
|
@awk -i inplace '{ \
|
|
|
|
while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \
|
|
|
|
$$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \
|
|
|
|
print \
|
|
|
|
}' $(file)
|