forked from edgexfoundry/device-s7
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
61 lines (44 loc) · 1.86 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
.PHONY: build test clean docker unittest lint
ARCH=$(shell uname -m)
MICROSERVICES=cmd/device-s7
.PHONY: $(MICROSERVICES)
VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/device-sdk-go/v3 v' | sed 's/require//g' | awk '{print $$2}')
DOCKER_TAG=$(VERSION)-dev
GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-s7.Version=$(VERSION) \
-X github.com/edgexfoundry/device-sdk-go/v3/internal/common.SDKVersion=$(SDKVERSION)" \
-trimpath -mod=readonly
GOTESTFLAGS?=-race
GIT_SHA=$(shell git rev-parse HEAD)
build: $(MICROSERVICES)
build-nats:
make -e ADD_BUILD_TAGS=include_nats_messaging build
tidy:
go mod tidy
# CGO is enabled by default and cause docker builds to fail due to no gcc,
# but is required for test with -race, so must disable it for the builds only
cmd/device-s7:
CGO_ENABLED=1 go build $(GOFLAGS) -o $@ ./cmd
docker:
docker build \
-f Dockerfile \
--label "git_sha=$(GIT_SHA)" \
-t edgexfoundry/device-s7:$(GIT_SHA) \
-t edgexfoundry/device-s7:$(DOCKER_TAG) \
.
unittest:
go test $(GOTESTFLAGS) -coverprofile=coverage.out ./...
lint:
@which golangci-lint >/dev/null || echo "WARNING: go linter not installed. To install, run make install-lint"
@if [ "z${ARCH}" = "zx86_64" ] && which golangci-lint >/dev/null ; then golangci-lint run --config .golangci.yml ; else echo "WARNING: Linting skipped (not on x86_64 or linter not installed)"; fi
install-lint:
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.54.2
test: unittest lint
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
clean:
rm -f $(MICROSERVICES)
vendor:
go mod vendor