2017-06-25 17:51:08 +02:00
|
|
|
SOURCES = $(shell find . -name '*.go')
|
2017-10-29 20:01:33 +01:00
|
|
|
PARSERS = $(shell find . -name '*.treerack')
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
.PHONY: cpu.out
|
|
|
|
|
2017-06-25 17:51:08 +02:00
|
|
|
default: build
|
|
|
|
|
2017-11-05 03:48:38 +01:00
|
|
|
deps:
|
|
|
|
go get golang.org/x/tools/cmd/goimports
|
2017-11-05 04:08:08 +01:00
|
|
|
go get -t ./...
|
2017-11-05 03:48:38 +01:00
|
|
|
|
2017-11-05 03:28:36 +01:00
|
|
|
imports: $(SOURCES)
|
2018-01-05 19:06:10 +01:00
|
|
|
@echo imports
|
2017-06-25 17:51:08 +02:00
|
|
|
@goimports -w $(SOURCES)
|
|
|
|
|
|
|
|
build: $(SOURCES)
|
2018-01-05 19:06:10 +01:00
|
|
|
go build
|
2018-01-07 01:45:56 +01:00
|
|
|
go build -o cmd/treerack/treerack ./cmd/treerack
|
|
|
|
|
|
|
|
install: $(SOURCES)
|
|
|
|
go install ./cmd/treerack
|
2018-01-05 19:06:10 +01:00
|
|
|
|
2018-01-09 03:53:20 +01:00
|
|
|
head: $(SOURCES) fmt
|
2018-01-05 19:06:10 +01:00
|
|
|
go run scripts/createhead.go -- \
|
|
|
|
char.go \
|
|
|
|
sequence.go \
|
|
|
|
choice.go \
|
|
|
|
idset.go \
|
|
|
|
results.go \
|
|
|
|
context.go \
|
|
|
|
nodehead.go \
|
|
|
|
syntaxhead.go \
|
|
|
|
> head.go
|
2018-01-09 03:53:20 +01:00
|
|
|
@gofmt -s -w head.go
|
2018-01-05 19:06:10 +01:00
|
|
|
|
2018-01-09 03:53:20 +01:00
|
|
|
generate: $(SOURCES) $(PARSERS) fmt head install
|
2018-01-07 01:45:56 +01:00
|
|
|
treerack generate -export -package-name self < syntax.treerack > self/self.go.next
|
2019-01-27 16:08:39 +01:00
|
|
|
@mv self/self.go.next self/self.go
|
2018-01-05 19:06:10 +01:00
|
|
|
@gofmt -s -w self/self.go
|
|
|
|
|
2018-01-09 03:53:20 +01:00
|
|
|
regenerate: $(SOURCES) $(PARSERS) fmt head install
|
2018-01-07 01:45:56 +01:00
|
|
|
treerack generate -export -package-name self < syntax.treerack > self/self.go.next
|
2019-01-27 16:08:39 +01:00
|
|
|
@mv self/self.go.next self/self.go
|
2018-01-28 19:01:55 +01:00
|
|
|
go install ./cmd/treerack
|
2018-01-07 01:45:56 +01:00
|
|
|
treerack generate -export -package-name self < syntax.treerack > self/self.go.next
|
2019-01-27 16:08:39 +01:00
|
|
|
@mv self/self.go.next self/self.go
|
2018-01-05 19:06:10 +01:00
|
|
|
@gofmt -s -w self/self.go
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2018-01-09 03:53:20 +01:00
|
|
|
check-generate: $(SOURCES) $(PARSERS)
|
|
|
|
@echo checking head
|
|
|
|
@mv head.go head.go.backup
|
|
|
|
@go run scripts/createhead.go -- \
|
|
|
|
char.go \
|
|
|
|
sequence.go \
|
|
|
|
choice.go \
|
|
|
|
idset.go \
|
|
|
|
results.go \
|
|
|
|
context.go \
|
|
|
|
nodehead.go \
|
|
|
|
syntaxhead.go \
|
|
|
|
> head.go
|
|
|
|
@gofmt -s -w head.go
|
|
|
|
@if ! diff head.go head.go.backup > /dev/null; then \
|
|
|
|
mv head.go.backup head.go; \
|
|
|
|
echo head does not match; \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
@echo checking self
|
|
|
|
@mv self/self.go self/self.go.backup
|
|
|
|
@treerack generate -export -package-name self < syntax.treerack > self/self.go.next
|
2019-01-27 16:08:39 +01:00
|
|
|
@mv self/self.go.next self/self.go
|
2018-01-09 03:53:20 +01:00
|
|
|
@gofmt -s -w self/self.go
|
|
|
|
@if ! diff self/self.go self/self.go.backup > /dev/null; then \
|
|
|
|
mv self/self.go.backup self/self.go; \
|
|
|
|
echo self does not match; \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
@echo ok
|
|
|
|
@mv head.go.backup head.go
|
|
|
|
@mv self/self.go.backup self/self.go
|
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
check: build $(PARSERS)
|
2017-11-05 03:28:36 +01:00
|
|
|
go test -test.short -run ^Test
|
2018-01-08 16:49:04 +01:00
|
|
|
go test ./cmd/treerack -test.short -run ^Test
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
checkall: build $(PARSERS)
|
2017-11-05 03:28:36 +01:00
|
|
|
go test
|
2018-01-08 16:49:04 +01:00
|
|
|
go test ./cmd/treerack
|
2017-10-29 16:47:03 +01:00
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
.coverprofile: $(SOURCES)
|
2017-11-05 03:28:36 +01:00
|
|
|
go test -coverprofile .coverprofile
|
|
|
|
|
|
|
|
cover: .coverprofile
|
|
|
|
go tool cover -func .coverprofile
|
|
|
|
|
2018-01-06 22:56:26 +01:00
|
|
|
showcover: .coverprofile
|
2017-11-05 03:28:36 +01:00
|
|
|
go tool cover -html .coverprofile
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
.coverprofile-cmd: $(SOURCES)
|
2018-01-08 16:49:04 +01:00
|
|
|
go test ./cmd/treerack -coverprofile .coverprofile-cmd
|
|
|
|
|
|
|
|
cover-cmd: .coverprofile-cmd
|
|
|
|
go tool cover -func .coverprofile-cmd
|
|
|
|
|
|
|
|
showcover-cmd: .coverprofile-cmd
|
|
|
|
go tool cover -html .coverprofile-cmd
|
|
|
|
|
|
|
|
# command line interface not included
|
2018-01-06 22:56:26 +01:00
|
|
|
publishcoverage: .coverprofile
|
2017-11-05 03:38:24 +01:00
|
|
|
curl -s https://codecov.io/bash -o codecov
|
2017-11-05 04:49:36 +01:00
|
|
|
bash codecov -Zf .coverprofile
|
2017-11-05 03:38:24 +01:00
|
|
|
|
2018-01-28 19:01:55 +01:00
|
|
|
cpu.out:
|
2017-07-30 02:35:51 +02:00
|
|
|
go test -v -run TestMMLFile -cpuprofile cpu.out
|
|
|
|
|
|
|
|
cpu: cpu.out
|
|
|
|
go tool pprof -top cpu.out
|
|
|
|
|
2017-11-05 03:28:36 +01:00
|
|
|
fmt: $(SOURCES)
|
2018-01-05 19:06:10 +01:00
|
|
|
@echo fmt
|
2017-11-05 03:28:36 +01:00
|
|
|
@gofmt -w -s $(SOURCES)
|
|
|
|
|
2018-01-06 22:56:26 +01:00
|
|
|
checkfmt: $(SOURCES)
|
2018-01-05 19:06:10 +01:00
|
|
|
@echo check fmt
|
2017-11-05 05:07:20 +01:00
|
|
|
@if [ "$$(gofmt -s -d $(SOURCES))" != "" ]; then false; else true; fi
|
|
|
|
|
|
|
|
vet:
|
2018-01-08 16:49:04 +01:00
|
|
|
go vet ./...
|
2017-11-05 05:07:20 +01:00
|
|
|
|
2018-01-09 03:53:20 +01:00
|
|
|
precommit: fmt check-generate vet build checkall
|
2017-07-30 02:35:51 +02:00
|
|
|
|
|
|
|
clean:
|
2018-01-05 19:06:10 +01:00
|
|
|
rm -f *.test
|
|
|
|
rm -f cpu.out
|
|
|
|
rm -f .coverprofile
|
|
|
|
go clean -i ./...
|
2017-11-05 03:45:15 +01:00
|
|
|
|
2018-01-06 22:56:26 +01:00
|
|
|
ci-trigger: deps checkfmt build checkall
|
2017-11-05 04:01:27 +01:00
|
|
|
ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST), master_false)
|
2018-01-06 22:56:26 +01:00
|
|
|
make publishcoverage
|
2017-11-05 04:01:27 +01:00
|
|
|
endif
|