- Centralize hidden-process setup per OS - Hide console early to avoid startup flash - Keep capture window off-screen and hidden - Enable unified scheduler for watchdog task - Force GUI subsystem in build script
28 lines
821 B
Bash
Executable File
28 lines
821 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Cross-compile win64_mp for Windows amd64.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
out="${1:-win64_mp.exe}"
|
|
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -H windowsgui" -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("<I", f.read(4))[0]
|
|
f.seek(pe)
|
|
if f.read(4) != b"PE\x00\x00":
|
|
raise SystemExit(f"not a PE file: {path}")
|
|
opt = pe + 24
|
|
f.seek(opt)
|
|
magic, = struct.unpack("<H", f.read(2))
|
|
if magic not in (0x10B, 0x20B):
|
|
raise SystemExit(f"unknown PE magic {magic:#x}")
|
|
f.seek(opt + 68)
|
|
f.write(struct.pack("<H", 2))
|
|
print(f"pe subsystem=gui {path}")
|
|
PY
|
|
echo "built $out"
|