2017-11-18 16:21:53 +01:00
|
|
|
.PHONY: generate build test vet cover release docs docs-clean clean release-bins
|
2017-11-12 21:41:34 +01:00
|
|
|
.DEFAULT_GOAL := build
|
2017-09-30 16:40:39 +02:00
|
|
|
|
|
|
|
ROOT := github.com/zrepl/zrepl
|
|
|
|
SUBPKGS := cmd logger rpc sshbytestream util
|
|
|
|
|
|
|
|
_TESTPKGS := $(ROOT) $(foreach p,$(SUBPKGS),$(ROOT)/$(p))
|
|
|
|
|
|
|
|
ARTIFACTDIR := artifacts
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
generate: #not part of the build, must do that manually
|
2017-09-30 16:40:39 +02:00
|
|
|
@for pkg in $(_TESTPKGS); do\
|
|
|
|
go generate "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
build:
|
|
|
|
go build -o $(ARTIFACTDIR)/zrepl
|
|
|
|
|
2017-09-30 16:40:39 +02:00
|
|
|
test:
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
echo "Testing $$pkg"; \
|
|
|
|
go test "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
|
|
|
vet:
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
echo "Vetting $$pkg"; \
|
|
|
|
go vet "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
|
|
|
cover: artifacts
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
profile="$(ARTIFACTDIR)/cover-$$(basename $$pkg).out"; \
|
|
|
|
go test -coverprofile "$$profile" $$pkg || exit 1; \
|
|
|
|
if [ -f "$$profile" ]; then \
|
|
|
|
go tool cover -html="$$profile" -o "$${profile}.html" || exit 2; \
|
|
|
|
fi; \
|
|
|
|
done;
|
|
|
|
|
2017-11-18 16:20:14 +01:00
|
|
|
$(ARTIFACTDIR):
|
|
|
|
mkdir -p "$@"
|
2017-09-30 16:40:39 +02:00
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
$(ARTIFACTDIR)/docs: $(ARTIFACTDIR)
|
|
|
|
mkdir -p "$@"
|
|
|
|
|
|
|
|
docs: $(ARTIFACTDIR)/docs
|
|
|
|
make -C docs \
|
|
|
|
html \
|
|
|
|
BUILDDIR=../artifacts/docs \
|
|
|
|
|
|
|
|
docs-clean:
|
|
|
|
make -C docs \
|
|
|
|
clean \
|
|
|
|
BUILDDIR=../artifacts/docs
|
|
|
|
|
|
|
|
release-bins: $(ARTIFACTDIR) vet test
|
2017-09-30 16:40:39 +02:00
|
|
|
GOOS=linux GOARCH=amd64 go build -o "$(ARTIFACTDIR)/zrepl-linux-amd64"
|
|
|
|
GOOS=freebsd GOARCH=amd64 go build -o "$(ARTIFACTDIR)/zrepl-freebsd-amd64"
|
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
release: release-bins docs
|
|
|
|
|
|
|
|
clean: docs-clean
|
2017-09-30 16:40:39 +02:00
|
|
|
rm -rf "$(ARTIFACTDIR)"
|