build-lynx-asio.sh 1.3 KB

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. # Cross build of the LYNX ASIO driver with Zig (clang + MinGW-w64). REA rounds 97 and 106.
  3. #
  4. # scripts/build-lynx-asio.sh -> $OUT/lynx-asio.dll (64-bit hosts) and $OUT/lynx-asio32.dll (32-bit hosts)
  5. #
  6. # OUT defaults to build-win. Install for other programs: copy the DLLs somewhere permanent and run, as administrator,
  7. # %SystemRoot%\System32\regsvr32.exe "C:\path\to\lynx-asio.dll" (64-bit hosts)
  8. # %SystemRoot%\SysWOW64\regsvr32.exe "C:\path\to\lynx-asio32.dll" (32-bit hosts)
  9. # (regsvr32 /u ... removes them; "Register LYNX ASIO.bat" does both.)
  10. # On 32-bit x86 the IASIO methods are __thiscall, like MSVC's: clang uses thiscall for member functions on
  11. # *-windows-gnu targets (checked in REA_rodada106.md), and the COM entry points are exported undecorated (.def).
  12. set -euo pipefail
  13. cd "$(dirname "$0")/.."
  14. ZIG="${ZIG:-$HOME/opt/zig-x86_64-linux-0.14.1/zig}"
  15. OUT="${OUT:-build-win}"
  16. mkdir -p "$OUT"
  17. for arch in x86_64 x86; do
  18. dll="$OUT/lynx-asio.dll"
  19. [[ $arch == x86 ]] && dll="$OUT/lynx-asio32.dll"
  20. "$ZIG" c++ -target $arch-windows-gnu -std=c++20 -O2 -DNDEBUG=1 -fno-sanitize=undefined -Wall -Wextra \
  21. -DUNICODE -D_UNICODE -Ithird_party/asiosdk/common \
  22. -shared -o "$dll" asio/LynxAsio.cpp asio/lynx-asio.def \
  23. -lole32 -luuid -lavrt -luser32 -lgdi32 -ladvapi32 -static
  24. echo "built $dll"
  25. done