-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (33 loc) · 1.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
BIN_OUTPUT_PATH = bin
TOOL_BIN = bin/gotools/$(shell uname -s)-$(shell uname -m)
COMMON_LDFLAGS = -s -w #-X 'go.viam.com/rdk/config.Version=${TAG_VERSION}' -X 'go.viam.com/rdk/config.GitRevision=${GIT_REVISION}' -X 'go.viam.com/rdk/config.DateCompiled=${DATE_COMPILED}'
UNAME_S ?= $(shell uname -s)
ifeq ($(shell command -v dpkg >/dev/null && dpkg --print-architecture),armhf)
GOFLAGS += -tags=no_tflite
endif
module: build
rm -f $(BIN_OUTPUT_PATH)/module.tar.gz
tar czf $(BIN_OUTPUT_PATH)/module.tar.gz $(BIN_OUTPUT_PATH)/wit-motion meta.json
build: build-go
build-go:
rm -f $(BIN_OUTPUT_PATH)/wit-motion
go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o $(BIN_OUTPUT_PATH)/wit-motion main.go
tool-install:
GOBIN=`pwd`/$(TOOL_BIN) go install \
github.com/edaniels/golinters/cmd/combined \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/AlekSi/gocov-xml \
github.com/axw/gocov/gocov \
gotest.tools/gotestsum \
github.com/rhysd/actionlint/cmd/actionlint
lint: lint-go
PATH=$(TOOL_BIN) actionlint
lint-go: tool-install
go mod tidy
export pkgs="`go list -f '{{.Dir}}' ./... | grep -v /proto/`" && echo "$$pkgs" | xargs go vet -vettool=$(TOOL_BIN)/combined
GOGC=50 $(TOOL_BIN)/golangci-lint run -v --fix --config=./etc/golangci.yaml
test: test-go
test-go: tool-install
go test -race ./...
clean-all:
git clean -fxd