2017-05-15 17:59:51 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Compile the Windows resources into the sources
|
|
|
|
#
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-07-18 08:17:17 -04:00
|
|
|
# shellcheck source=/go/src/github.com/docker/cli/scripts/build/.variables
|
2017-05-15 17:59:51 -04:00
|
|
|
source $SCRIPTDIR/../build/.variables
|
|
|
|
|
|
|
|
RESOURCES=$SCRIPTDIR/../winresources
|
|
|
|
|
|
|
|
TEMPDIR=$(mktemp -d)
|
|
|
|
trap 'rm -rf $TEMPDIR' EXIT
|
|
|
|
|
|
|
|
if [ "$(go env GOHOSTOS)" == "windows" ]; then
|
|
|
|
WINDRES=windres
|
|
|
|
else
|
|
|
|
# Cross compiling
|
|
|
|
WINDRES=x86_64-w64-mingw32-windres
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate a Windows file version of the form major,minor,patch,build (with any part optional)
|
2017-07-18 08:17:17 -04:00
|
|
|
VERSION_QUAD=$(echo -n "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
|
2017-05-15 17:59:51 -04:00
|
|
|
|
|
|
|
# Pass version and commit information into the resource compiler
|
|
|
|
defs=
|
2017-07-18 08:17:17 -04:00
|
|
|
[ ! -z "$VERSION" ] && defs+=( "-D DOCKER_VERSION=\"$VERSION\"")
|
|
|
|
[ ! -z "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD")
|
|
|
|
[ ! -z "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"")
|
2017-05-15 17:59:51 -04:00
|
|
|
|
|
|
|
function makeres {
|
2017-07-18 08:17:17 -04:00
|
|
|
"$WINDRES" \
|
|
|
|
-i "$RESOURCES/$1" \
|
|
|
|
-o "$3" \
|
|
|
|
-F "$2" \
|
2017-05-15 17:59:51 -04:00
|
|
|
--use-temp-file \
|
2017-07-18 08:17:17 -04:00
|
|
|
-I "$TEMPDIR" \
|
|
|
|
${defs[*]}
|
2017-05-15 17:59:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
makeres docker.rc pe-x86-64 rsrc_amd64.syso
|
|
|
|
makeres docker.rc pe-i386 rsrc_386.syso
|