cmd: fix winresources and move them out cli package

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
Kevin Alvarez
2025-06-26 15:46:41 +02:00
committed by CrazyMax
parent ee49437e38
commit 0ea20c9f72
13 changed files with 18 additions and 33 deletions

View File

@@ -2,5 +2,5 @@
# build artifacts # build artifacts
/bundles/ /bundles/
/cli/winresources/dockerd/winres.json /cmd/dockerd/winresources/winres.json
/cli/winresources/dockerd/*.syso /cmd/dockerd/*.syso

4
.gitignore vendored
View File

@@ -15,8 +15,8 @@ thumbs.db
# build artifacts # build artifacts
/bundles/ /bundles/
/cli/winresources/dockerd/*.syso /cmd/dockerd/winresources/winres.json
/cli/winresources/dockerd/winres.json /cmd/dockerd/*.syso
# ci artifacts # ci artifacts
*.exe *.exe

View File

@@ -579,7 +579,6 @@ RUN <<EOT
fi fi
EOT EOT
RUN --mount=type=bind,target=.,rw \ RUN --mount=type=bind,target=.,rw \
--mount=type=tmpfs,target=cli/winresources/dockerd \
--mount=type=cache,target=/root/.cache/go-build,id=moby-build-$TARGETPLATFORM <<EOT --mount=type=cache,target=/root/.cache/go-build,id=moby-build-$TARGETPLATFORM <<EOT
set -e set -e
target=$([ "$DOCKER_STATIC" = "1" ] && echo "binary" || echo "dynbinary") target=$([ "$DOCKER_STATIC" = "1" ] && echo "binary" || echo "dynbinary")

View File

@@ -1 +0,0 @@
package builtins

View File

@@ -1,5 +0,0 @@
//go:generate go-winres make --arch=386,amd64,arm,arm64 --in=../../../cli/winresources/dockerd/winres.json --out=../../../cli/winresources/dockerd/resource
package builtins
import _ "github.com/docker/docker/cli/winresources/dockerd"

View File

@@ -11,8 +11,6 @@ import (
"github.com/moby/term" "github.com/moby/term"
"github.com/docker/docker/daemon/command" "github.com/docker/docker/daemon/command"
_ "github.com/docker/docker/cmd/dockerd/builtins"
) )
func main() { func main() {

View File

@@ -0,0 +1,5 @@
//go:generate go-winres make --arch=386,amd64,arm,arm64 --in=./winresources/winres.json --out=./resource
package main
import _ "github.com/docker/docker/cmd/dockerd/winresources"

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

@@ -7,6 +7,6 @@
// * Events message table // * Events message table
// //
// The resource object files are generated when building with go-winres // The resource object files are generated when building with go-winres
// in hack/make/.go-autogen and are located in cli/winresources. // in hack/make/.go-autogen. This occurs automatically when you cross build
// This occurs automatically when you cross build against Windows OS. // against Windows OS.
package winresources package winresources

View File

@@ -72,7 +72,7 @@ try {
$mkwinresContents = '{ $mkwinresContents = '{
"RT_GROUP_ICON": { "RT_GROUP_ICON": {
"#1": { "#1": {
"0409": "../../winresources/docker.ico" "0409": "docker.ico"
} }
}, },
"RT_MANIFEST": { "RT_MANIFEST": {
@@ -99,7 +99,7 @@ try {
}, },
"RT_MESSAGETABLE": { "RT_MESSAGETABLE": {
"#1": { "#1": {
"0409": "../../winresources/event_messages.bin" "0409": "event_messages.bin"
} }
}, },
"RT_VERSION": { "RT_VERSION": {
@@ -127,17 +127,11 @@ try {
}' }'
# Write the file # Write the file
$outputFile="$(Get-Location)\cli\winresources\dockerd\winres.json" $outputFile="$(Get-Location)\cmd\dockerd\winresources\winres.json"
if (Test-Path $outputFile) { Remove-Item $outputFile } if (Test-Path $outputFile) { Remove-Item $outputFile }
[System.IO.File]::WriteAllText($outputFile, $mkwinresContents) [System.IO.File]::WriteAllText($outputFile, $mkwinresContents)
Get-Content $outputFile | Out-Host Get-Content $outputFile | Out-Host
# Create winresources package stub if removed while using tmpfs in Dockerfile
$stubPackage="$(Get-Location)\cli\winresources\dockerd\winresources.go"
if(![System.IO.File]::Exists($stubPackage)){
Set-Content -NoNewline -Path $stubPackage -Value 'package winresources'
}
# Generate # Generate
go generate -v "github.com/docker/docker/cmd/dockerd" go generate -v "github.com/docker/docker/cmd/dockerd"
if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" } if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" }

View File

@@ -16,11 +16,11 @@ VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | sed -re
# Microsoft Windows Version Information and an icon using go-winres. # Microsoft Windows Version Information and an icon using go-winres.
# https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block # https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
# https://github.com/tc-hib/go-winres#json-format # https://github.com/tc-hib/go-winres#json-format
cat > "./cli/winresources/${BINARY_NAME}/winres.json" << EOL cat > "./cmd/${BINARY_NAME}/winresources/winres.json" << EOL
{ {
"RT_GROUP_ICON": { "RT_GROUP_ICON": {
"#1": { "#1": {
"0409": "../../winresources/docker.ico" "0409": "docker.ico"
} }
}, },
"RT_MANIFEST": { "RT_MANIFEST": {
@@ -47,7 +47,7 @@ cat > "./cli/winresources/${BINARY_NAME}/winres.json" << EOL
}, },
"RT_MESSAGETABLE": { "RT_MESSAGETABLE": {
"#1": { "#1": {
"0409": "../../winresources/event_messages.bin" "0409": "event_messages.bin"
} }
}, },
"RT_VERSION": { "RT_VERSION": {
@@ -76,10 +76,5 @@ cat > "./cli/winresources/${BINARY_NAME}/winres.json" << EOL
EOL EOL
( (
set -x set -x
cat "./cli/winresources/${BINARY_NAME}/winres.json" cat "./cmd/${BINARY_NAME}/winresources/winres.json"
) )
# Create winresources package stub if removed while using tmpfs in Dockerfile
if [ ! -f "./cli/winresources/${BINARY_NAME}/winresources.go" ]; then
echo "package winresources" > "./cli/winresources/${BINARY_NAME}/winresources.go"
fi