-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (47 loc) · 2.47 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
PROJECT_NAME := "ctrlx-datalayer-golang"
PKG := "github.com/boschrexroth/$(PROJECT_NAME)"
PKG_LIST := ./pkg/datalayer ./pkg/sseclient ./pkg/token
COV_PKG_LIST := ./pkg/datalayer,./pkg/sseclient,./pkg/token
TST_LIST := ./test/datalayer ./test/sseclient ./test/token
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
BUILD := build/public/$(GOOS)_$(GOARCH)
SDK_RELEASE_VERSION := 3.4.0
DATALAYER_DEB_FILE_VERSION := 2.8.6
.PHONY: all go-dep apt-dep lint vet test test-coverage build clean
all: build
go-dep: ## Get go dependencies
@go get -u ./...
@go mod download
@go mod vendor
@go mod tidy
apt-dep: ## Get native dependencies
@sudo apt-get update
@sudo apt-get install -y libsystemd-dev
@wget --quiet https://github.com/boschrexroth/ctrlx-automation-sdk/releases/download/$(SDK_RELEASE_VERSION)/ctrlx-datalayer-${DATALAYER_DEB_FILE_VERSION}.deb
@sudo apt-get install -y -f ./ctrlx-datalayer-${DATALAYER_DEB_FILE_VERSION}.deb
@rm ctrlx-datalayer-${DATALAYER_DEB_FILE_VERSION}.deb
lint: ## Lint Golang files
@golangci-lint run
vet: ## Run go vet
@go vet $(PKG_LIST)
test: ## Run unittests
@go test -race -short -count=1 -mod=vendor $(TST_LIST)
memprofile: ## Run memory profiler
@go test -race -short -count=1 -mod=vendor $(TST_LIST) -memprofile mem.pprof -memprofilerate 1
@go tool pprof -http=:8080 mem.pprof
cpuprofile: ## Run cpu profiler
@go test -race -short -count=1 -mod=vendor $(TST_LIST) -cpuprofile cpu.pprof
@go tool pprof -http=:8080 cpu.pprof
testcover: ## Run unittests with coverage 'go tool cover -html=coverage.out -o coverage.html'
@go test -race -short -count=1 -mod=vendor -coverpkg=$(COV_PKG_LIST) -coverprofile=coverage.out -covermode=atomic $(TST_LIST)
testreport: ## Run unittests with coverage 'go tool cover -html=coverage.out -o coverage.html' and junit report
@go test -v 2>&1 -race -short -count=1 -mod=vendor -coverpkg=$(COV_PKG_LIST) -coverprofile=coverage.out -covermode=atomic $(TST_LIST) | go-junit-report -set-exit-code > test-results.junit.xml
build: go-dep ## Build the samples
@CGO_ENABLED=1 go build -mod=vendor -o $(BUILD)/datalayer ./cmd/datalayer
@CGO_ENABLED=1 go build -mod=vendor -o $(BUILD)/benchmark ./cmd/benchmark
clean: ## Remove previously build samples
@rm -rf $(BUILD)/*
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'