1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/make/.go-autogen
John Starks 4677f8036e Windows: Add file version information
This change adds file version information to docker.exe and dockerd.exe by
adding a Windows version resource with the windres tool.

This change adds a dependency to binutils-mingw-w64 on Linux, but removes
a dependency on rsrc. Most Windows build environments should already have
windres if they have gcc (which is necessary to build dockerd).

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-04-24 10:55:51 -07:00

59 lines
1.8 KiB
Bash

#!/bin/bash
rm -rf autogen
cat > dockerversion/version_autogen.go <<DVEOF
// +build autogen
// Package dockerversion is auto-generated at build-time
package dockerversion
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
const (
GitCommit string = "$GITCOMMIT"
Version string = "$VERSION"
BuildTime string = "$BUILDTIME"
IAmStatic string = "${IAMSTATIC:-true}"
)
// AUTOGENERATED FILE; see $BASH_SOURCE
DVEOF
# Compile the Windows resources into the sources
if [ "$(go env GOOS)" = "windows" ]; then
mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd
cp hack/make/.resources-windows/resources.go autogen/winresources/docker/
cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
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)
VERSION_QUAD=$(echo -n $VERSION | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
# Pass version and commit information into the resource compiler
defs=
[ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
[ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
[ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
function makeres {
$WINDRES \
-i hack/make/.resources-windows/$1 \
-o $3 \
-F $2 \
--use-temp-file \
-I autogen/winresources/tmp \
$defs
}
makeres docker.rc pe-x86-64 autogen/winresources/docker/rsrc_amd64.syso
makeres docker.rc pe-i386 autogen/winresources/docker/rsrc_386.syso
makeres dockerd.rc pe-x86-64 autogen/winresources/dockerd/rsrc_amd64.syso
rm -r autogen/winresources/tmp
fi