telegraf/Makefile

148 lines
3.6 KiB
Makefile
Raw Normal View History

2018-07-12 05:57:46 +00:00
ifeq ($(SHELL), cmd)
VERSION := $(shell git describe --exact-match --tags 2>nil)
HOME := $(HOMEPATH)
else ifeq ($(SHELL), sh.exe)
VERSION := $(shell git describe --exact-match --tags 2>nil)
HOME := $(HOMEPATH)
else
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
endif
2017-08-03 18:54:05 +00:00
PREFIX := /usr/local
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 -s $(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)
2018-07-12 05:57:46 +00:00
else
PATH := $(subst :,/bin:,$(shell go env 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
.PHONY: all
2017-08-09 18:47:55 +00:00
all:
@$(MAKE) --no-print-directory deps
@$(MAKE) --no-print-directory telegraf
2017-08-03 18:54:05 +00:00
.PHONY: deps
2017-08-03 18:54:05 +00:00
deps:
2018-07-12 05:57:46 +00:00
dep ensure -vendor-only
2017-08-03 18:54:05 +00:00
.PHONY: telegraf
2017-08-03 18:54:05 +00:00
telegraf:
2018-05-04 21:08:23 +00:00
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
.PHONY: go-install
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
.PHONY: install
2017-08-03 18:54:05 +00:00
install: telegraf
mkdir -p $(DESTDIR)$(PREFIX)/bin/
cp telegraf $(DESTDIR)$(PREFIX)/bin/
.PHONY: test
2017-08-03 18:54:05 +00:00
test:
go test -short ./...
.PHONY: fmt
2018-02-01 23:05:39 +00:00
fmt:
@gofmt -s -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))
2018-02-01 23:05:39 +00:00
.PHONY: fmtcheck
2018-02-01 23:05:39 +00:00
fmtcheck:
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
.PHONY: test-windows
2017-08-03 18:54:05 +00:00
test-windows:
2018-06-22 00:46:58 +00:00
go test -short ./plugins/inputs/ping/...
go test -short ./plugins/inputs/win_perf_counters/...
go test -short ./plugins/inputs/win_services/...
go test -short ./plugins/inputs/procstat/...
go test -short ./plugins/inputs/ntpq/...
2017-08-03 18:54:05 +00:00
.PHONY: vet
2018-02-01 23:05:39 +00:00
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
.PHONY: check
check: fmtcheck vet
2018-04-02 21:13:15 +00:00
.PHONY: test-all
2018-04-02 21:13:15 +00:00
test-all: fmtcheck vet
2017-08-03 18:54:05 +00:00
go test ./...
.PHONY: package
package:
./scripts/build.py --package --platform=all --arch=all
2017-11-07 21:54:36 +00:00
.PHONY: package-release
package-release:
./scripts/build.py --release --package --platform=all --arch=all \
--upload --bucket=dl.influxdata.com/telegraf/releases
.PHONY: package-nightly
package-nightly:
./scripts/build.py --nightly --package --platform=all --arch=all \
--upload --bucket=dl.influxdata.com/telegraf/nightlies
.PHONY: clean
2017-08-03 18:54:05 +00:00
clean:
2018-02-01 23:05:39 +00:00
rm -f telegraf
rm -f telegraf.exe
.PHONY: docker-image
docker-image:
docker build -f scripts/stretch.docker -t "telegraf:$(COMMIT)" .
plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl
ragel -Z -G2 $^ -o $@
.PHONY: static
static:
@echo "Building static linux binary..."
@CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
.PHONY: plugin-%
plugin-%:
@echo "Starting dev environment for $${$(@)} input plugin..."
@docker-compose -f plugins/inputs/$${$(@)}/dev/docker-compose.yml up
2018-10-19 18:01:31 +00:00
.PHONY: ci-1.11
ci-1.11:
2019-01-26 02:08:48 +00:00
docker build -t quay.io/influxdb/telegraf-ci:1.11.5 - < scripts/ci-1.11.docker
docker push quay.io/influxdb/telegraf-ci:1.11.5
2018-10-19 18:01:31 +00:00
.PHONY: ci-1.10
ci-1.10:
2019-01-26 02:08:48 +00:00
docker build -t quay.io/influxdb/telegraf-ci:1.10.8 - < scripts/ci-1.10.docker
docker push quay.io/influxdb/telegraf-ci:1.10.8
.PHONY: ci-1.9
ci-1.9:
docker build -t quay.io/influxdb/telegraf-ci:1.9.7 - < scripts/ci-1.9.docker
docker push quay.io/influxdb/telegraf-ci:1.9.7