#!/usr/bin/env bash # Cross-compile win64_mp for Windows amd64. set -euo pipefail cd "$(dirname "$0")/.." out="${1:-win64_mp.exe}" version_file="VERSION" if [[ ! -f "$version_file" ]]; then echo "1.0.0" > "$version_file" fi old="$(tr -d '[:space:]' < "$version_file")" if [[ ! "$old" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "bad VERSION: $old" >&2 exit 1 fi IFS=. read -r major minor patch <<< "$old" ver="${major}.${minor}.$((10#$patch + 1))" printf '%s\n' "$ver" > "$version_file" ldflags="-s -w -H windowsgui -X tea.chunkbyte.com/kato/go-worm/lib/config.Version=${ver}" GOOS=windows GOARCH=amd64 go build -ldflags "$ldflags" -o "$out" . # Belt-and-suspenders: PE subsystem WINDOWS (2) even if ldflags were dropped. python3 - "$out" <<'PY' import struct, sys path = sys.argv[1] with open(path, "r+b") as f: f.seek(0x3C) pe = struct.unpack("