From 0c02708d63f62d6bca55effedd9601908311baa9 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sun, 13 Aug 2017 09:41:50 -0700 Subject: [PATCH] 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 * Update to only use `make` without running inside `docker run` Signed-off-by: Yong Tang --- Makefile | 4 +++- Makefile.release | 37 +++++++++++++++---------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index b76fba6b4..5e5ec4ffa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ GITCOMMIT:=$(shell git describe --dirty --always) +BINARY:=coredns +SYSTEM:= all: coredns @@ -6,7 +8,7 @@ all: coredns # TODO: Add .go file dependencies. .PHONY: coredns 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 check: fmt core/zmiddleware.go core/dnsserver/zdirectives.go godeps diff --git a/Makefile.release b/Makefile.release index 37cffe148..8ad24c8ef 100644 --- a/Makefile.release +++ b/Makefile.release @@ -1,5 +1,12 @@ # 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 # there is used to tag the git repo and to build the assets that are # uploaded to github (after some sanity checks). @@ -43,7 +50,7 @@ GITCOMMIT:=$(shell git describe --dirty --always) all: @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 @@ -57,28 +64,14 @@ commit: @echo Committing git commit -am"Release $(VERSION)" -.PHONY: generate -generate: - go generate - .PHONY: build -build: build-arm build-darwin build-linux - -.PHONY: build-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: +build: + @echo Building: linux $(VERSION) + mkdir -p build/Linux && $(MAKE) coredns BINARY=build/Linux/$(NAME) SYSTEM="GOOS=linux" @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) - -.PHONY: build-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) - + mkdir -p build/Darwin && $(MAKE) coredns BINARY=build/Darwin/$(NAME) SYSTEM="GOOS=darwin" + @echo Building: arm $(VERSION) + mkdir -p build/Linux/Arm && $(MAKE) coredns BINARY=build/Linux/Arm/$(NAME) SYSTEM="GOOS=linux GOARCH=arm" .PHONY: tar tar: @@ -94,7 +87,7 @@ upload: .PHONY: 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 tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(VERSION)