2021-08-12 21:03:24 +02:00
|
|
|
SHELL := /bin/bash
|
2023-03-20 11:05:46 +01:00
|
|
|
RAGEL := ragel
|
|
|
|
GOFMT := go fmt
|
2021-08-12 21:03:24 +02:00
|
|
|
|
2023-03-20 11:05:46 +01:00
|
|
|
export GO_TEST=env GOTRACEBACK=all go test $(GO_ARGS)
|
|
|
|
|
|
|
|
.PHONY: build
|
2021-08-12 21:03:24 +02:00
|
|
|
build: machine.go
|
|
|
|
|
2023-03-20 11:05:46 +01:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@rm -rf docs
|
|
|
|
@rm -f machine.go
|
|
|
|
|
|
|
|
.PHONY: images
|
2021-08-12 21:03:24 +02:00
|
|
|
images: docs/urn.png
|
|
|
|
|
2023-03-20 11:05:46 +01:00
|
|
|
.PHONY: removecomments
|
|
|
|
removecomments:
|
2023-05-22 09:17:48 +02:00
|
|
|
@cd ./tools/removecomments; go build -o ../../removecomments .
|
2023-03-20 11:05:46 +01:00
|
|
|
|
2021-08-12 21:03:24 +02:00
|
|
|
machine.go: machine.go.rl
|
2023-03-20 11:05:46 +01:00
|
|
|
|
|
|
|
machine.go: removecomments
|
|
|
|
|
|
|
|
machine.go:
|
|
|
|
$(RAGEL) -Z -G2 -e -o $@ $<
|
|
|
|
@./removecomments $@
|
|
|
|
$(MAKE) -s file=$@ snake2camel
|
|
|
|
$(GOFMT) $@
|
2021-08-12 21:03:24 +02:00
|
|
|
|
|
|
|
docs/urn.dot: machine.go.rl
|
|
|
|
@mkdir -p docs
|
2023-03-20 11:05:46 +01:00
|
|
|
$(RAGEL) -Z -e -Vp $< -o $@
|
2021-08-12 21:03:24 +02: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 11:05:46 +01:00
|
|
|
tests: *_test.go
|
|
|
|
$(GO_TEST) ./...
|
2021-08-12 21:03:24 +02: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 \
|
2023-05-22 09:17:48 +02:00
|
|
|
}' $(file)
|