-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (30 loc) · 1.41 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
REVISION := $(shell git describe --always)
DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
LDFLAGS := -ldflags="-X \"main.Revision=$(REVISION)\" -X \"main.BuildDate=${DATE}\" -extldflags \"-static\""
.PHONY: build-cross dist build mod clean run help
name := ecs-task-monitoring
linux_name := $(name)-linux-amd64
darwin_name := $(name)-darwin-amd64
GO_VERSION := 1.12
help:
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf "\033[36m%-22s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST)
dist: build-docker ## create .tar.gz linux & darwin to /bin
cd bin && tar zcvf $(linux_name).tar.gz $(linux_name) && rm -f $(linux_name)
cd bin && tar zcvf $(darwin_name).tar.gz $(darwin_name) && rm -f $(darwin_name)
build-cross: ## create to build for linux & darwin to bin/
GOOS=linux GOARCH=amd64 go build -o bin/$(linux_name) $(LDFLAGS) cmd/$(name)/*.go
GOOS=darwin GOARCH=amd64 go build -o bin/$(darwin_name) $(LDFLAGS) cmd/$(name)/*.go
build: ## go build
go build -o bin/$(name) $(LDFLAGS) cmd/$(name)/*.go
build-docker: ## go build on Docker
@docker run --rm -v "$(PWD)":/go/src/github.com/sioncojp/$(name) -w /go/src/github.com/sioncojp/$(name) golang:$(GO_VERSION) bash build.sh
test: ## go test
go test -v $$(go list ./... | grep -v /vendor/)
mod: ## go mod init
go mod init
clean: ## remove bin/*
rm -f bin/*
run: ## go run
go run cmd/$(name)/main.go -c examples/
lint: ## go lint ignore vendor
golint $(go list ./... | grep -v /vendor/)