mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Adapt project/make.sh for Windows builds
Fixes: - link -H windows is not compatible with -linkmode external - under Cygwin go does not play well with cygdrive type paths Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
parent
660eadae3d
commit
ce86d5ae68
2 changed files with 17 additions and 6 deletions
|
@ -101,6 +101,10 @@ LDFLAGS='
|
||||||
-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
|
-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
|
||||||
'
|
'
|
||||||
LDFLAGS_STATIC='-linkmode external'
|
LDFLAGS_STATIC='-linkmode external'
|
||||||
|
# Cgo -H windows is incompatible with -linkmode external.
|
||||||
|
if [ "$(go env GOOS)" == 'windows' ]; then
|
||||||
|
LDFLAGS_STATIC=''
|
||||||
|
fi
|
||||||
EXTLDFLAGS_STATIC='-static'
|
EXTLDFLAGS_STATIC='-static'
|
||||||
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
||||||
# with options like -race.
|
# with options like -race.
|
||||||
|
@ -215,7 +219,7 @@ bundle() {
|
||||||
bundle=$(basename $bundlescript)
|
bundle=$(basename $bundlescript)
|
||||||
echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
|
echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
|
||||||
mkdir -p bundles/$VERSION/$bundle
|
mkdir -p bundles/$VERSION/$bundle
|
||||||
source $bundlescript $(pwd)/bundles/$VERSION/$bundle
|
source "$bundlescript" "$(pwd)/bundles/$VERSION/$bundle"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
|
@ -3,19 +3,26 @@ set -e
|
||||||
|
|
||||||
DEST=$1
|
DEST=$1
|
||||||
BINARY_NAME="docker-$VERSION"
|
BINARY_NAME="docker-$VERSION"
|
||||||
|
BINARY_EXTENSION=
|
||||||
if [ "$(go env GOOS)" = 'windows' ]; then
|
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
|
fi
|
||||||
|
|
||||||
go build \
|
go build \
|
||||||
-o "$DEST/$BINARY_NAME" \
|
-o "$DEST/$BINARY_FULLNAME" \
|
||||||
"${BUILDFLAGS[@]}" \
|
"${BUILDFLAGS[@]}" \
|
||||||
-ldflags "
|
-ldflags "
|
||||||
$LDFLAGS
|
$LDFLAGS
|
||||||
$LDFLAGS_STATIC_DOCKER
|
$LDFLAGS_STATIC_DOCKER
|
||||||
" \
|
" \
|
||||||
./docker
|
./docker
|
||||||
echo "Created binary: $DEST/$BINARY_NAME"
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
||||||
ln -sf "$BINARY_NAME" "$DEST/docker"
|
ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
|
||||||
|
|
||||||
hash_files "$DEST/$BINARY_NAME"
|
hash_files "$DEST/$BINARY_FULLNAME"
|
||||||
|
|
Loading…
Reference in a new issue