No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. SHELL := /bin/bash
  2. RELEASE_DIR ?= ./_release
  3. TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 plan9/amd64
  4. PACKAGE := gerrit.wikimedia.org/r/blubber
  5. GO_LIST_GOFILES := '{{range .GoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}{{range .XTestGoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}'
  6. GO_PACKAGES := $(shell go list ./...)
  7. GO_LDFLAGS := \
  8. -X $(PACKAGE)/meta.Version=$(shell cat VERSION) \
  9. -X $(PACKAGE)/meta.GitCommit=$(shell git rev-parse --short HEAD)
  10. # go build/install commands
  11. #
  12. GO_BUILD := go build -v -ldflags "$(GO_LDFLAGS)"
  13. GO_INSTALL := go install -v -ldflags "$(GO_LDFLAGS)"
  14. all: code blubber blubberoid
  15. blubber:
  16. $(GO_BUILD) ./cmd/blubber
  17. blubberoid:
  18. $(GO_BUILD) ./cmd/blubberoid
  19. code:
  20. go generate $(GO_PACKAGES)
  21. clean:
  22. go clean
  23. rm -f blubber blubberoid
  24. install: all
  25. $(GO_INSTALL) $(GO_PACKAGES)
  26. release:
  27. gox -output="$(RELEASE_DIR)/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' -ldflags '$(GO_LDFLAGS)' $(GO_PACKAGES)
  28. cp LICENSE "$(RELEASE_DIR)"
  29. for f in "$(RELEASE_DIR)"/*/{blubber,blubberoid}; do \
  30. shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256"; \
  31. done
  32. lint:
  33. @echo > .lint-gofmt.diff
  34. @go list -f $(GO_LIST_GOFILES) $(GO_PACKAGES) | while read f; do \
  35. gofmt -e -d "$${f}" >> .lint-gofmt.diff; \
  36. done
  37. @test -z "$(grep '[^[:blank:]]' .lint-gofmt.diff)" || (echo "gofmt found errors:"; cat .lint-gofmt.diff; exit 1)
  38. golint -set_exit_status $(GO_PACKAGES)
  39. go vet -composites=false $(GO_PACKAGES)
  40. unit:
  41. go test -cover -ldflags "$(GO_LDFLAGS)" $(GO_PACKAGES)
  42. test: unit lint
  43. .PHONY: install release