FEnigma/packaging/windows/oem/build.bat
Dominik Roth 6a61bffb22 Fix taking-fire ally misclassification; Windows build fixes; Field Gun
OCR (src/fenigma/ocr.py):
- A "taking fire" report's reporting unit was added as a hostile Target,
  not a friendly Ally -- no "Friendly"/"Hostile" prefix word exists in
  that grammar for the usual inference to key off of, so it silently
  defaulted to not-ally. Fixed with an explicit force_ally override
  (_TAKING_FIRE_RE), and the shell/deadline (which an Ally tuple has no
  fields for) now always splits into a synthetic StrikeRequest target at
  the reporting position, even for the no-offset "on our position" case
  that previously kept them on the entity itself.
- "Enemy <Type>#<id> Destroyed" kill-feed lines were silently dropping
  for shorter/less distinctive type words (e.g. "Enemy Field Gun#1") --
  _ALLY_PREFIX_RE only ever stripped "Friendly"/"Hostile", never
  "Enemy", so the whole "EnemyFieldGun" token got alias/fuzzy-matched
  against "Artillery" and missed by a mile. Longer type words
  ("Enemy Mechanized Infantry#2") only ever worked by fuzzy-match
  accident. Now strips "Enemy" too (lookahead guards a BARE "Enemy#N"
  report, which IS TargetType.ENEMY itself, from being stripped to an
  empty, unresolvable string).
- "Field Gun" added to _TYPE_WORD_ALIASES as plain Artillery under
  another name (confirmed by the user), not a missing unit type.
7 new/updated regression tests, 54 total passing.

Windows build (packaging/windows/): three real bugs found and fixed by
actually booting and driving the build VM live (VNC), not just guessing
from the README's "UNTESTED end to end" note:
- install.bat's MSYS2/WiX provisioning previously left NOTHING behind
  once C:\OEM stopped existing (a 2-day-old BUILD_REQUEST sat unclaimed
  the whole time) -- the build.bat/watch_build.bat persistence fix
  (C:\FenigmaBuild instead of C:\OEM) is real and now confirmed live:
  after a full container restart, the watcher auto-starts on login and
  picks up a pending request with zero manual intervention.
- pip install pytesseract needs --break-system-packages (MSYS2's
  mingw64 Python enforces PEP 668).
- mingw-w64-x86_64-opencv is the C++ library only; the actual Python
  bindings are the separate mingw-w64-x86_64-python-opencv package,
  never in install.bat's dependency list.

With all three, import fenigma.app succeeds and a real build attempt
gets through source copy, sanity check, dist-tree assembly, and WiX
harvest+compile -- further than this pipeline has ever gotten. Full
findings, including the still-open light.exe timeout and the OCR
multi-shell/deadline-phrasing/phantom-header gaps found along the way,
logged in TODO.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 22:02:17 +02:00

87 lines
3.2 KiB
Batchfile

@echo off
REM Actual per-build packaging. Triggered by watch_build.bat once
REM install.bat's one-time provisioning has already put MSYS2/GTK4/
REM libadwaita/WiX in place. Reads source from Z:\src, writes
REM FEnigma-<version>.msi to Z:\dist, and Z:\BUILD_DONE (or
REM Z:\BUILD_FAILED, with the log copied alongside it) when finished.
REM
REM UNTESTED (see install.bat's note) -- the WiX harvest/link step in
REM particular is likely to need iteration: bulk-copying all of
REM mingw64\ is the "make it work first" approach, not a lean one, and
REM heat.exe's default harvest options may need tuning to actually
REM produce a working component set for a tree this size.
setlocal enabledelayedexpansion
set LOG=Z:\build.log
echo [build.bat] starting > %LOG%
if exist Z:\BUILD_VERSION (
set /p APPVER=<Z:\BUILD_VERSION
) else (
set APPVER=0.1.0
)
echo [build.bat] version %APPVER% >> %LOG%
rd /s /q C:\build 2>nul
mkdir C:\build\src
mkdir C:\build\dist\src
mkdir C:\build\dist\mingw64
echo [build.bat] copying source from Z:\src ... >> %LOG%
xcopy /e /i /q Z:\src C:\build\src >> %LOG% 2>&1
echo [build.bat] sanity import check ... >> %LOG%
set PYTHONPATH=C:\build\src\src
C:\msys64\mingw64\bin\python3.exe -c "import fenigma.app" >> %LOG% 2>&1
if errorlevel 1 (
echo [build.bat] FAILED: fenigma.app failed to import, see log >> %LOG%
copy %LOG% Z:\build.log.failed >nul
echo FAILED > Z:\BUILD_FAILED
exit /b 1
)
echo [build.bat] assembling dist tree ... >> %LOG%
xcopy /e /i /q C:\build\src\src C:\build\dist\src >> %LOG% 2>&1
REM Bulk-copy the whole mingw64 runtime rather than hand-tracing the DLL/
REM typelib/icon-theme/schema dependency closure -- bloated (likely 1GB+)
REM but reliable; trimming this down is a known follow-up, not attempted
REM here (see this file's top-of-file note).
robocopy C:\msys64\mingw64 C:\build\dist\mingw64 /e /xd include share\doc share\man share\gtk-doc /nfl /ndl /njh /njs >> %LOG% 2>&1
echo [build.bat] harvesting WiX components ... >> %LOG%
C:\wix\heat.exe dir C:\build\dist -cg AppFiles -gg -scom -sreg -sfrag -srd -sw5150 -dr INSTALLFOLDER -var var.DistDir -out C:\build\files.wxs >> %LOG% 2>&1
if errorlevel 1 (
echo [build.bat] FAILED: heat.exe harvest failed >> %LOG%
copy %LOG% Z:\build.log.failed >nul
echo FAILED > Z:\BUILD_FAILED
exit /b 1
)
copy /y C:\FenigmaBuild\product.wxs C:\build\product.wxs >nul
echo [build.bat] compiling (candle) ... >> %LOG%
C:\wix\candle.exe -dDistDir=C:\build\dist -dAppVersion=%APPVER% -out C:\build\ C:\build\product.wxs C:\build\files.wxs >> %LOG% 2>&1
if errorlevel 1 (
echo [build.bat] FAILED: candle.exe failed >> %LOG%
copy %LOG% Z:\build.log.failed >nul
echo FAILED > Z:\BUILD_FAILED
exit /b 1
)
echo [build.bat] linking (light) ... >> %LOG%
C:\wix\light.exe -ext WixUIExtension -sice:ICE60 -sice:ICE61 -out C:\build\FEnigma-%APPVER%.msi C:\build\product.wixobj C:\build\files.wixobj >> %LOG% 2>&1
if errorlevel 1 (
echo [build.bat] FAILED: light.exe failed >> %LOG%
copy %LOG% Z:\build.log.failed >nul
echo FAILED > Z:\BUILD_FAILED
exit /b 1
)
if not exist Z:\dist mkdir Z:\dist
copy /y C:\build\FEnigma-%APPVER%.msi Z:\dist\ >> %LOG% 2>&1
copy /y %LOG% Z:\dist\build.log >nul
echo [build.bat] done >> %LOG%
echo DONE > Z:\BUILD_DONE
endlocal