Skip to content

Commit 79e933c

Browse files
committed
Use goversioninfo to create Windows Version Info
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent f14d8e7 commit 79e933c

20 files changed

+153
-88
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
.gitignore
55
appveyor.yml
66
build
7+
/cli/winresources/versioninfo.json
8+
/cli/winresources/*.syso
79
/vndr.log

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
Thumbs.db
99
.editorconfig
1010
/build/
11-
cli/winresources/rsrc_*.syso
11+
/cli/winresources/versioninfo.json
12+
/cli/winresources/*.syso
1213
/man/man1/
1314
/man/man5/
1415
/man/man8/

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
ARG BASE_VARIANT=alpine
44
ARG GO_VERSION=1.16.8
55
ARG XX_VERSION=1.0.0-rc.2
6+
ARG GOVERSIONINFO_VERSION=v1.3.0
67

78
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS gostable
89
FROM --platform=$BUILDPLATFORM golang:1.17rc1-${BASE_VARIANT} AS golatest
@@ -47,9 +48,17 @@ ARG GO_STRIP
4748
ARG CGO_ENABLED
4849
# VERSION sets the version for the produced binary
4950
ARG VERSION
50-
RUN --mount=ro --mount=type=cache,target=/root/.cache \
51+
# COMPANY_NAME sets the company that produced the windows binary
52+
ARG COMPANY_NAME
53+
# GOVERSIONINFO_VERSION defines goversioninfo tool version
54+
ARG GOVERSIONINFO_VERSION
55+
RUN --mount=type=bind,target=.,ro \
56+
--mount=type=cache,target=/root/.cache \
5157
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
5258
--mount=type=tmpfs,target=cli/winresources \
59+
# install goversioninfo tool
60+
GO111MODULE=auto go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION} && \
61+
# override the default behavior of go with xx-go
5362
xx-go --wrap && \
5463
# export GOCACHE=$(go env GOCACHE)/$(xx-info)$([ -f /etc/alpine-release ] && echo "alpine") && \
5564
TARGET=/out ./scripts/build/binary && \

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#
22
# github.com/docker/cli
33
#
4+
5+
# Sets the name of the company that produced the windows binary.
6+
COMPANY_NAME ?=
7+
48
all: binary
59

610
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))

cli/winresources/res_windows.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

cli/winresources/winresources.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Package winresources is used to embed Windows resources into docker.exe.
2+
//
3+
// These resources are used to provide:
4+
// * Version information
5+
// * An icon
6+
// * A Windows manifest declaring Windows version support
7+
//
8+
// The resource object files are generated when building with goversioninfo
9+
// in scripts/build/binary and are located in cmd/docker/winresources.
10+
// This occurs automatically when you build against Windows OS.
11+
package winresources

cmd/docker/docker_windows.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

cmd/docker/docker_windows_386.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build windows && 386
2+
// +build windows,386
3+
4+
//go:generate goversioninfo -o=../../cli/winresources/resource.syso -icon=winresources/docker.ico -manifest=winresources/docker.exe.manifest ../../cli/winresources/versioninfo.json
5+
6+
package main
7+
8+
import _ "github.com/docker/cli/cli/winresources"

cmd/docker/docker_windows_amd64.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build windows && amd64
2+
// +build windows,amd64
3+
4+
//go:generate goversioninfo -64=true -o=../../cli/winresources/resource.syso -icon=winresources/docker.ico -manifest=winresources/docker.exe.manifest ../../cli/winresources/versioninfo.json
5+
6+
package main
7+
8+
import _ "github.com/docker/cli/cli/winresources"

cmd/docker/docker_windows_arm.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build windows && arm
2+
// +build windows,arm
3+
4+
//go:generate goversioninfo -arm=true -o=../../cli/winresources/resource.syso -icon=winresources/docker.ico -manifest=winresources/docker.exe.manifest ../../cli/winresources/versioninfo.json
5+
6+
package main
7+
8+
import _ "github.com/docker/cli/cli/winresources"

0 commit comments

Comments
 (0)