From 393783c7f545e56dee83f23c4eef2900be1d41c3 Mon Sep 17 00:00:00 2001 From: Ying Li Date: Thu, 22 Sep 2016 00:20:45 -0700 Subject: [PATCH] Add windows as a supported cross-compile platform. Add cross-compiling for supported platforms to our CircleCI builders. Signed-off-by: Ying Li --- Makefile | 2 +- buildscripts/circle_parallelism.sh | 1 + buildscripts/cross.sh | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 2c2ee16ea2..d31b1fe670 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/buildscripts/circle_parallelism.sh b/buildscripts/circle_parallelism.sh index cc07fdc2d0..961d90a6ad 100755 --- a/buildscripts/circle_parallelism.sh +++ b/buildscripts/circle_parallelism.sh @@ -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 diff --git a/buildscripts/cross.sh b/buildscripts/cross.sh index 840a751aa6..324f50081f 100755 --- a/buildscripts/cross.sh +++ b/buildscripts/cross.sh @@ -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" @@ -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;