diff --git a/.travis.yml b/.travis.yml index b79c8c2f1..5f06dd2f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ script: > -e GOPATH=/gopath -e TRASH_CACHE=/gopath/.trashcache -v /etc/passwd:/etc/passwd -v /etc/sudoers:/etc/sudoers -v /etc/sudoers.d:/etc/sudoers.d -v /var/run:/var/run:z -v $HOME/gopath:/gopath:Z - -w /gopath/src/github.com/containers/image image-test bash -c "PATH=$PATH:/gopath/bin make tools .gitvalidation validate test test-skopeo SUDO=sudo BUILDTAGS=\"$BUILDTAGS\"" + -w /gopath/src/github.com/containers/image image-test bash -c "PATH=$PATH:/gopath/bin make cross tools .gitvalidation validate test test-skopeo SUDO=sudo BUILDTAGS=\"$BUILDTAGS\"" diff --git a/Makefile b/Makefile index 30fe58659..4de6893e9 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,18 @@ SKOPEO_BRANCH = master # Set SUDO=sudo to run container integration tests using sudo. SUDO = +# when cross compiling _for_ a Darwin or windows host, then we must use openpgp +BUILD_TAGS_WINDOWS_CROSS = containers_image_ostree_stub containers_image_openpgp +BUILD_TAGS_DARWIN_CROSS = containers_image_ostree_stub containers_image_openpgp +# when compiling _on_ a Darwin host, then we can link against gpgme +BUILD_TAGS_DARWIN_NATIVE = containers_image_ostree_stub + ifeq ($(shell uname),Darwin) -DARWIN_BUILD_TAG = containers_image_ostree_stub +PLATFORM_BUILD_TAG = $(BUILD_TAGS_DARWIN_NATIVE) endif -BUILDTAGS = btrfs_noversion libdm_no_deferred_remove $(DARWIN_BUILD_TAG) + + +BUILDTAGS = btrfs_noversion libdm_no_deferred_remove $(PLATFORM_BUILD_TAG) BUILDFLAGS := -tags "$(BUILDTAGS)" PACKAGES := $(shell go list $(BUILDFLAGS) ./... | grep -v github.com/containers/image/vendor) @@ -25,8 +33,14 @@ GPGME_ENV = CGO_CFLAGS="$(shell gpgme-config --cflags 2>/dev/null)" CGO_LDFLAGS= all: tools test validate .gitvalidation -build: vendor - @$(GPGME_ENV) go build $(BUILDFLAGS) $(PACKAGES) +build: vendor build-internal + +build-internal: + $(GPGME_ENV) go build $(BUILDFLAGS) $(PACKAGES) + +cross: vendor + GOOS=windows $(MAKE) build-internal BUILDTAGS="$(BUILDTAGS) $(BUILD_TAGS_WINDOWS_CROSS)" + GOOS=darwin $(MAKE) build-internal BUILDTAGS="$(BUILDTAGS) $(BUILD_TAGS_DARWIN_CROSS)" tools: tools.timestamp