Skip to content

Commit

Permalink
Makefile consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
r2d4 committed Oct 19, 2017
1 parent 02f0d41 commit 9fbda69
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ INSTALL_SIZE ?= $(shell du out/minikube-windows-amd64.exe | cut -f1)
BUILDROOT_BRANCH ?= 2017.02
REGISTRY?=gcr.io/k8s-minikube

MINIKUBE_BUILD_IMAGE ?= karalabe/xgo-1.8.3
LOCALKUBE_BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.8.3-1
HYPERKIT_BUILD_IMAGE ?= karalabe/xgo-1.8.3
BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.8.3-1
ISO_BUILD_IMAGE ?= $(REGISTRY)/buildroot-image

ISO_VERSION ?= v0.23.5
Expand Down Expand Up @@ -59,18 +59,12 @@ MINIKUBE_TEST_FILES := go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}

KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')

# extra env vars that need to be set in cross build container
MINIKUBE_ENV_darwin_DOCKER := CC=o64-clang CXX=o64-clang++

MINIKUBE_BUILD_TAGS := container_image_ostree_stub containers_image_openpgp
MINIKUBE_INTEGRATION_BUILD_TAGS := integration $(MINIKUBE_BUILD_TAGS)

MINIKUBE_DOCKER_CMD := docker run -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) --workdir /go/src/$(REPOPATH) --entrypoint /bin/bash -v $(PWD):/go/src/$(REPOPATH) $(MINIKUBE_BUILD_IMAGE) -c
KUBE_CROSS_DOCKER_CMD := docker run -w /go/src/$(REPOPATH) --user $(shell id -u):$(shell id -g) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(LOCALKUBE_BUILD_IMAGE)

# $(call MINIKUBE_GO_BUILD_CMD, output file, OS)
define MINIKUBE_GO_BUILD_CMD
GOOS=$(2) go build -tags "$(MINIKUBE_BUILD_TAGS)" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
# $(call DOCKER, image, command)
define DOCKER
docker run --rm -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /go/src/$(REPOPATH) -v $(PWD):/go/src/$(REPOPATH) --entrypoint /bin/bash $(1) -c '$(2)'
endef

ifeq ($(BUILD_IN_DOCKER),y)
Expand Down Expand Up @@ -99,7 +93,7 @@ out/minikube$(IS_EXE): gopath out/minikube-$(GOOS)-$(GOARCH)$(IS_EXE)

out/localkube: $(shell $(LOCALKUBEFILES))
ifeq ($(LOCALKUBE_BUILD_IN_DOCKER),y)
$(KUBE_CROSS_DOCKER_CMD) make $@
$(call DOCKER,$(BUILD_IMAGE),/usr/bin/make $@)
else
CGO_ENABLED=1 go build -tags static_build -ldflags=$(LOCALKUBE_LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube
endif
Expand All @@ -109,9 +103,9 @@ out/minikube-windows-amd64.exe: out/minikube-windows-amd64

out/minikube-%-amd64: pkg/minikube/assets/assets.go $(shell $(MINIKUBEFILES))
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_$*_DOCKER) $(call MINIKUBE_GO_BUILD_CMD,$@,$*)'
$(call DOCKER,$(BUILD_IMAGE),GOOS=$* /usr/bin/make $@)
else
$(call MINIKUBE_GO_BUILD_CMD,$@,$*)
go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $@ k8s.io/minikube/cmd/minikube
endif

.PHONY: e2e-%-amd64
Expand Down Expand Up @@ -255,7 +249,7 @@ out/minikube-installer.exe: out/minikube-windows-amd64.exe

out/docker-machine-driver-hyperkit: $(shell $(HYPERKIT_FILES))
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_darwin_DOCKER) GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit'
$(call DOCKER,$(HYPERKIT_BUILD_IMAGE),/usr/bin/make $@)
else
GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
endif
Expand Down

0 comments on commit 9fbda69

Please sign in to comment.