From 527069ea137c2482e9fc008e9cff9c90e9120cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 27 Oct 2019 08:45:10 +0100 Subject: [PATCH 1/3] Use faster build for the default minikube target When we are doing the "cross" compile targets, we force rebuilding all packages (up-to-date or not). For the default native target "out/minikube", we can do a much faster build (10x!), for development. Leaving all the cross target to rebuild, as before. Also the _test.go files are only used for unit tests. --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4d250bac5120..4207efb2dcc8 100755 --- a/Makefile +++ b/Makefile @@ -106,6 +106,9 @@ CMD_SOURCE_DIRS = cmd pkg SOURCE_DIRS = $(CMD_SOURCE_DIRS) test SOURCE_PACKAGES = ./cmd/... ./pkg/... ./test/... +SOURCE_GENERATED = pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go +SOURCE_FILES = $(shell find $(CMD_SOURCE_DIRS) -type f -name "*.go" | grep -v _test.go) + # kvm2 ldflags KVM2_LDFLAGS := -X k8s.io/minikube/pkg/drivers/kvm.version=$(VERSION) -X k8s.io/minikube/pkg/drivers/kvm.gitCommitID=$(COMMIT) @@ -139,8 +142,8 @@ else endif -out/minikube$(IS_EXE): out/minikube-$(GOOS)-$(GOARCH)$(IS_EXE) - cp $< $@ +out/minikube$(IS_EXE): $(SOURCE_GENERATED) $(SOURCE_FILES) + go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS)" -o $@ k8s.io/minikube/cmd/minikube out/minikube-windows-amd64.exe: out/minikube-windows-amd64 cp $< $@ @@ -157,11 +160,12 @@ minikube-linux-arm64: out/minikube-linux-arm64 minikube-darwin-amd64: out/minikube-darwin-amd64 minikube-windows-amd64.exe: out/minikube-windows-amd64.exe -out/minikube-%: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go $(shell find $(CMD_SOURCE_DIRS) -type f -name "*.go") +out/minikube-%: $(SOURCE_GENERATED) $(SOURCE_FILES) ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) $(call DOCKER,$(BUILD_IMAGE),/usr/bin/make $@) else - GOOS="$(firstword $(subst -, ,$*))" GOARCH="$(lastword $(subst -, ,$(subst $(IS_EXE), ,$*)))" go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $@ k8s.io/minikube/cmd/minikube + GOOS="$(firstword $(subst -, ,$*))" GOARCH="$(lastword $(subst -, ,$(subst $(IS_EXE), ,$*)))" \ + go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $@ k8s.io/minikube/cmd/minikube endif .PHONY: e2e-linux-amd64 e2e-darwin-amd64 e2e-windows-amd64.exe From ad221904974fd01864289f3a7244c7c18f5dadb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 2 Nov 2019 09:04:07 +0100 Subject: [PATCH 2/3] Add go modules to the minikube dependencies When not rebuilding everything all the time, we need to check the go.mod for changes to the list of dependencies (and rebuild). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4207efb2dcc8..0073332a1a1b 100755 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ else endif -out/minikube$(IS_EXE): $(SOURCE_GENERATED) $(SOURCE_FILES) +out/minikube$(IS_EXE): $(SOURCE_GENERATED) $(SOURCE_FILES) go.mod go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS)" -o $@ k8s.io/minikube/cmd/minikube out/minikube-windows-amd64.exe: out/minikube-windows-amd64 From e5c4720433aff470c6bdcbf6606213b9068d04b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 2 Nov 2019 09:20:54 +0100 Subject: [PATCH 3/3] Still support building default in docker Since the docker image is always running Linux amd64, we need to pass the actual local target to build (cross-compile) minikube for. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 0073332a1a1b..3130a13daa9a 100755 --- a/Makefile +++ b/Makefile @@ -143,7 +143,11 @@ endif out/minikube$(IS_EXE): $(SOURCE_GENERATED) $(SOURCE_FILES) go.mod +ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) + $(call DOCKER,$(BUILD_IMAGE),GOOS=$(GOOS) GOARCH=$(GOARCH) /usr/bin/make $@) +else go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS)" -o $@ k8s.io/minikube/cmd/minikube +endif out/minikube-windows-amd64.exe: out/minikube-windows-amd64 cp $< $@