forked from taiyoh/sqsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (31 loc) · 1.68 KB
/
Makefile
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
GIT_VERSION=$(shell git describe --tags | sed 's/^v//')
CURRENT_REVISION=$(shell git rev-parse --short HEAD)
CURRENT_DATE=$(shell date +"%FT%T%z")
LDFLAGS="-s -w -X github.com/taiyoh/sqsd.version=$(GIT_VERSION) -X main.commit=$(CURRENT_REVISION) -X main.date=$(CURRENT_DATE)"
.PHONY: test install build release clean
install:
cd cmd/sqsd && go install
test:
go test -v -race -timeout 30s
PKGDIR=pkg/v$(GIT_VERSION)
DISTDIR=$(PKGDIR)/dist
clean:
rm -rf $(PKGDIR)/ && mkdir -p $(PKGDIR)/dist
$(PKGDIR)/sqsd_linux_amd64/sqsd:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(@D)/$(@F) -ldflags=$(LDFLAGS) cmd/sqsd/main.go
$(PKGDIR)/sqsd_darwin_amd64/sqsd:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(@D)/$(@F) -ldflags=$(LDFLAGS) cmd/sqsd/main.go
$(PKGDIR)/sqsd_windows_amd64/sqsd.exe:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(@D)/$(@F) -ldflags=$(LDFLAGS) cmd/sqsd/main.go
$(DISTDIR)/sqsd_$(GIT_VERSION)_linux_amd64.tar.gz: $(PKGDIR)/sqsd_linux_amd64/sqsd
cd $(PKGDIR)/sqsd_linux_amd64 && tar cvzf $(@F) sqsd && mv $(@F) ../dist
$(DISTDIR)/sqsd_$(GIT_VERSION)_darwin_amd64.zip: $(PKGDIR)/sqsd_darwin_amd64/sqsd
cd $(PKGDIR)/sqsd_darwin_amd64 && zip $(@F) * && mv $(@F) ../dist
$(DISTDIR)/sqsd_$(GIT_VERSION)_windows_amd64.zip: $(PKGDIR)/sqsd_windows_amd64/sqsd.exe
cd $(PKGDIR)/sqsd_windows_amd64 && zip $(@F) * && mv $(@F) ../dist
build: clean $(DISTDIR)/sqsd_$(GIT_VERSION)_linux_amd64.tar.gz $(DISTDIR)/sqsd_$(GIT_VERSION)_darwin_amd64.zip $(DISTDIR)/sqsd_$(GIT_VERSION)_windows_amd64.zip
release:
ghr v$(GIT_VERSION) $(PKGDIR)/dist
.PHONY: protobuf
protobuf:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative sqsd.proto