103 lines
2.7 KiB
Bash
103 lines
2.7 KiB
Bash
#!/bin/bash
|
|
# Package Windows build as a portable directory with all DLLs
|
|
# Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>
|
|
set -euo pipefail
|
|
|
|
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>}"
|
|
QT_DIR="${2:?}"
|
|
MINGW_SYSROOT="${3:?}"
|
|
OUTPUT_DIR="${4:?}"
|
|
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
DIST_DIR="${BUILD_DIR}/dist"
|
|
|
|
rm -rf "$DIST_DIR"
|
|
mkdir -p "$DIST_DIR"
|
|
|
|
# Copy the main executable
|
|
cp "$BUILD_DIR/asteria-qt.exe" "$DIST_DIR/"
|
|
|
|
# Use windeployqt to gather Qt dependencies
|
|
# windeployqt6 from the cross-compiled Qt may not work on Linux host,
|
|
# so we manually copy the required DLLs
|
|
|
|
# Qt DLLs
|
|
QT_DLLS=(
|
|
Qt6Core.dll
|
|
Qt6Gui.dll
|
|
Qt6Qml.dll
|
|
Qt6Quick.dll
|
|
Qt6Widgets.dll
|
|
Qt6Concurrent.dll
|
|
Qt6Svg.dll
|
|
Qt6QuickControls2.dll
|
|
Qt6QuickControls2Impl.dll
|
|
Qt6QuickTemplates2.dll
|
|
Qt6QuickLayouts.dll
|
|
Qt6QmlModels.dll
|
|
Qt6QmlWorkerScript.dll
|
|
Qt6Network.dll
|
|
Qt6OpenGL.dll
|
|
Qt6QmlMeta.dll
|
|
)
|
|
|
|
for dll in "${QT_DLLS[@]}"; do
|
|
if [ -f "$QT_DIR/bin/$dll" ]; then
|
|
cp "$QT_DIR/bin/$dll" "$DIST_DIR/"
|
|
fi
|
|
done
|
|
|
|
# Qt plugins
|
|
mkdir -p "$DIST_DIR/platforms"
|
|
cp "$QT_DIR/plugins/platforms/qwindows.dll" "$DIST_DIR/platforms/" 2>/dev/null || true
|
|
|
|
mkdir -p "$DIST_DIR/imageformats"
|
|
cp "$QT_DIR/plugins/imageformats/"*.dll "$DIST_DIR/imageformats/" 2>/dev/null || true
|
|
|
|
mkdir -p "$DIST_DIR/iconengines"
|
|
cp "$QT_DIR/plugins/iconengines/"*.dll "$DIST_DIR/iconengines/" 2>/dev/null || true
|
|
|
|
mkdir -p "$DIST_DIR/tls"
|
|
cp "$QT_DIR/plugins/tls/"*.dll "$DIST_DIR/tls/" 2>/dev/null || true
|
|
|
|
# QML modules
|
|
mkdir -p "$DIST_DIR/qml"
|
|
for mod in QtQuick QtQml Qt5Compat; do
|
|
if [ -d "$QT_DIR/qml/$mod" ]; then
|
|
cp -r "$QT_DIR/qml/$mod" "$DIST_DIR/qml/"
|
|
fi
|
|
done
|
|
|
|
# MinGW runtime DLLs
|
|
MINGW_DLLS=(
|
|
libgcc_s_seh-1.dll
|
|
libstdc++-6.dll
|
|
libwinpthread-1.dll
|
|
)
|
|
|
|
for dll in "${MINGW_DLLS[@]}"; do
|
|
find /usr/lib/gcc/x86_64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
|
|
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "/usr/x86_64-w64-mingw32/lib/$dll" ]; then
|
|
cp "/usr/x86_64-w64-mingw32/lib/$dll" "$DIST_DIR/"
|
|
fi
|
|
done
|
|
|
|
# Third-party DLLs from sysroot
|
|
if [ -f "$MINGW_SYSROOT/lib/libuchardet.dll" ]; then
|
|
cp "$MINGW_SYSROOT/lib/libuchardet.dll" "$DIST_DIR/"
|
|
elif [ -f "$MINGW_SYSROOT/bin/libuchardet.dll" ]; then
|
|
cp "$MINGW_SYSROOT/bin/libuchardet.dll" "$DIST_DIR/"
|
|
fi
|
|
|
|
# Create qt.conf for portable deployment
|
|
cat > "$DIST_DIR/qt.conf" << 'EOF'
|
|
[Paths]
|
|
Plugins = .
|
|
Qml2Imports = qml
|
|
EOF
|
|
|
|
# Create zip archive
|
|
mkdir -p "$OUTPUT_DIR"
|
|
cp -r "$DIST_DIR" "$OUTPUT_DIR/asteria-qt-windows"
|
|
cd "$OUTPUT_DIR" && zip -r "asteria-qt-windows.zip" asteria-qt-windows/ && rm -rf asteria-qt-windows/
|