Consolidation of Makefile and Makefile.release (#912)

* Consolidation of Makefile and Makefile.release

Several changes:
1. All go specific target like `go generate`, etc. has
been moved to Makefile. Now Makefile.release does not
repeat go build, etc. related rules.
2. In Makefile.release, the binary build is done through
`docker run` and with a fixed specific go version (currently 1.8.3).
This will help making sure build process could be reproduced
on any dev platform, with no dependency to the golang version
installed on the platform.
3. Platform related flags (e.g., "GOOS=darwin") are passed through
Makefile (not Makefile.release).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Update to only use `make` without running inside `docker run`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2017-08-13 09:41:50 -07:00
committed by Miek Gieben
parent 8d876c770c
commit 0c02708d63
2 changed files with 18 additions and 23 deletions

View File

@@ -1,4 +1,6 @@
GITCOMMIT:=$(shell git describe --dirty --always) GITCOMMIT:=$(shell git describe --dirty --always)
BINARY:=coredns
SYSTEM:=
all: coredns all: coredns
@@ -6,7 +8,7 @@ all: coredns
# TODO: Add .go file dependencies. # TODO: Add .go file dependencies.
.PHONY: coredns .PHONY: coredns
coredns: check godeps coredns: check godeps
CGO_ENABLED=0 go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" CGO_ENABLED=0 $(SYSTEM) go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o $(BINARY)
.PHONY: check .PHONY: check
check: fmt core/zmiddleware.go core/dnsserver/zdirectives.go godeps check: fmt core/zmiddleware.go core/dnsserver/zdirectives.go godeps

View File

@@ -1,5 +1,12 @@
# Makefile for releasing CoreDNS # Makefile for releasing CoreDNS
# #
# The release binaries are built through docker run like
# make coredns
#
# There advantage of the above command is that we could control reused
# the binary generation from the default `Makefile`, instread of repeating
# in `Makefile.release`.
#
# The release is controlled from coremain/version.go. The version found # The release is controlled from coremain/version.go. The version found
# there is used to tag the git repo and to build the assets that are # there is used to tag the git repo and to build the assets that are
# uploaded to github (after some sanity checks). # uploaded to github (after some sanity checks).
@@ -43,7 +50,7 @@ GITCOMMIT:=$(shell git describe --dirty --always)
all: all:
@echo Use the 'release' target to start a release @echo Use the 'release' target to start a release
release: generate commit push build tar upload release: commit push build tar upload
docker: docker-build docker-upload docker: docker-build docker-upload
@@ -57,28 +64,14 @@ commit:
@echo Committing @echo Committing
git commit -am"Release $(VERSION)" git commit -am"Release $(VERSION)"
.PHONY: generate
generate:
go generate
.PHONY: build .PHONY: build
build: build-arm build-darwin build-linux build:
@echo Building: linux $(VERSION)
.PHONY: build-linux mkdir -p build/Linux && $(MAKE) coredns BINARY=build/Linux/$(NAME) SYSTEM="GOOS=linux"
build-linux:
@echo Building: linux $(VERSION)
mkdir -p build/Linux && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Linux/$(NAME)
.PHONY: build-darwin
build-darwin:
@echo Building: darwin $(VERSION) @echo Building: darwin $(VERSION)
mkdir -p build/Darwin && CGO_ENABLED=0 GOOS=darwin go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Darwin/$(NAME) mkdir -p build/Darwin && $(MAKE) coredns BINARY=build/Darwin/$(NAME) SYSTEM="GOOS=darwin"
@echo Building: arm $(VERSION)
.PHONY: build-arm mkdir -p build/Linux/Arm && $(MAKE) coredns BINARY=build/Linux/Arm/$(NAME) SYSTEM="GOOS=linux GOARCH=arm"
build-arm:
@echo Building: arm $(VERSION)
mkdir -p build/Linux/Arm && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Linux/Arm/$(NAME)
.PHONY: tar .PHONY: tar
tar: tar:
@@ -94,7 +87,7 @@ upload:
.PHONY: docker-build .PHONY: docker-build
docker-build: docker-build:
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" $(MAKE) coredns SYSTEM="GOOS=linux"
docker build -t $(DOCKER_IMAGE_NAME) . docker build -t $(DOCKER_IMAGE_NAME) .
docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(VERSION) docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(VERSION)