forked from mendersoftware/mender-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (88 loc) · 3.14 KB
/
Makefile
File metadata and controls
112 lines (88 loc) · 3.14 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
GO ?= go
V ?=
PKGS = $(shell go list ./...)
PKGFILES = $(shell find . \( -path ./vendor -o -path ./Godeps \) -prune \
-o -type f -name '*.go' -print)
PKGFILES_notest = $(shell echo $(PKGFILES) | tr ' ' '\n' | grep -v _test.go)
GO_TEST_TOOLS = \
github.com/opennota/check/cmd/varcheck \
github.com/mendersoftware/deadcode
VERSION = $(shell git describe --tags --dirty --exact-match 2>/dev/null || git rev-parse --short HEAD)
GO_LDFLAGS = \
-ldflags "-X github.com/mendersoftware/mender-cli/cmd.Version=$(VERSION)"
BUILDFLAGS ?=
ifeq ($(V),1)
BUILDV = -v
endif
TAGS =
ifeq ($(LOCAL),1)
TAGS += local
endif
ifneq ($(TAGS),)
BUILDTAGS = -tags 'nopkcs11 $(TAGS)'
else
BUILDTAGS = -tags 'nopkcs11'
endif
build:
CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) $(GO_LDFLAGS) $(BUILDV) $(BUILDTAGS)
build-autocomplete-scripts: build
@./mender-cli --generate-autocomplete
build-multiplatform:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build $(BUILDTAGS) $(GO_LDFLAGS) $(BUILDV) $(BUILDFLAGS) \
-o mender-cli.linux.amd64
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build $(BUILDTAGS) $(GO_LDFLAGS) $(BUILDV) $(BUILDFLAGS) \
-o mender-cli.darwin.amd64
build-coverage:
CGO_ENABLED=0 $(GO) build -cover -o mender-cli-test \
-coverpkg $(shell echo $(PKGS) | tr ' ' ',')
install:
CGO_ENABLED=0 $(GO) install $(BUILDTAGS) $(GO_LDFLAGS) $(BUILDV) $(BUILDFLAGS)
install-autocomplete-scripts: build-autocomplete-scripts
@echo "Installing Bash auto-complete script into ${DESTDIR}${PREFIX}/etc/bash_completion.d/"
@install -d ${DESTDIR}$(PREFIX)/etc/bash_completion.d/
@install -m 644 ./autocomplete/autocomplete.sh $(DESTDIR)$(PREFIX)/etc/bash_completion.d/
@if which zsh >/dev/null 2>&1 ; then \
echo "Installing zsh auto-complete script into ${DESTDIR}${PREFIX}/usr/local/share/zsh/site-functions/" && \
install -d $(DESTDIR)$(PREFIX)/usr/local/share/zsh/site-functions/ && \
install -m 644 ./autocomplete/autocomplete.zsh $(DESTDIR)$(PREFIX)/usr/local/share/zsh/site-functions/_mender-cli \
; fi
clean:
$(GO) clean
rm -f coverage.txt coverage-tmp.txt
get-go-tools:
set -e ; for t in $(GO_TEST_TOOLS); do \
echo "-- go getting $$t"; \
GO111MODULE=off go get -u $$t; \
done
get-build-deps:
apt-get update -qq
apt-get install -yyq $(shell cat deb-requirements.txt)
get-deps: get-go-tools get-build-deps
test-unit:
$(GO) test $(BUILDV) $(PKGS)
build-acceptance:
docker compose -f tests/docker-compose.yml build acceptance $(BUILDFLAGS)
run-acceptance:
docker compose -f tests/docker-compose.yml run acceptance
test-static:
echo "-- checking for dead code"
deadcode -ignore version.go:Version
echo "-- checking with varcheck"
varcheck .
cover: coverage
$(GO) tool cover -func=coverage.txt
htmlcover: coverage
$(GO) tool cover -html=coverage.txt
coverage:
rm -f coverage.txt
echo 'mode: set' > coverage.txt
set -e ; for p in $(PKGS); do \
rm -f coverage-tmp.txt; \
$(GO) test -coverprofile=coverage-tmp.txt $$p ; \
if [ -f coverage-tmp.txt ]; then \
cat coverage-tmp.txt | grep -v 'mode:' >> coverage.txt || /bin/true; \
fi; \
done
rm -f coverage-tmp.txt
.PHONY: build clean get-go-tools get-apt-deps get-deps test check \
cover htmlcover coverage