2018-05-22 17:28:04 +00:00
|
|
|
# Top level Makefile for the entire project
|
|
|
|
#
|
2019-12-11 03:45:25 +00:00
|
|
|
# This Makefile encodes the "go generate" prerequisites ensuring that the proper tooling is installed and
|
|
|
|
# that the generate steps are executed when their prerequisite files change.
|
2018-06-25 23:24:52 +00:00
|
|
|
#
|
2018-05-22 17:28:04 +00:00
|
|
|
# This Makefile follows a few conventions:
|
|
|
|
#
|
|
|
|
# * All cmds must be added to this top level Makefile.
|
|
|
|
# * All binaries are placed in ./bin, its recommended to add this directory to your PATH.
|
|
|
|
# * Each package that has a need to run go generate, must have its own Makefile for that purpose.
|
2018-12-18 18:04:42 +00:00
|
|
|
# * All recursive Makefiles must support the all and clean targets
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
|
2018-12-18 18:04:42 +00:00
|
|
|
# SUBDIRS are directories that have their own Makefile.
|
2019-12-11 03:45:25 +00:00
|
|
|
# It is required that all SUBDIRS have the `all` and `clean` targets.
|
2019-06-06 16:05:27 +00:00
|
|
|
SUBDIRS := http ui chronograf query storage
|
2019-12-11 03:45:25 +00:00
|
|
|
# The 'libflux' tag is required for instructing the flux to be compiled with the Rust parser
|
|
|
|
GO_TAGS=libflux
|
2018-05-22 17:28:04 +00:00
|
|
|
GO_ARGS=-tags '$(GO_TAGS)'
|
2019-12-30 19:53:52 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
VERSION := $(shell git describe --exact-match --tags 2>nil)
|
|
|
|
else
|
|
|
|
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
|
|
|
|
endif
|
|
|
|
COMMIT := $(shell git rev-parse --short HEAD)
|
|
|
|
|
2019-12-31 00:56:58 +00:00
|
|
|
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT)
|
2019-12-30 19:53:52 +00:00
|
|
|
ifdef VERSION
|
|
|
|
LDFLAGS += -X main.version=$(VERSION)
|
|
|
|
endif
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# Test vars can be used by all recursive Makefiles
|
2018-06-25 23:24:52 +00:00
|
|
|
export GOOS=$(shell go env GOOS)
|
2019-12-30 19:53:52 +00:00
|
|
|
export GO_BUILD=env GO111MODULE=on CGO_LDFLAGS="$$(cat .cgo_ldflags)" go build $(GO_ARGS) -ldflags "$(LDFLAGS)"
|
|
|
|
export GO_INSTALL=env GO111MODULE=on CGO_LDFLAGS="$$(cat .cgo_ldflags)" go install $(GO_ARGS) -ldflags "$(LDFLAGS)"
|
2019-12-11 03:45:25 +00:00
|
|
|
export GO_TEST=env FLUX_PARSER_TYPE=rust GOTRACEBACK=all GO111MODULE=on CGO_LDFLAGS="$$(cat .cgo_ldflags)" go test $(GO_ARGS)
|
2018-08-26 18:54:24 +00:00
|
|
|
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
|
2018-05-22 17:28:04 +00:00
|
|
|
export GO_GENERATE=go generate $(GO_ARGS)
|
2019-12-11 03:45:25 +00:00
|
|
|
export GO_VET=env GO111MODULE=on CGO_LDFLAGS="$$(cat .cgo_ldflags)" go vet $(GO_ARGS)
|
2018-12-20 19:17:02 +00:00
|
|
|
export GO_RUN=env GO111MODULE=on go run $(GO_ARGS)
|
2018-09-11 15:22:06 +00:00
|
|
|
export PATH := $(PWD)/bin/$(GOOS):$(PATH)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# All go source files
|
2019-01-16 22:00:38 +00:00
|
|
|
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go') go.mod go.sum
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# All go source files excluding the vendored sources.
|
|
|
|
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
|
|
|
|
|
2018-09-11 20:55:36 +00:00
|
|
|
# All assets for chronograf
|
2018-10-25 15:20:35 +00:00
|
|
|
UISOURCES := $(shell find ui -type f -not \( -path ui/build/\* -o -path ui/node_modules/\* -o -path ui/.cache/\* -o -name Makefile -prune \) )
|
2018-09-11 20:55:36 +00:00
|
|
|
|
|
|
|
# All precanned dashboards
|
|
|
|
PRECANNED := $(shell find chronograf/canned -name '*.json')
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# List of binary cmds to build
|
2018-06-25 23:24:52 +00:00
|
|
|
CMDS := \
|
|
|
|
bin/$(GOOS)/influx \
|
2018-09-25 23:02:06 +00:00
|
|
|
bin/$(GOOS)/influxd
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
# Default target to build all go commands.
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
2018-08-27 15:34:17 +00:00
|
|
|
# This target sets up the dependencies to correctly build all go commands.
|
2018-05-22 17:28:04 +00:00
|
|
|
# Other targets must depend on this target to correctly builds CMDS.
|
2019-05-01 17:50:17 +00:00
|
|
|
ifeq ($(GOARCH), arm64)
|
2019-12-11 03:45:25 +00:00
|
|
|
all: GO_ARGS=-tags 'assets noasm $(GO_TAGS)'
|
2019-05-01 17:50:17 +00:00
|
|
|
else
|
|
|
|
all: GO_ARGS=-tags 'assets $(GO_TAGS)'
|
|
|
|
endif
|
2020-01-16 23:01:53 +00:00
|
|
|
all: $(SUBDIRS) generate $(CMDS)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# Target to build subdirs.
|
|
|
|
# Each subdirs must support the `all` target.
|
2020-01-16 23:01:53 +00:00
|
|
|
$(SUBDIRS):
|
|
|
|
$(MAKE) -C $@ all
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Define targets for commands
|
|
|
|
#
|
2019-12-11 03:45:25 +00:00
|
|
|
$(CMDS): $(SOURCES) libflux
|
2018-09-25 16:33:07 +00:00
|
|
|
$(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2019-09-04 14:00:20 +00:00
|
|
|
# Ease of use build for just the go binary
|
|
|
|
influxd: bin/$(GOOS)/influxd
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
2018-10-15 14:39:01 +00:00
|
|
|
# Define targets for the web ui
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
|
2018-10-25 15:20:35 +00:00
|
|
|
node_modules: ui/node_modules
|
2018-08-27 15:34:17 +00:00
|
|
|
|
2019-02-19 23:47:19 +00:00
|
|
|
# phony target to wait for server to be alive
|
|
|
|
ping:
|
|
|
|
./etc/pinger.sh
|
|
|
|
|
|
|
|
e2e: ping
|
|
|
|
make -C ui e2e
|
|
|
|
|
2018-09-27 17:46:48 +00:00
|
|
|
chronograf_lint:
|
2018-10-25 15:20:35 +00:00
|
|
|
make -C ui lint
|
2018-09-27 17:46:48 +00:00
|
|
|
|
2018-10-25 15:20:35 +00:00
|
|
|
ui/node_modules:
|
|
|
|
make -C ui node_modules
|
2018-07-23 21:42:03 +00:00
|
|
|
|
2019-08-07 20:42:35 +00:00
|
|
|
ui_client:
|
|
|
|
make -C ui client
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
# Define action only targets
|
|
|
|
#
|
|
|
|
|
2019-12-11 03:45:25 +00:00
|
|
|
libflux: .cgo_ldflags
|
|
|
|
|
|
|
|
.cgo_ldflags: go.mod
|
|
|
|
$(GO_RUN) github.com/influxdata/flux/internal/cmd/flux-config --libs --verbose > .cgo_ldflags.tmp
|
|
|
|
mv .cgo_ldflags.tmp .cgo_ldflags
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
fmt: $(SOURCES_NO_VENDOR)
|
2018-10-08 18:16:06 +00:00
|
|
|
gofmt -w -s $^
|
|
|
|
|
2018-10-10 16:31:37 +00:00
|
|
|
checkfmt:
|
2018-10-08 18:16:06 +00:00
|
|
|
./etc/checkfmt.sh
|
2019-02-16 00:58:20 +00:00
|
|
|
$(GO_RUN) github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-10-10 16:31:37 +00:00
|
|
|
tidy:
|
|
|
|
GO111MODULE=on go mod tidy
|
|
|
|
|
|
|
|
checktidy:
|
|
|
|
./etc/checktidy.sh
|
|
|
|
|
2018-12-18 18:04:42 +00:00
|
|
|
checkgenerate:
|
|
|
|
./etc/checkgenerate.sh
|
2018-07-24 20:18:21 +00:00
|
|
|
|
2019-03-13 22:48:30 +00:00
|
|
|
checkcommit:
|
|
|
|
./etc/circle-detect-committed-binaries.sh
|
|
|
|
|
2020-01-16 23:01:53 +00:00
|
|
|
generate: $(SUBDIRS)
|
2018-09-11 20:55:36 +00:00
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
test-js: node_modules
|
2018-10-25 15:20:35 +00:00
|
|
|
make -C ui test
|
2018-07-24 20:18:21 +00:00
|
|
|
|
2019-12-11 03:45:25 +00:00
|
|
|
test-go: libflux
|
2018-05-22 17:28:04 +00:00
|
|
|
$(GO_TEST) ./...
|
|
|
|
|
2019-07-15 10:43:15 +00:00
|
|
|
test-promql-e2e:
|
|
|
|
cd query/promql/internal/promqltests; go test ./...
|
|
|
|
|
2018-11-16 16:45:00 +00:00
|
|
|
test-integration: GO_TAGS=integration
|
|
|
|
test-integration:
|
|
|
|
$(GO_TEST) -count=1 ./...
|
|
|
|
|
2018-08-27 15:34:17 +00:00
|
|
|
test: test-go test-js
|
|
|
|
|
2019-12-11 03:45:25 +00:00
|
|
|
test-go-race: libflux
|
2018-12-05 18:36:19 +00:00
|
|
|
$(GO_TEST) -v -race -count=1 ./...
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2019-12-11 03:45:25 +00:00
|
|
|
vet: libflux
|
2018-05-22 22:19:04 +00:00
|
|
|
$(GO_VET) -v ./...
|
|
|
|
|
2019-12-11 03:45:25 +00:00
|
|
|
bench: libflux
|
2018-05-22 17:28:04 +00:00
|
|
|
$(GO_TEST) -bench=. -run=^$$ ./...
|
|
|
|
|
2018-12-20 17:13:41 +00:00
|
|
|
build: all
|
|
|
|
|
2019-01-16 16:11:37 +00:00
|
|
|
dist:
|
2019-01-23 20:19:05 +00:00
|
|
|
$(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --config=.goreleaser-nightly.yml
|
2019-01-16 16:11:37 +00:00
|
|
|
|
2018-12-20 22:17:32 +00:00
|
|
|
nightly:
|
2019-01-23 20:19:05 +00:00
|
|
|
$(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --publish-snapshots --config=.goreleaser-nightly.yml
|
|
|
|
|
|
|
|
release:
|
|
|
|
$(GO_INSTALL) github.com/goreleaser/goreleaser
|
2019-08-07 20:42:35 +00:00
|
|
|
git checkout -- go.sum # avoid dirty git repository caused by go install
|
2019-01-23 20:19:05 +00:00
|
|
|
goreleaser release --rm-dist
|
2018-05-22 20:42:32 +00:00
|
|
|
|
2018-11-16 02:12:00 +00:00
|
|
|
clean:
|
2018-12-18 18:04:42 +00:00
|
|
|
@for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
|
2019-01-16 01:45:38 +00:00
|
|
|
$(RM) -r bin
|
|
|
|
$(RM) -r dist
|
2019-12-11 03:45:25 +00:00
|
|
|
$(RM) .cgo_ldflags
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-09-25 22:40:46 +00:00
|
|
|
define CHRONOGIRAFFE
|
|
|
|
._ o o
|
|
|
|
\_`-)|_
|
|
|
|
,"" _\_
|
|
|
|
," ## | 0 0.
|
|
|
|
," ## ,-\__ `.
|
|
|
|
," / `--._;) - "HAI, I'm Chronogiraffe. Let's be friends!"
|
|
|
|
," ## /
|
|
|
|
," ## /
|
|
|
|
endef
|
|
|
|
export CHRONOGIRAFFE
|
2020-01-16 23:01:53 +00:00
|
|
|
chronogiraffe: $(SUBDIRS) generate $(CMDS)
|
2018-09-25 22:40:46 +00:00
|
|
|
@echo "$$CHRONOGIRAFFE"
|
|
|
|
|
|
|
|
run: chronogiraffe
|
2019-02-19 23:47:19 +00:00
|
|
|
./bin/$(GOOS)/influxd --assets-path=ui/build
|
|
|
|
|
|
|
|
run-e2e: chronogiraffe
|
|
|
|
./bin/$(GOOS)/influxd --assets-path=ui/build --e2e-testing --store=memory
|
2018-09-25 22:40:46 +00:00
|
|
|
|
2019-02-19 23:47:19 +00:00
|
|
|
# assume this is running from circleci
|
|
|
|
protoc:
|
|
|
|
curl -s -L https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip > /tmp/protoc.zip
|
|
|
|
unzip -o -d /go /tmp/protoc.zip
|
|
|
|
chmod +x /go/bin/protoc
|
2018-09-25 22:40:46 +00:00
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# .PHONY targets represent actions that do not create an actual file.
|
2020-01-16 23:01:53 +00:00
|
|
|
.PHONY: all $(SUBDIRS) run fmt checkfmt tidy checktidy checkgenerate test test-go test-js test-go-race bench clean node_modules vet nightly chronogiraffe dist ping protoc e2e run-e2e influxd libflux
|