Makefile: Use a pattern rule for cross-compilation

Pattern-rule documentation is in [1].  This commit follows the basic
approach from [2], with the portable build tags from [3].

Using --keep-going allows folks to see errors for multiple target
platforms.  For example, if the Darwin target dies, we'll still
attempt to build the Linux target before erroring out.

I've added an ALLOWED_TO_FAIL environment variable to mark script
blocks for the the allow_failures block.  Currently we're requiring
builds from Linux for Linux and OS X to succeed, but allowing builds
from OS X to both targets to fail.

[1]: https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html#Pattern-Intro
[2]: e5031fcf9a
[3]: https://github.com/kubernetes-incubator/cri-o/pull/1653

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1034
Approved by: baude
This commit is contained in:
W. Trevor King 2018-06-29 14:47:53 -07:00 committed by Atomic Bot
parent cc6f0e85f9
commit 4b54a471a4
2 changed files with 27 additions and 8 deletions

View File

@ -7,10 +7,10 @@ services:
- docker - docker
before_install: before_install:
- sudo apt-get -qq update - if [ "${TRAVIS_OS_NAME}" = linux ]; then sudo apt-get -qq update; fi
- sudo apt-get -qq install btrfs-tools libdevmapper-dev libgpgme11-dev libapparmor-dev - if [ "${TRAVIS_OS_NAME}" = linux ]; then sudo apt-get -qq install btrfs-tools libdevmapper-dev libgpgme11-dev libapparmor-dev; fi
- sudo apt-get -qq install autoconf automake bison e2fslibs-dev libfuse-dev libtool liblzma-dev gettext python3-setuptools python3-dateutil - if [ "${TRAVIS_OS_NAME}" = linux ]; then sudo apt-get -qq install autoconf automake bison e2fslibs-dev libfuse-dev libtool liblzma-dev gettext python3-setuptools python3-dateutil; fi
- sudo make install.libseccomp.sudo - if [ "${TRAVIS_OS_NAME}" = linux ]; then sudo make install.libseccomp.sudo; fi
install: install:
- make install.tools - make install.tools
@ -37,11 +37,21 @@ jobs:
script: script:
- make testunit - make testunit
go: 1.10.x go: 1.10.x
- script:
- make --keep-going local-cross
go: 1.10.x
- script:
- make --keep-going local-cross
go: 1.10.x
os: osx
env: ALLOWED_TO_FAIL=true
- stage: Integration Test - stage: Integration Test
script: script:
- make all - make all
- make integration - make integration
go: 1.9.x go: 1.9.x
allow_failures:
- env: ALLOWED_TO_FAIL=true
notifications: notifications:
irc: "chat.freenode.net#podman" irc: "chat.freenode.net#podman"

View File

@ -18,7 +18,7 @@ ETCDIR_LIBPOD ?= ${ETCDIR}/crio
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh) varlink BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh) varlink
BUILDTAGS_DARWIN ?= containers_image_ostree_stub containers_image_openpgp BUILDTAGS_CROSS ?= containers_image_openpgp containers_image_ostree_stub exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_overlay
ifneq (,$(findstring varlink,$(BUILDTAGS))) ifneq (,$(findstring varlink,$(BUILDTAGS)))
PODMAN_VARLINK_DEPENDENCIES = cmd/podman/varlink/ioprojectatomicpodman.go PODMAN_VARLINK_DEPENDENCIES = cmd/podman/varlink/ioprojectatomicpodman.go
endif endif
@ -57,6 +57,10 @@ GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man')
BOX="fedora_atomic" BOX="fedora_atomic"
CROSS_BUILD_TARGETS := \
bin/podman.cross.darwin.amd64 \
bin/podman.cross.linux.amd64
all: binaries docs all: binaries docs
default: help default: help
@ -98,8 +102,13 @@ test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
$(GO) build -i -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman $(GO) build -i -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
darwin: local-cross: $(CROSS_BUILD_TARGETS)
GOOS=darwin $(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS_DARWIN)" -o bin/podman.$@ $(PROJECT)/cmd/podman
bin/podman.cross.%: .gopathok
TARGET="$*"; \
GOOS="$${TARGET%%.*}" \
GOARCH="$${TARGET##*.}" \
$(GO) build -i -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" $(PROJECT)/cmd/podman
python-podman: python-podman:
ifdef HAS_PYTHON3 ifdef HAS_PYTHON3
@ -110,7 +119,7 @@ clean:
rm -rf \ rm -rf \
.gopathok \ .gopathok \
_output \ _output \
bin/podman \ bin \
build \ build \
test/bin2img/bin2img \ test/bin2img/bin2img \
test/checkseccomp/checkseccomp \ test/checkseccomp/checkseccomp \