build: Make sure the tools compile on Linux/macOS/Windows

This patch adds cross compilation steps for Linux, macOS and,
Windows to the CI targets to ensure that the all commands cross
compile nicely.

Although the CI runs on Linux we still explicitly compile for
Linux in case developers use the CI targets locally on a
non-Linux host.

While at it, also fix the GOARCH override to enable cross compilation
of ARM64 on Linux. The build support seems to work, but the
compilation fails (hence it is not added to the test).

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-06-08 13:28:30 +01:00
parent b5ae1260ab
commit 3e5797a911

View File

@ -12,7 +12,10 @@ LINUXKIT?=bin/linuxkit
GOOS?=$(shell uname -s | tr '[:upper:]' '[:lower:]') GOOS?=$(shell uname -s | tr '[:upper:]' '[:lower:]')
GOARCH?=amd64 GOARCH?=amd64
ifneq ($(GOOS),linux) ifneq ($(GOOS),linux)
CROSS=-e GOOS=$(GOOS) -e GOARCH=$(GOARCH) CROSS+=-e GOOS=$(GOOS)
endif
ifneq ($(GOARCH),amd64)
CROSS+=-e GOARCH=$(GOARCH)
endif endif
PREFIX?=/usr/local/ PREFIX?=/usr/local/
@ -55,6 +58,12 @@ collect-artifacts: artifacts/test.img.tar.gz artifacts/test-ltp.img.tar.gz
.PHONY: ci ci-tag ci-pr .PHONY: ci ci-tag ci-pr
ci: ci:
$(MAKE) clean
$(MAKE) GOOS=darwin
$(MAKE) clean
$(MAKE) GOOS=linux
$(MAKE) clean
$(MAKE) GOOS=windows
$(MAKE) clean $(MAKE) clean
$(MAKE) $(MAKE)
$(MAKE) install $(MAKE) install
@ -62,6 +71,12 @@ ci:
$(MAKE) -C pkg tag $(MAKE) -C pkg tag
ci-tag: ci-tag:
$(MAKE) clean
$(MAKE) GOOS=darwin
$(MAKE) clean
$(MAKE) GOOS=linux
$(MAKE) clean
$(MAKE) GOOS=windows
$(MAKE) clean $(MAKE) clean
$(MAKE) $(MAKE)
$(MAKE) install $(MAKE) install
@ -69,6 +84,12 @@ ci-tag:
$(MAKE) -C pkg tag $(MAKE) -C pkg tag
ci-pr: ci-pr:
$(MAKE) clean
$(MAKE) GOOS=darwin
$(MAKE) clean
$(MAKE) GOOS=linux
$(MAKE) clean
$(MAKE) GOOS=windows
$(MAKE) clean $(MAKE) clean
$(MAKE) $(MAKE)
$(MAKE) install $(MAKE) install