forked from edgexfoundry/device-opc-ua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (43 loc) · 1.57 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
.PHONY: build test clean docker run
GO=go
CGO=CGO_ENABLED=1 GO111MODULE=on $(GO)
MICROSERVICES=cmd/device-opcua
.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-opc-ua.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)
TEST_OUT=test-artifacts
build: $(MICROSERVICES)
$(CGO) install -tags=safe
cmd/device-opcua:
$(CGO) build $(GOFLAGS) -o $@ ./cmd
build-nats:
make -e ADD_BUILD_TAGS=include_nats_messaging build
tidy:
go mod tidy
test:
$(GO) install github.com/jstemmer/[email protected]
$(GO) install github.com/axw/gocov/[email protected]
$(GO) install github.com/AlekSi/[email protected]
$(GO) install github.com/jandelgado/[email protected]
rm -rf $(TEST_OUT)
mkdir $(TEST_OUT)
$(GO) test -v ./... -coverprofile=$(TEST_OUT)/cover.out | go-junit-report > $(TEST_OUT)/report.xml
gocov convert $(TEST_OUT)/cover.out | gocov-xml > $(TEST_OUT)/coverage.xml
gcov2lcov -infile=$(TEST_OUT)/cover.out -outfile=$(TEST_OUT)/coverage.lcov
clean:
rm -f $(MICROSERVICES)
docker:
docker build \
-f Dockerfile \
--label "git_sha=$(GIT_SHA)" \
-t edgexfoundry/device-opcua:$(GIT_SHA) \
-t edgexfoundry/device-opcua:$(DOCKER_TAG) \
.
run:
cd bin && ./edgex-launch.sh