Add windows resources to binary.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
master
Daniel Nephin 2017-05-15 17:59:51 -04:00
parent a2225276af
commit 8a6ad48d2b
15 changed files with 191 additions and 11 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
.DS_Store
./build
/build/
cli/winresources/rsrc_386.syso
cli/winresources/rsrc_amd64.syso

View File

@ -7,7 +7,7 @@ all: binary
# remove build artifacts
.PHONY: clean
clean:
@rm -rf ./build/*
@rm -rf ./build/* cli/winresources/rsrc_*
# run go test
# the "-tags daemon" part is temporary

View File

@ -0,0 +1,18 @@
/*Package winresources is used to embed Windows resources into docker.exe.
These resources are used to provide
* Version information
* An icon
* A Windows manifest declaring Windows version support
The resource object files are generated with go generate.
The resource source files are located in scripts/winresources.
This occurs automatically when you run scripts/build/windows.
These object files are picked up automatically by go build when this package
is included.
*/
package winresources
//go:generate ../../scripts/gen/windows-resources

View File

@ -1,8 +0,0 @@
// +build autogen,windows
package main
// TODO: add build scripts that include the winresources (for docker icon etc.)
// Those scripts will need to specify an autogen buildtag.
import _ "github.com/docker/cli/autogen/winresources"

View File

@ -0,0 +1,3 @@
package main
import _ "github.com/docker/cli/cli/winresources"

View File

@ -2,7 +2,7 @@
set -eu -o pipefail
export BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Building all binaries"
SHELL=/bin/bash parallel ::: \

View File

@ -15,6 +15,9 @@ export GOARCH=amd64
# Override TARGET
TARGET="build/docker-$GOOS-$GOARCH"
echo "Generating windows resources"
go generate ./cli/winresources
echo "Building $TARGET"
# TODO: -tags pkcs11
go build -o "${TARGET}" --ldflags "${LDFLAGS}" "${SOURCE}"

46
scripts/gen/windows-resources Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
#
# Compile the Windows resources into the sources
#
set -eu -o pipefail
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPTDIR/../build/.variables
RESOURCES=$SCRIPTDIR/../winresources
TEMPDIR=$(mktemp -d)
trap 'rm -rf $TEMPDIR' EXIT
if [ "$(go env GOHOSTOS)" == "windows" ]; then
WINDRES=windres
WINDMC=windmc
else
# Cross compiling
WINDRES=x86_64-w64-mingw32-windres
WINDMC=x86_64-w64-mingw32-windmc
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 $RESOURCES/$1 \
-o $3 \
-F $2 \
--use-temp-file \
-I $TEMPDIR \
$defs
}
$WINDMC $RESOURCES/event_messages.mc -h $TEMPDIR -r $TEMPDIR
makeres docker.rc pe-x86-64 rsrc_amd64.syso
makeres docker.rc pe-i386 rsrc_386.syso

View File

@ -0,0 +1,38 @@
// Application icon
1 ICON "docker.ico"
// Windows executable manifest
1 24 /* RT_MANIFEST */ "docker.exe.manifest"
// Version information
1 VERSIONINFO
#ifdef DOCKER_VERSION_QUAD
FILEVERSION DOCKER_VERSION_QUAD
PRODUCTVERSION DOCKER_VERSION_QUAD
#endif
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004B0"
BEGIN
VALUE "ProductName", DOCKER_NAME
#ifdef DOCKER_VERSION
VALUE "FileVersion", DOCKER_VERSION
VALUE "ProductVersion", DOCKER_VERSION
#endif
#ifdef DOCKER_COMMIT
VALUE "OriginalFileName", DOCKER_COMMIT
#endif
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0000, 0x04B0
END
END

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Docker</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 KiB

View File

@ -0,0 +1,3 @@
#define DOCKER_NAME "Docker Client"
#include "common.rc"

View File

@ -0,0 +1,39 @@
MessageId=1
Language=English
%1
.
MessageId=2
Language=English
debug: %1
.
MessageId=3
Language=English
panic: %1
.
MessageId=4
Language=English
fatal: %1
.
MessageId=11
Language=English
%1 [%2]
.
MessageId=12
Language=English
debug: %1 [%2]
.
MessageId=13
Language=English
panic: %1 [%2]
.
MessageId=14
Language=English
fatal: %1 [%2]
.

View File

@ -0,0 +1,18 @@
/*
Package winresources is used to embed Windows resources into docker.exe.
These resources are used to provide
* Version information
* An icon
* A Windows manifest declaring Windows version support
The resource object files are generated in hack/make/.go-autogen from
source files in hack/make/.resources-windows. This occurs automatically
when you run hack/make.sh.
These object files are picked up automatically by go build when this package
is included.
*/
package winresources