From 39f679c450ff8bbb7e20aa1363f2719eb6665269 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sat, 16 Jun 2018 09:29:52 +0900 Subject: [PATCH] travis: test cross compilation Signed-off-by: Akihiro Suda --- .gitignore | 1 + .travis.yml | 2 +- Dockerfile | 8 +++++++- Makefile | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d270f10b..282e34ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ vendor/pkg /runc +/runc-* contrib/cmd/recvtty/recvtty man/man8 release diff --git a/.travis.yml b/.travis.yml index 2120f167..0d1c66c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,4 +32,4 @@ before_install: script: - git-validation -run DCO,short-subject -v - make BUILDTAGS="${BUILDTAGS}" - - make BUILDTAGS="${BUILDTAGS}" clean ci + - make BUILDTAGS="${BUILDTAGS}" clean ci cross diff --git a/Dockerfile b/Dockerfile index 2f14dffb..2f153c9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ FROM golang:1.10-stretch -RUN apt-get update && apt-get install -y \ +RUN dpkg --add-architecture armel \ + && dpkg --add-architecture armhf \ + && dpkg --add-architecture arm64 \ + && dpkg --add-architecture ppc64el \ + && apt-get update && apt-get install -y \ build-essential \ curl \ sudo \ @@ -21,6 +25,8 @@ RUN apt-get update && apt-get install -y \ python-minimal \ uidmap \ kmod \ + crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-arm64 crossbuild-essential-ppc64el \ + libseccomp-dev:armel libseccomp-dev:armhf libseccomp-dev:arm64 libseccomp-dev:ppc64el \ --no-install-recommends \ && apt-get clean diff --git a/Makefile b/Makefile index 36d5065b..96b90232 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ .PHONY: all shell dbuild man release \ localtest localunittest localintegration \ - test unittest integration + test unittest integration \ + cross localcross GO := go @@ -105,7 +106,7 @@ uninstall-man: rm -f $(addprefix $(MAN_INSTALL_PATH),$(MAN_PAGES_BASE)) clean: - rm -f runc + rm -f runc runc-* rm -f contrib/cmd/recvtty/recvtty rm -rf $(RELEASE_DIR) rm -rf $(MAN_DIR) @@ -117,6 +118,15 @@ validate: ci: validate test release +cross: runcimage + docker run -e BUILDTAGS="$(BUILDTAGS)" --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localcross + +localcross: + CGO_ENABLED=1 GOARCH=arm GOARM=6 CC=arm-linux-gnueabi-gcc $(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc-armel . + CGO_ENABLED=1 GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc $(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc-armhf . + CGO_ENABLED=1 GOARCH=arm64 CC=aarch64-linux-gnu-gcc $(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc-arm64 . + CGO_ENABLED=1 GOARCH=ppc64le CC=powerpc64le-linux-gnu-gcc $(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc-ppc64le . + # memoize allpackages, so that it's executed only once and only if used _allpackages = $(shell $(GO) list ./... | grep -v vendor) allpackages = $(if $(__allpackages),,$(eval __allpackages := $$(_allpackages)))$(__allpackages)