Merge pull request #9225 from icecrime/win_make_binary

Adapt project/make.sh for Windows builds
This commit is contained in:
Arnaud Porterie 2014-11-21 08:37:19 -08:00
commit ce8ebaf0e0
2 changed files with 17 additions and 6 deletions

View File

@ -101,6 +101,10 @@ LDFLAGS='
-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
'
LDFLAGS_STATIC='-linkmode external'
# Cgo -H windows is incompatible with -linkmode external.
if [ "$(go env GOOS)" == 'windows' ]; then
LDFLAGS_STATIC=''
fi
EXTLDFLAGS_STATIC='-static'
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
# with options like -race.
@ -215,7 +219,7 @@ bundle() {
bundle=$(basename $bundlescript)
echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
mkdir -p bundles/$VERSION/$bundle
source $bundlescript $(pwd)/bundles/$VERSION/$bundle
source "$bundlescript" "$(pwd)/bundles/$VERSION/$bundle"
}
main() {

View File

@ -3,19 +3,26 @@ set -e
DEST=$1
BINARY_NAME="docker-$VERSION"
BINARY_EXTENSION=
if [ "$(go env GOOS)" = 'windows' ]; then
BINARY_NAME+='.exe'
BINARY_EXTENSION='.exe'
fi
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
# Cygdrive paths don't play well with go build -o.
if [[ "$(uname -s)" == CYGWIN* ]]; then
DEST=$(cygpath -mw $DEST)
fi
go build \
-o "$DEST/$BINARY_NAME" \
-o "$DEST/$BINARY_FULLNAME" \
"${BUILDFLAGS[@]}" \
-ldflags "
$LDFLAGS
$LDFLAGS_STATIC_DOCKER
" \
./docker
echo "Created binary: $DEST/$BINARY_NAME"
ln -sf "$BINARY_NAME" "$DEST/docker"
echo "Created binary: $DEST/$BINARY_FULLNAME"
ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
hash_files "$DEST/$BINARY_NAME"
hash_files "$DEST/$BINARY_FULLNAME"