-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathMakefile
59 lines (46 loc) · 1.65 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
BINARY_NAME := go-dnscollector
GO_VERSION := 1.21
GO_LOGGER := 0.3.0
GO_POWERDNS_PROTOBUF := 0.2.0
GO_DNSTAP_PROTOBUF := 0.6.0
GO_FRAMESTREAM := 0.6.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 --abbrev=0 ${COMMIT} 2>/dev/null | cut -c2-)
VERSION := $(or $(VERSION),$(COMMIT))
LD_FLAGS ?=
LD_FLAGS += -s -w # disable debug informations
LD_FLAGS += -X github.com/prometheus/common/version.Version=$(VERSION)
LD_FLAGS += -X github.com/prometheus/common/version.Revision=$(COMMIT)
LD_FLAGS += -X github.com/prometheus/common/version.Branch=$(BRANCH)
LD_FLAGS += -X github.com/prometheus/common/version.BuildDate=$(BUILD_TIME)
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}
version: build
./${BINARY_NAME} -v
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 90s ./loggers/ -race -cover -v
clean:
@go clean