You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.4 KiB

#!/bin/bash
set -eo pipefail
LOG_FILE="build_win.log"
> "$LOG_FILE"
log() { echo "$1"; echo "$1" >> "$LOG_FILE"; }
log "================================"
log "ChatGUI Build Script (MSYS2 UCRT64)"
log "================================"
log ""
SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$SRC_DIR/build"
log "Source: $SRC_DIR"
log "Build: $BUILD_DIR"
log ""
log "[1/4] Configuring CMake..."
cmake -S "$SRC_DIR" -B "$BUILD_DIR" -G "MSYS Makefiles" 2>&1 | tee -a "$LOG_FILE"
test ${PIPESTATUS[0]} -eq 0 || { log "CMake configure FAILED"; exit 1; }
log ""
log "[2/4] Building..."
cmake --build "$BUILD_DIR" 2>&1 | tee -a "$LOG_FILE"
test ${PIPESTATUS[0]} -eq 0 || { log "Build FAILED"; exit 1; }
log ""
log "[3/4] Deploying runtime DLLs..."
WINDEPLOYQT="/ucrt64/bin/windeployqt"
if [ -x "$WINDEPLOYQT" ]; then
log " Running $WINDEPLOYQT..."
"$WINDEPLOYQT" --no-translations --no-compiler-runtime "$BUILD_DIR/chatgui.exe" 2>&1 | tee -a "$LOG_FILE"
RC=${PIPESTATUS[0]}
if [ $RC -eq 0 ]; then
log " OK: windeployqt completed"
else
log " WARN: windeployqt failed (exit $RC)"
fi
else
log " WARN: $WINDEPLOYQT not found (install: pacman -S mingw-w64-ucrt-x86_64-qt5-tools)"
log " Using objdump to find dependencies..."
DLL_LIST=$(objdump -p "$BUILD_DIR/chatgui.exe" 2>/dev/null | grep "DLL Name:" | awk '{print $3}')
if [ -n "$DLL_LIST" ]; then
for dll in $DLL_LIST; do
# skip system DLLs
case "$dll" in KERNEL32.dll|msvcrt.dll|USER32.dll|GDI32.dll|SHELL32.dll|ADVAPI32.dll|WS2_32.dll|ole32.dll|OLEAUT32.dll|IPHLPAPI.DLL|BCRYPT.dll|dbghelp.dll) continue ;; esac
cp "/ucrt64/bin/$dll" "$BUILD_DIR/" 2>/dev/null && log " OK: $dll" || \
cp "/mingw64/bin/$dll" "$BUILD_DIR/" 2>/dev/null || \
log " WARN: $dll not found"
done
else
log " FAIL: objdump failed, cannot determine dependencies"
exit 1
fi
fi
cp "$SRC_DIR/rlottie_build/librlottie.dll" "$BUILD_DIR/" 2>/dev/null && log " OK: librlottie.dll" || log " WARN: librlottie.dll not found"
log ""
log "[4/4] Verifying..."
EXE="$BUILD_DIR/chatgui.exe"
if [ -f "$EXE" ]; then
SIZE=$(du -h "$EXE" | cut -f1)
log " OK: chatgui.exe ($SIZE)"
log ""
log "================================"
log "Build SUCCESS"
log "================================"
log "Executable: $EXE"
else
log " FAIL: chatgui.exe not found"
exit 1
fi