forked from dcos/dcos-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (68 loc) · 2.34 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
CURRENT_DIR=$(shell pwd)
PKG=github.com/dcos/dcos-cli
PKG_DIR=/go/src/$(PKG)
IMAGE_NAME=dcos/dcos-cli
VERSION?=$(shell git rev-parse HEAD)
CORE_VERSION?=1.12-patch.1
windows_EXE=.exe
.PHONY: default
default:
@make $(shell uname | tr [A-Z] [a-z])
.PHONY: darwin linux windows
darwin linux windows: docker-image
$(call inDocker,env GOOS=$(@) GO111MODULE=on CGO_ENABLED=0 go build \
-ldflags '-X $(PKG)/pkg/cli/version.version=$(VERSION)' \
-tags '$(GO_BUILD_TAGS)' -mod=vendor \
-o build/$(@)/dcos$($(@)_EXE) ./cmd/dcos)
.PHONY: core-bundle
core-bundle: docker-image
$(call inDocker,go-bindata -pkg corecli -o pkg/internal/corecli/corecli_linux.gen.go -nometadata -tags "corecli" -prefix "build/linux" build/linux/core.zip)
$(call inDocker,go-bindata -pkg corecli -o pkg/internal/corecli/corecli_darwin.gen.go -nometadata -tags "corecli" -prefix "build/darwin" build/darwin/core.zip)
$(call inDocker,go-bindata -pkg corecli -o pkg/internal/corecli/corecli_windows.gen.go -nometadata -tags "corecli" -prefix "build/windows" build/windows/core.zip)
.PHONY: core-download
core-download:
mkdir -p build/linux build/darwin build/windows
wget https://downloads.dcos.io/cli/releases/plugins/dcos-core-cli/linux/x86-64/dcos-core-cli-$(CORE_VERSION).zip -O build/linux/core.zip
wget https://downloads.dcos.io/cli/releases/plugins/dcos-core-cli/darwin/x86-64/dcos-core-cli-$(CORE_VERSION).zip -O build/darwin/core.zip
wget https://downloads.dcos.io/cli/releases/plugins/dcos-core-cli/windows/x86-64/dcos-core-cli-$(CORE_VERSION).zip -O build/windows/core.zip
.PHONY: install
install:
go install ./cmd/dcos
.PHONY: test
test: vet
$(call inDocker,go test -race -cover ./...)
.PHONY: vet
vet: lint
$(call inDocker,go vet ./...)
.PHONY: lint
lint: docker-image
# Can be simplified once https://github.com/golang/lint/issues/320 is fixed.
$(call inDocker,golint -set_exit_status ./cmd/... ./pkg/...)
.PHONY: generate
generate: docker-image
$(call inDocker,go generate ./...)
.PHONY: vendor
vendor: docker-image
$(call inDocker,go mod vendor)
.PHONY: docker-image
docker-image:
ifndef NO_DOCKER
docker build -t $(IMAGE_NAME) .
endif
.PHONY: clean
clean:
rm -rf build
ifdef NO_DOCKER
define inDocker
$1
endef
else
define inDocker
docker run \
-v $(CURRENT_DIR):$(PKG_DIR) \
-w $(PKG_DIR) \
--rm \
$(IMAGE_NAME) \
bash -c "$1"
endef
endif