Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Sep 8, 2012
1 parent 2e1ca90 commit 175cba9
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions crosscompile.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,32 @@
PLATFORMS="darwin/386 darwin/amd64 freebsd/386 freebsd/amd64 linux/386 linux/amd64 linux/arm windows/386 windows/amd64"

eval "$(go env)"
HOST_GOOS=${GOOS}
HOST_GOARCH=${GOARCH}

function cgo-enabled {
if [ "$1" = "${HOST_GOOS}" ]; then
CGO_ENABLED=1
if [ "$1" = "${GOHOSTOS}" ]; then
echo 1
else
CGO_ENABLED=0
echo 0
fi
}

function go-alias {
GOOS=${1%/*}
GOARCH=${1#*/}
eval "function go-${GOOS}-${GOARCH} { (CGO_ENABLED=$(cgo-enabled ${GOOS}) GOOS=${GOOS} GOARCH=${GOARCH} go \$@ ) }"
eval "function go-${GOOS}-${GOARCH} { (CGO_ENABLED=$(cgo-enabled ${GOOS} ${GOARCH}) GOOS=${GOOS} GOARCH=${GOARCH} go \$@ ) }"
}

function go-crosscompile-build {
GOOS=${1%/*}
GOARCH=${1#*/}
OUTPUT=$(cd ${GOROOT}/src ; CGO_ENABLED=$(cgo-enabled ${GOOS}) GOOS=${GOOS} GOARCH=${GOARCH} ./make.bash --no-clean 2>&1)
if [ $? -ne 0 ] ; then
echo "$OUTPUT" >&2
fi
cd ${GOROOT}/src ; CGO_ENABLED=$(cgo-enabled ${GOOS} ${GOARCH}) GOOS=${GOOS} GOARCH=${GOARCH} ./make.bash --no-clean 2>&1
}

function go-crosscompile-build-all {
set -e
for PLATFORM in $PLATFORMS; do
CMD="go-crosscompile-build ${PLATFORM}"
echo $CMD
$CMD
echo "$CMD"
$CMD >/dev/null
done
}

Expand Down

0 comments on commit 175cba9

Please sign in to comment.