forked from dmachard/DNS-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (40 loc) · 1.32 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
BINARY_NAME := go-dnscollector
GO_VERSION := 1.20
GO_LOGGER := 0.3.0
GO_POWERDNS_PROTOBUF := 0.1.0
GO_DNSTAP_PROTOBUF := 0.5.0
GO_FRAMESTREAM := 0.3.0
BUILD_TIME := $(shell LANG=en_US date +"%F_%T_%z")
COMMIT := $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION ?= $(shell git describe --tags ${COMMIT} 2>/dev/null | cut -c2-)
VERSION := $(or $(VERSION),$(COMMIT))
LD_FLAGS ?=
LD_FLAGS += -X main.Version=$(VERSION)
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
.PHONY: all dep lint build clean
all: dep build
dep:
@go get github.com/dmachard/go-logger@v$(GO_LOGGER)
@go get github.com/dmachard/go-powerdns-protobuf@v$(GO_POWERDNS_PROTOBUF)
@go get github.com/dmachard/go-dnstap-protobuf@v$(GO_DNSTAP_PROTOBUF)
@go get github.com/dmachard/go-framestream@v$(GO_FRAMESTREAM)
@go mod edit -go=$(GO_VERSION)
@go mod tidy
build:
CGO_ENABLED=0 go build -v -ldflags="$(LD_FLAGS)" -o ${BINARY_NAME} dnscollector.go
run: build
./${BINARY_NAME}
lint:
$(GOPATH)/bin/golangci-lint run --config=.golangci.yml ./...
test:
@go test ./dnsutils/ -race -cover -v
@go test ./netlib/ -race -cover -v
@go test -timeout 30s ./transformers/ -race -cover -v
@go test -timeout 30s ./collectors/ -race -cover -v
@go test -timeout 60s ./loggers/ -race -cover -v
clean:
@go clean