2016-07-07 01:40:58 -07:00
|
|
|
BUILD_VERBOSE := -v
|
|
|
|
|
|
2016-07-14 14:50:14 -07:00
|
|
|
TEST_VERBOSE := -v
|
2016-06-06 12:49:53 -07:00
|
|
|
|
2017-02-09 13:27:31 -05:00
|
|
|
DOCKER_IMAGE_NAME ?= $$USER/coredns
|
|
|
|
|
DOCKER_VERSION ?= $(shell grep 'coreVersion' coremain/version.go | awk '{ print $$3 }' | tr -d '"')
|
2016-08-05 18:19:51 -07:00
|
|
|
|
2016-08-19 17:14:17 -07:00
|
|
|
all: coredns
|
2016-08-05 18:19:51 -07:00
|
|
|
|
2016-08-19 17:14:17 -07:00
|
|
|
# Phony this to ensure we always build the binary.
|
|
|
|
|
# TODO: Add .go file dependencies.
|
|
|
|
|
.PHONY: coredns
|
2016-09-24 22:47:30 +01:00
|
|
|
coredns: deps
|
2016-08-05 18:19:51 -07:00
|
|
|
go build $(BUILD_VERBOSE) -ldflags="-s -w"
|
2016-04-13 20:14:13 +01:00
|
|
|
|
|
|
|
|
.PHONY: docker
|
2016-08-19 17:14:17 -07:00
|
|
|
docker: deps
|
|
|
|
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w"
|
2016-08-05 18:19:51 -07:00
|
|
|
docker build -t $(DOCKER_IMAGE_NAME) .
|
2016-11-07 14:12:01 +00:00
|
|
|
docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(DOCKER_VERSION)
|
2016-04-28 11:07:44 -07:00
|
|
|
|
|
|
|
|
.PHONY: deps
|
2016-09-24 22:47:30 +01:00
|
|
|
deps:
|
2016-07-07 01:40:58 -07:00
|
|
|
go get ${BUILD_VERBOSE}
|
2016-04-28 11:07:44 -07:00
|
|
|
|
|
|
|
|
.PHONY: test
|
2016-08-19 17:14:17 -07:00
|
|
|
test: deps
|
2016-11-05 14:38:49 +00:00
|
|
|
go test -race $(TEST_VERBOSE) ./test ./middleware/...
|
2016-04-28 11:07:44 -07:00
|
|
|
|
2016-07-14 14:50:14 -07:00
|
|
|
.PHONY: testk8s
|
2016-08-19 17:14:17 -07:00
|
|
|
testk8s: deps
|
2016-10-17 18:37:56 +01:00
|
|
|
go test -race $(TEST_VERBOSE) -tags=k8s -run 'TestKubernetes' ./test ./middleware/kubernetes/...
|
2016-08-05 18:19:51 -07:00
|
|
|
|
2016-09-26 14:22:48 +08:00
|
|
|
.PHONY: coverage
|
|
|
|
|
coverage: deps
|
|
|
|
|
set -e -x
|
|
|
|
|
echo "" > coverage.txt
|
|
|
|
|
for d in `go list ./... | grep -v vendor`; do \
|
2016-09-27 07:57:04 +08:00
|
|
|
go test $(TEST_VERBOSE) -tags 'etcd k8s' -race -coverprofile=cover.out -covermode=atomic -bench=. $$d || exit 1; \
|
|
|
|
|
if [ -f cover.out ]; then \
|
|
|
|
|
cat cover.out >> coverage.txt; \
|
|
|
|
|
rm cover.out; \
|
2016-09-26 14:22:48 +08:00
|
|
|
fi; \
|
|
|
|
|
done
|
|
|
|
|
|
2016-04-28 11:07:44 -07:00
|
|
|
.PHONY: clean
|
|
|
|
|
clean:
|
|
|
|
|
go clean
|
2016-08-19 17:14:17 -07:00
|
|
|
rm -f coredns
|
|
|
|
|
|
2017-01-31 12:25:02 -05:00
|
|
|
.PHONY: gen
|
|
|
|
|
gen:
|
2017-02-14 19:23:18 +00:00
|
|
|
go generate coredns.go
|
2017-01-31 12:25:02 -05:00
|
|
|
|
2016-08-19 17:14:17 -07:00
|
|
|
.PHONY: distclean
|
|
|
|
|
distclean: clean
|
|
|
|
|
# Clean all dependencies and build artifacts
|
|
|
|
|
find $(GOPATH)/pkg -maxdepth 1 -mindepth 1 | xargs rm -rf
|
|
|
|
|
find $(GOPATH)/bin -maxdepth 1 -mindepth 1 | xargs rm -rf
|
2016-11-07 14:12:01 +00:00
|
|
|
|
2016-08-19 17:14:17 -07:00
|
|
|
find $(GOPATH)/src -maxdepth 1 -mindepth 1 | grep -v github | xargs rm -rf
|
|
|
|
|
find $(GOPATH)/src -maxdepth 2 -mindepth 2 | grep -v miekg | xargs rm -rf
|
|
|
|
|
find $(GOPATH)/src/github.com/miekg -maxdepth 1 -mindepth 1 \! -name \*coredns\* | xargs rm -rf
|