Add windows and linux cross.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-05-12 11:30:30 -04:00
parent a787cbc93b
commit 84a77889c3
4 changed files with 46 additions and 19 deletions

View File

@ -7,11 +7,10 @@ RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.li
RUN apt-get update && apt-get install -y \
libltdl-dev \
gcc-mingw-w64 \
parallel \
;
# build-essential \
# binutils-mingw-w64 gcc-mingw-w64
RUN go get github.com/mitchellh/gox && \
cp /go/bin/gox /usr/bin && \
rm -rf /go/src/* /go/pkg/* /go/bin/*

View File

@ -2,20 +2,8 @@
set -eu -o pipefail
source ./scripts/build/.variables
export BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Wow, gox doesn't like extra spaces between these strings...
CROSS_OSARCH="\
windows/amd64"
#darwin/amd64 \
#linux/amd64 \
#linux/arm \
# Currently broken
# linux/ppc64le \
gox -output build/docker-{{.OS}}-{{.Arch}} \
-osarch "${CROSS_OSARCH}" \
--ldflags "${LDFLAGS}" \
${SOURCE}
SHELL=/bin/bash parallel ::: \
"$BUILDDIR/linux-cross" \
"$BUILDDIR/windows"

21
scripts/build/linux-cross Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# Build static linux binary for multiple architectures
#
set -eu -o pipefail
source ./scripts/build/.variables
CROSS_OSARCH="linux/amd64 linux/arm"
# Compile is broken
# linux/ppc64le
# Not yet supported by gox
# linux/s390x
gox -output build/docker-{{.OS}}-{{.Arch}} \
-osarch "${CROSS_OSARCH}" \
--ldflags "${LDFLAGS}" \
"${SOURCE}"

19
scripts/build/windows Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# Build a windows binary from linux
#
set -eu -o pipefail
source ./scripts/build/.variables
export CC=x86_64-w64-mingw32-gcc
export CGO_ENABLED=1
export GOOS=windows
export GOARCH=amd64
# Override TARGET
export TARGET="build/docker-windows-amd64"
# TODO: -tags pkcs11
go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"