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