forked from edgexfoundry/edgex-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (51 loc) · 2.37 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
.PHONY: build test clean install
GO = CGO_ENABLED=0 GO111MODULE=on go
# If GOPATH undefined, base within module to avoid collisions"
ifndef GOPATH
GOMOD=$(shell go env GOMOD)
GOPATH=$(dir ${GOMOD})go
export GOPATH
endif
ifndef GOBIN
GOBIN=$(GOPATH)/bin
export GOBIN
endif
BINARY=edgex-cli
VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
TIME=$(shell date)
GOFLAGS=-ldflags "-X 'github.com/edgexfoundry/edgex-cli.BuildVersion=$(VERSION)' -X 'github.com/edgexfoundry/edgex-cli.BuildTime=$(TIME)'"
ARTIFACT_ROOT?=bin
tidy:
go mod tidy
build:
@echo "GOPATH=$(GOPATH)"
$(GO) build -o ${ARTIFACT_ROOT}/$(BINARY) $(GOFLAGS) ./cmd/edgex-cli
# initial impl. Feel free to override. Please keep ARTIFACT_ROOT coming from env though. CI/CD pipeline relies on this
build-all:
@echo "GOPATH=$(GOPATH)"
GOOS=linux GOARCH=amd64 $(GO) build -o ${ARTIFACT_ROOT}/$(BINARY)-linux-amd64 $(GOFLAGS) ./cmd/edgex-cli
GOOS=linux GOARCH=arm64 $(GO) build -o ${ARTIFACT_ROOT}/$(BINARY)-linux-arm64 $(GOFLAGS) ./cmd/edgex-cli
GOOS=darwin GOARCH=amd64 $(GO) build -o ${ARTIFACT_ROOT}/$(BINARY)-mac $(GOFLAGS) ./cmd/edgex-cli
GOOS=windows GOARCH=amd64 $(GO) build -o ${ARTIFACT_ROOT}/$(BINARY).exe $(GOFLAGS) ./cmd/edgex-cli
tar -czvf ${ARTIFACT_ROOT}/$(BINARY)-linux-amd64-$(VERSION).tar.gz Attribution.txt LICENSE res/sample-configuration.toml ${ARTIFACT_ROOT}/$(BINARY)-linux-amd64 --transform 's/-linux-amd64//'
tar -czvf ${ARTIFACT_ROOT}/$(BINARY)-linux-arm64-$(VERSION).tar.gz Attribution.txt LICENSE res/sample-configuration.toml ${ARTIFACT_ROOT}/$(BINARY)-linux-arm64 --transform 's/-linux-arm64//'
tar -czvf ${ARTIFACT_ROOT}/$(BINARY)-mac-$(VERSION).tar.gz Attribution.txt LICENSE res/sample-configuration.toml ${ARTIFACT_ROOT}/$(BINARY)-mac --transform 's/-mac//'
zip ${ARTIFACT_ROOT}/$(BINARY)-win-$(VERSION).zip ${ARTIFACT_ROOT}/$(BINARY).exe Attribution.txt LICENSE res/sample-configuration.toml
test:
$(GO) test ./... -coverprofile coverage.out
GO111MODULE=on go vet ./...
gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")
[ "`gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")`" = "" ]
./bin/test-attribution-txt.sh
install:
@echo "GOBIN=$(GOBIN)"
$(GO) install $(GOFLAGS)
uninstall:
@echo "GOBIN=$(GOBIN)"
rm -f $(GOBIN)/$(BINARY)
rm -rf $(HOME)/.edgex-cli
clean: uninstall
rm -f $(BINARY)*
rm -rf $(ARTIFACT_ROOT)/$(BINARY)*
vendor:
$(GO) mod vendor