Skip to content

Commit

Permalink
Add windows as a supported cross-compile platform.
Browse files Browse the repository at this point in the history
Add cross-compiling for supported platforms to our CircleCI builders.

Signed-off-by: Ying Li <ying.li@docker.com>
  • Loading branch information
cyli committed Sep 22, 2016
1 parent 210946e commit 393783c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endif
CTIMEVAR=-X $(NOTARY_PKG)/version.GitCommit=$(GITCOMMIT) -X $(NOTARY_PKG)/version.NotaryVersion=$(NOTARY_VERSION)
GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)"
GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static"
GOOSES = darwin linux
GOOSES = darwin linux windows
NOTARY_BUILDTAGS ?= pkcs11
NOTARYDIR := /go/src/github.com/docker/notary

Expand Down
1 change: 1 addition & 0 deletions buildscripts/circle_parallelism.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ case $CIRCLE_NODE_INDEX in
;;
2) SKIPENVCHECK=1 make TESTDB=mysql testdb
SKIPENVCHECK=1 make TESTDB=mysql integration
SKIPENVCHECK=1 make cross # just trying not to exceed 5 builders
;;
3) SKIPENVCHECK=1 make TESTDB=rethink testdb
SKIPENVCHECK=1 make TESTDB=rethink integration
Expand Down
20 changes: 12 additions & 8 deletions buildscripts/cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@

GOARCH="amd64"

if [[ "${NOTARY_BUILDTAGS}" == *pkcs11* ]]; then
export CGO_ENABLED=1
else
export CGO_ENABLED=0
fi


for os in "$@"; do
export GOOS="${os}"
BUILDTAGS="${NOTARY_BUILDTAGS}"

if [[ "${GOOS}" == "darwin" ]]; then
export CC="o64-clang"
Expand All @@ -24,18 +18,28 @@ for os in "$@"; do
# darwin binaries can't be compiled to be completely static with the -static flag
LDFLAGS="-s"
else
# no building with Cgo. Also no building with pkcs11
if [[ "${GOOS}" == "windows" ]]; then
BUILDTAGS=""
fi
unset CC
unset CXX
LDFLAGS="-extldflags -static"
fi

if [[ "${BUILDTAGS}" == *pkcs11* ]]; then
export CGO_ENABLED=1
else
export CGO_ENABLED=0
fi

mkdir -p "${NOTARYDIR}/cross/${GOOS}/${GOARCH}";

set -x;
go build \
-o "${NOTARYDIR}/cross/${GOOS}/${GOARCH}/notary" \
-a \
-tags "${NOTARY_BUILDTAGS}" \
-tags "${BUILDTAGS}" \
-ldflags "-w ${CTIMEVAR} ${LDFLAGS}" \
./cmd/notary;
set +x;
Expand Down

0 comments on commit 393783c

Please sign in to comment.