Phase 5 (D4): headless daemon entry point (ewsdrd)

ewsdrd.lpr — a console daemon that runs TRadioController + TWebAdapter WITHOUT
TMainForm/LCL, proving the Phase-5 goal: web-only headless operation. THeadlessHost
wires the data-path callbacks to the controller, the web command handlers to the
adapter (lifecycle ones marshalled to the main thread via FCtrl.Invoke =
TThread.Synchronize), opens WDSP synchronously, autostarts the saved device, and
runs a CheckSynchronize + periodic PushState loop. SIGINT/SIGTERM → graceful
StopAndDisconnect (persist + Run=0).

To keep the controller graph truly LCL-free, PlatformUtils now guards its only
Forms dependency (Screen.PixelsPerInch in CurrentScreenDPI) behind {$IFNDEF
HEADLESS}; the GUI build is byte-identical (HEADLESS undefined). build-ewsdrd.sh
compiles the headless graph from source with -Mobjfpc (nested comments) -dHEADLESS
into a separate lib-headless/ output dir, untouching the GUI .ppu.

Verified: builds clean; runs headless, web server up (HTTP 401 = serving), no LCL;
SIGINT shuts down gracefully. Radio-connect + web round-trip need hardware to test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-09 15:26:44 +03:00
co-authored by Claude Opus 4.8
parent b9c358789d
commit de234b56e5
4 changed files with 432 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
# Сборка headless-демона ewsdrd (только Web-управление, без LCL/виджетсета).
#
# Компилирует headless-граф ИЗ ИСХОДНИКОВ с -dHEADLESS в ОТДЕЛЬНЫЙ каталог
# (lib-headless/...), чтобы не трогать .ppu GUI-сборки. Ключевое:
# -Mobjfpc — командный режим по умолчанию: включает nested comments, нужные
# для лидирующих комментариев Settings.pas (юниты дальше сами ставят
# свой {$mode} директивой; программа — {$MODE Delphi}).
# -dHEADLESS — PlatformUtils не тянет Forms (LCL), граф остаётся LCL-free.
# libwdsp.dylib должна лежать в /usr/local/lib.
set -e
ROOT=$(cd "$(dirname "$0")" && pwd)
cd "$ROOT"
CPU=$(fpc -iTP)
OS=$(fpc -iTO)
OUTUNITS="lib-headless/${CPU}-${OS}"
OUT="bin/${CPU}-${OS}"
mkdir -p "$OUTUNITS" "$OUT"
fpc -Mobjfpc -O3 -dHEADLESS \
-Fu"$ROOT" -FU"$OUTUNITS" -k-L/usr/local/lib \
-o"$OUT/ewsdrd" ewsdrd.lpr
echo "Built: $OUT/ewsdrd"