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
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
2017-03-13 11:55:44 -04:00
coredns : check
2016-08-05 18:19:51 -07:00
go build $( BUILD_VERBOSE) -ldflags= "-s -w"
2016-04-13 20:14:13 +01:00
2016-04-28 11:07:44 -07:00
.PHONY : deps
2017-03-13 11:55:44 -04:00
deps : core /zmiddleware .go core /dnsserver /zdirectives .go
2016-07-07 01:40:58 -07:00
go get ${ BUILD_VERBOSE }
2017-03-05 14:17:05 -08:00
go get -u github.com/golang/lint/golint
.PHONY : check
check : fmt deps
2016-04-28 11:07:44 -07:00
.PHONY : test
2017-03-05 14:17:05 -08:00
test : check
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 : testk 8s
2017-03-05 14:17:05 -08:00
testk8s : check
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
2017-03-05 14:17:05 -08:00
coverage : check
2016-09-26 14:22:48 +08:00
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-02-16 12:12:19 -05:00
core/zmiddleware.go core/dnsserver/zdirectives.go : middleware .cfg
go generate coredns.go
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
2017-02-22 10:28:04 -08:00
.PHONY : fmt
fmt :
## run go fmt
@test -z " $$ (gofmt -s -l . | grep -v vendor/ | tee /dev/stderr) " || \
( echo "please format Go code with 'gofmt -s -w'" && false )
2017-03-05 14:17:05 -08:00
.PHONY : lint
lint : deps
## run go lint, suggestion only (not enforced)
@test -z " $$ (golint ./... | grep -v vendor/ | grep -v " .pb.go:" | grep -vE " context\. Context should be the first parameter of a function " | tee /dev/stderr)"
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