2018-05-22 17:28:04 +00:00
|
|
|
# Top level Makefile for the entire project
|
|
|
|
#
|
2018-06-25 23:24:52 +00:00
|
|
|
# This Makefile encodes the "go generate" prerequeisites ensuring that the proper tooling is installed and
|
|
|
|
# that the generate steps are executed when their prerequeisites files change.
|
|
|
|
#
|
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.
|
|
|
|
# * All recursive Makefiles must support the targets: all and clean.
|
|
|
|
#
|
|
|
|
|
2018-08-02 21:02:38 +00:00
|
|
|
SUBDIRS := query task
|
2018-07-23 21:42:03 +00:00
|
|
|
GOBINDATA := $(shell go list -f {{.Root}} github.com/kevinburke/go-bindata 2> /dev/null)
|
|
|
|
UISOURCES := $(shell find chronograf/ui -type f -not \( -path chronograf/ui/build/\* -o -path chronograf/ui/node_modules/\* -prune \) )
|
|
|
|
YARN := $(shell command -v yarn 2> /dev/null)
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
GO_ARGS=-tags '$(GO_TAGS)'
|
|
|
|
|
|
|
|
# Test vars can be used by all recursive Makefiles
|
2018-06-25 23:24:52 +00:00
|
|
|
export GOOS=$(shell go env GOOS)
|
2018-05-22 17:28:04 +00:00
|
|
|
export GO_BUILD=go build $(GO_ARGS)
|
2018-07-23 21:42:03 +00:00
|
|
|
export GO_TEST=go test -count=1 $(GO_ARGS)
|
2018-05-22 17:28:04 +00:00
|
|
|
export GO_GENERATE=go generate $(GO_ARGS)
|
2018-05-22 22:19:04 +00:00
|
|
|
export GO_VET= go vet $(GO_ARGS)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# All go source files
|
|
|
|
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go')
|
|
|
|
|
|
|
|
# All go source files excluding the vendored sources.
|
|
|
|
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
|
|
|
|
|
|
|
|
# List of binary cmds to build
|
2018-06-25 23:24:52 +00:00
|
|
|
CMDS := \
|
|
|
|
bin/$(GOOS)/influx \
|
|
|
|
bin/$(GOOS)/idpd \
|
|
|
|
bin/$(GOOS)/fluxd \
|
|
|
|
bin/$(GOOS)/transpilerd
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# List of utilities to build as part of the build process
|
2018-06-25 23:24:52 +00:00
|
|
|
UTILS := \
|
|
|
|
bin/$(GOOS)/pigeon \
|
|
|
|
bin/$(GOOS)/cmpgen \
|
2018-08-02 21:02:38 +00:00
|
|
|
bin/$(GOOS)/protoc-gen-gogofaster \
|
2018-06-25 23:24:52 +00:00
|
|
|
bin/$(GOOS)/goreleaser
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# Default target to build all commands.
|
|
|
|
#
|
|
|
|
# This target setups the dependencies to correctly build all commands.
|
|
|
|
# Other targets must depend on this target to correctly builds CMDS.
|
2018-07-24 20:18:21 +00:00
|
|
|
all: dep generate Gopkg.lock $(UTILS) subdirs $(CMDS)
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
# Target to build subdirs.
|
|
|
|
# Each subdirs must support the `all` target.
|
|
|
|
subdirs: $(SUBDIRS)
|
2018-06-25 23:24:52 +00:00
|
|
|
@for d in $^; do $(MAKE) -C $$d all; done
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Define targets for commands
|
|
|
|
#
|
2018-06-25 23:24:52 +00:00
|
|
|
$(CMDS): $(SOURCES)
|
|
|
|
$(GO_BUILD) -i -o $@ ./cmd/$(shell basename "$@")
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Define targets for utilities
|
|
|
|
#
|
|
|
|
|
2018-06-25 23:24:52 +00:00
|
|
|
bin/$(GOOS)/pigeon: ./vendor/github.com/mna/pigeon/main.go
|
|
|
|
go build -i -o $@ ./vendor/github.com/mna/pigeon
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-06-25 23:24:52 +00:00
|
|
|
bin/$(GOOS)/cmpgen: ./query/ast/asttest/cmpgen/main.go
|
|
|
|
go build -i -o $@ ./query/ast/asttest/cmpgen
|
2018-05-22 17:28:04 +00:00
|
|
|
|
2018-08-02 21:02:38 +00:00
|
|
|
bin/$(GOOS)/protoc-gen-gogofaster: vendor $(call go_deps,./vendor/github.com/gogo/protobuf/protoc-gen-gogofaster)
|
|
|
|
$(GO_BUILD) -i -o $@ ./vendor/github.com/gogo/protobuf/protoc-gen-gogofaster
|
|
|
|
|
2018-06-25 23:24:52 +00:00
|
|
|
bin/$(GOOS)/goreleaser: ./vendor/github.com/goreleaser/goreleaser/main.go
|
|
|
|
go build -i -o $@ ./vendor/github.com/goreleaser/goreleaser
|
2018-05-22 20:42:32 +00:00
|
|
|
|
2018-07-23 21:42:03 +00:00
|
|
|
dep: .jsdep .godep
|
|
|
|
|
|
|
|
.godep:
|
|
|
|
ifndef GOBINDATA
|
|
|
|
@echo "Installing go-bindata"
|
|
|
|
go get -u github.com/kevinburke/go-bindata/...
|
|
|
|
endif
|
|
|
|
@touch .godep
|
|
|
|
|
|
|
|
.jsdep: chronograf/ui/yarn.lock
|
|
|
|
ifndef YARN
|
|
|
|
$(error Please install yarn 0.19.1+)
|
|
|
|
else
|
|
|
|
mkdir -p chronograf/ui/build && cd chronograf/ui && yarn --no-progress --no-emoji
|
|
|
|
@touch .jsdep
|
|
|
|
endif
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
#
|
|
|
|
# Define how source dependencies are managed
|
|
|
|
#
|
|
|
|
|
|
|
|
Gopkg.lock: Gopkg.toml
|
|
|
|
dep ensure -v
|
2018-06-19 21:30:58 +00:00
|
|
|
touch Gopkg.lock
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
vendor/github.com/mna/pigeon/main.go: Gopkg.lock
|
2018-05-22 20:42:32 +00:00
|
|
|
dep ensure -v -vendor-only
|
|
|
|
|
|
|
|
vendor/github.com/goreleaser/goreleaser/main.go: Gopkg.lock
|
|
|
|
dep ensure -v -vendor-only
|
2018-05-22 17:28:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Define action only targets
|
|
|
|
#
|
|
|
|
|
|
|
|
fmt: $(SOURCES_NO_VENDOR)
|
|
|
|
goimports -w $^
|
|
|
|
|
2018-07-24 20:18:21 +00:00
|
|
|
generate:
|
2018-07-26 21:46:28 +00:00
|
|
|
# TODO: re-enable these after we decide on a strategy for building without running `go generate`.
|
|
|
|
# $(GO_GENERATE) ./chronograf/dist/...
|
|
|
|
# $(GO_GENERATE) ./chronograf/server/...
|
|
|
|
# $(GO_GENERATE) ./chronograf/canned/...
|
2018-07-24 20:18:21 +00:00
|
|
|
|
|
|
|
jstest:
|
|
|
|
cd chronograf/ui && yarn test --runInBand
|
|
|
|
|
|
|
|
test: all jstest
|
2018-05-22 17:28:04 +00:00
|
|
|
$(GO_TEST) ./...
|
|
|
|
|
|
|
|
test-race: all
|
|
|
|
$(GO_TEST) -race ./...
|
|
|
|
|
2018-05-22 22:19:04 +00:00
|
|
|
vet: all
|
|
|
|
$(GO_VET) -v ./...
|
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
bench: all
|
|
|
|
$(GO_TEST) -bench=. -run=^$$ ./...
|
|
|
|
|
2018-07-02 16:36:41 +00:00
|
|
|
nightly: bin/$(GOOS)/goreleaser all
|
|
|
|
PATH=./bin/$(GOOS):${PATH} goreleaser --snapshot --rm-dist
|
2018-07-17 19:03:40 +00:00
|
|
|
docker push quay.io/influxdb/flux:nightly
|
2018-05-22 20:42:32 +00:00
|
|
|
|
2018-05-22 17:28:04 +00:00
|
|
|
# Recursively clean all subdirs
|
|
|
|
clean: $(SUBDIRS)
|
2018-06-25 23:24:52 +00:00
|
|
|
@for d in $^; do $(MAKE) -C $$d $(MAKECMDGOALS); done
|
2018-05-22 17:28:04 +00:00
|
|
|
rm -rf bin
|
|
|
|
|
|
|
|
# .PHONY targets represent actions that do not create an actual file.
|
|
|
|
.PHONY: all subdirs $(SUBDIRS) fmt test test-race bench clean
|