telegraf/Makefile

96 lines
2.5 KiB
Makefile
Raw Permalink Normal View History

2017-08-03 18:54:05 +00:00
PREFIX := /usr/local
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git rev-parse --short HEAD)
GOFILES ?= $(shell git ls-files '*.go')
GOFMT ?= $(shell gofmt -l $(filter-out plugins/parsers/influx/machine.go, $(GOFILES)))
2018-04-10 22:35:58 +00:00
BUILDFLAGS ?=
2018-02-01 23:05:39 +00:00
ifdef GOBIN
PATH := $(GOBIN):$(PATH)
else
PATH := $(subst :,/bin:,$(GOPATH))/bin:$(PATH)
endif
2017-08-10 23:33:31 +00:00
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT) -X main.branch=$(BRANCH)
ifdef VERSION
LDFLAGS += -X main.version=$(VERSION)
endif
2017-08-09 18:47:55 +00:00
all:
$(MAKE) deps
$(MAKE) telegraf
2017-08-03 18:54:05 +00:00
deps:
2018-02-01 23:05:39 +00:00
go get -u github.com/golang/lint/golint
go get -u github.com/golang/dep/cmd/dep
dep ensure
2017-08-03 18:54:05 +00:00
telegraf:
2018-05-04 21:08:23 +00:00
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
2017-08-03 18:54:05 +00:00
go-install:
2017-08-07 22:47:20 +00:00
go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf
2017-08-03 18:54:05 +00:00
install: telegraf
mkdir -p $(DESTDIR)$(PREFIX)/bin/
cp telegraf $(DESTDIR)$(PREFIX)/bin/
2017-08-03 18:54:05 +00:00
test:
go test -short ./...
2018-02-01 23:05:39 +00:00
fmt:
@gofmt -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))
2018-02-01 23:05:39 +00:00
fmtcheck:
@echo '[INFO] running gofmt to identify incorrectly formatted code...'
2018-04-10 22:35:58 +00:00
@if [ ! -z "$(GOFMT)" ]; then \
2018-02-01 23:05:39 +00:00
echo "[ERROR] gofmt has found errors in the following files:" ; \
echo "$(GOFMT)" ; \
echo "" ;\
echo "Run make fmt to fix them." ; \
exit 1 ;\
fi
@echo '[INFO] done.'
2017-08-03 18:54:05 +00:00
test-windows:
go test ./plugins/inputs/ping/...
go test ./plugins/inputs/win_perf_counters/...
go test ./plugins/inputs/win_services/...
go test ./plugins/inputs/procstat/...
2018-04-05 01:35:05 +00:00
go test ./plugins/inputs/ntpq/...
2017-08-03 18:54:05 +00:00
2018-02-01 23:05:39 +00:00
# vet runs the Go source code static analysis tool `vet` to find
# any common errors.
vet:
@echo 'go vet $$(go list ./... | grep -v ./plugins/parsers/influx)'
2018-04-10 22:35:58 +00:00
@go vet $$(go list ./... | grep -v ./plugins/parsers/influx) ; if [ $$? -ne 0 ]; then \
2018-02-01 23:05:39 +00:00
echo ""; \
echo "go vet has found suspicious constructs. Please remediate any reported errors"; \
echo "to fix them before submitting code for review."; \
exit 1; \
fi
2018-04-02 21:13:15 +00:00
test-ci: fmtcheck vet
2018-04-10 22:35:58 +00:00
go test -short ./...
2018-04-02 21:13:15 +00:00
test-all: fmtcheck vet
2017-08-03 18:54:05 +00:00
go test ./...
package:
./scripts/build.py --package --platform=all --arch=all
2017-11-07 21:54:36 +00:00
2017-08-03 18:54:05 +00:00
clean:
2018-02-01 23:05:39 +00:00
rm -f telegraf
rm -f telegraf.exe
docker-image:
./scripts/build.py --package --platform=linux --arch=amd64
cp build/telegraf*$(COMMIT)*.deb .
docker build -f scripts/dev.docker --build-arg "package=telegraf*$(COMMIT)*.deb" -t "telegraf-dev:$(COMMIT)" .
plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl
ragel -Z -G2 $^ -o $@
.PHONY: deps telegraf install test test-windows lint vet test-all package clean docker-image fmtcheck uint64