Browse code

hack: check windows resources are set in the binary

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>

CrazyMax authored on 2025/06/26 23:11:30
Showing 2 changed files
... ...
@@ -549,7 +549,8 @@ RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \
549 549
         apt-get update && apt-get install --no-install-recommends -y \
550 550
             clang \
551 551
             lld \
552
-            llvm
552
+            llvm \
553
+            icoutils
553 554
 ARG TARGETPLATFORM
554 555
 RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \
555 556
     --mount=type=cache,sharing=locked,id=moby-build-aptcache,target=/var/cache/apt \
... ...
@@ -96,6 +96,18 @@ source "${MAKEDIR}/.go-autogen"
96 96
 		set -x
97 97
 	fi
98 98
 	./hack/with-go-mod.sh go build -mod=vendor -modfile=vendor.mod -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" -gcflags="${GCFLAGS}" "$GO_PACKAGE"
99
+
100
+	# Verify that the built binary contains windows resources
101
+	if [ "$(go env GOOS)" = "windows" ]; then
102
+		if command -v wrestool > /dev/null 2>&1; then
103
+			if ! wrestool -l "$DEST/$BINARY_FULLNAME" | grep -q -- '--type='; then
104
+				echo "No resources found in $DEST/$BINARY_FULLNAME"
105
+				exit 1
106
+			fi
107
+		else
108
+			echo "WARNING: wrestool not found, skipping resources check"
109
+		fi
110
+	fi
99 111
 )
100 112
 
101 113
 echo "Created binary: $DEST/$BINARY_FULLNAME"