forked from dcos/dcos-core-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (58 loc) · 1.29 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
CURRENT_DIR=$(shell pwd)
PKG=github.com/dcos/dcos-core-cli
PKG_DIR=/go/src/$(PKG)
IMAGE_NAME=dcos/dcos-core-cli
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 go build \
-tags '$(GO_BUILD_TAGS)' -mod=vendor \
-o build/$(@)/dcos$($(@)_EXE) ./cmd/dcos)
.PHONY: plugin
plugin: python
@python3 scripts/plugin/package_plugin.py
.PHONY: python
python:
@cd python/lib/dcoscli; \
make binary
.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