#!/bin/bash # Настоящий build.sh с подставленными CMake/PE-импортами: Qt6, Qt5 и полный runtime-комплект. set -euo pipefail source_dir=$(cd "$(dirname "$0")/.." && pwd) fixture_root=$(mktemp -d) trap 'test_rc=$?; if [ "$test_rc" -eq 0 ]; then rm -rf -- "$fixture_root"; else echo "ERROR: deployment fixture retained: $fixture_root" >&2 [ -z "${case_dir:-}" ] || tail -60 "$case_dir/output.log" >&2 fi' EXIT mkdir -p "$fixture_root/commands" cat > "$fixture_root/commands/cmake" <<'SH' #!/bin/bash set -eu if [ "$1" = --build ]; then printf 'DLL Name: Qt%sWidgets.dll\nDLL Name: Qt%sNetwork.dll\n' "$DEPLOY_MAJOR" "$DEPLOY_MAJOR" > "$2/vibechat.exe" printf 'DLL Name: libgcc_s_seh-1.dll\nDLL Name: libwinpthread-1.dll\nDLL Name: librlottie.dll\nDLL Name: zlib1.dll\nDLL Name: libcrypto-3.dll\n' >> "$2/vibechat.exe" else while [ "$1" != -B ]; do shift; done mkdir -p "$2" printf 'Qt%s\n' "$DEPLOY_MAJOR" > "$2/chatgui_qt_package.txt" fi SH cat > "$fixture_root/commands/objdump" <<'SH' #!/bin/bash cat "$2" SH chmod +x "$fixture_root/commands/"* prepare_case() { case_dir="$fixture_root/Qt$1 package"; prefix="$case_dir/ucrt64" mkdir -p "$case_dir/rlottie_build" "$prefix/bin" "$prefix/share/qt$1/plugins/platforms" "$prefix/share/qt$1/plugins/imageformats" cp "$fixture_root/commands/objdump" "$prefix/bin/objdump" cp "$source_dir/build.sh" "$source_dir/compiler_runtime.sh" "$case_dir/" printf 'DLL Name: KERNEL32.dll\n' > "$case_dir/rlottie_build/librlottie.dll" printf 'fixture\n' > "$case_dir/setup_firewall.bat" printf 'DLL Name: AUTHZ.dll\n' > "$prefix/bin/Qt$1Core.dll" printf 'DLL Name: d3d12.dll\nDLL Name: libpng.dll\n' > "$prefix/bin/Qt$1Gui.dll" printf 'DLL Name: WINHTTP.dll\n' > "$prefix/bin/Qt$1Network.dll" printf 'DLL Name: Qt%sGui.dll\nDLL Name: Qt%sCore.dll\nDLL Name: libstdc++-6.dll\n' "$1" "$1" > "$prefix/bin/Qt$1Widgets.dll" for name in libpng.dll libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll zlib1.dll libcrypto-3.dll \ plugin-helper.dll jpeg-helper.dll webp-helper.dll; do printf 'DLL Name: KERNEL32.dll\n' > "$prefix/bin/$name" done printf 'DLL Name: Qt%sGui.dll\nDLL Name: plugin-helper.dll\n' "$1" > "$prefix/share/qt$1/plugins/platforms/qwindows.dll" printf 'DLL Name: d3d9.dll\nDLL Name: SHCORE.dll\n' >> "$prefix/share/qt$1/plugins/platforms/qwindows.dll" printf 'DLL Name: jpeg-helper.dll\n' > "$prefix/share/qt$1/plugins/imageformats/qjpeg.dll" printf 'DLL Name: webp-helper.dll\n' > "$prefix/share/qt$1/plugins/imageformats/qwebp.dll" cat > "$prefix/bin/windeployqt$1.exe" <> "\$DEPLOY_TOOL_LOG"; fi SH chmod +x "$prefix/bin/windeployqt$1.exe" } run_case() { (cd "$case_dir"; PATH="$fixture_root/commands:$PATH" DEPLOY_MAJOR="$1" DEPLOY_TOOL_LOG="$case_dir/tool.log" \ MSYSTEM= MSYSTEM_PREFIX="$prefix" bash build.sh) > "$case_dir/output.log" 2>&1 } assert_file() { [ -f "$1" ] || { echo "FAIL: missing deployed file $1"; exit 1; }; } prepare_case 6 # Старый комплект Qt5 и одноимённый plugin не должны удовлетворить проверку Qt6. mkdir -p "$case_dir/build/platforms" "$prefix/share/qt5/plugins/platforms" printf 'wrong Qt5 plugin\n' > "$prefix/share/qt5/plugins/platforms/qwindows.dll" for component in Core Gui Network Widgets; do printf 'old Qt5\n' > "$case_dir/build/Qt5$component.dll"; done run_case 6 for name in Qt6Gui.dll plugin-helper.dll jpeg-helper.dll webp-helper.dll imageformats/qjpeg.dll imageformats/qwebp.dll; do assert_file "$case_dir/build/$name" done cmp "$case_dir/build/platforms/qwindows.dll" "$prefix/share/qt6/plugins/platforms/qwindows.dll" cmp "$case_dir/build/imageformats/qwebp.dll" "$prefix/share/qt6/plugins/imageformats/qwebp.dll" [ "$(cat "$case_dir/tool.log")" = 'Qt6 deploy' ] # Наличие основных DLL не отменяет проверку транзитивных зависимостей. rm "$case_dir/build/libpng.dll" "$case_dir/build/plugin-helper.dll" run_case 6; assert_file "$case_dir/build/libpng.dll"; assert_file "$case_dir/build/plugin-helper.dll" echo 'PASS: Qt6, Windows system DLLs (d3d9/SHCORE), matching platform/JPEG/WebP plugins and repeated dependency checks' # Сбой подходящего инструмента не должен обходить обязательную проверку ручного комплекта. cat > "$prefix/bin/windeployqt6.exe" <<'SH' #!/bin/bash if [ "$1" = --version ]; then echo 'windeployqt 6.10.0'; else exit 12; fi SH chmod +x "$prefix/bin/windeployqt6.exe" run_case 6 rg -q 'windeployqt failed \(exit 12\)' "$case_dir/output.log" echo 'PASS: failed matching deploy tool falls back to verified direct deployment' # Нет подходящего deploy tool: копирование DLL/плагинов всё равно должно работать. rm "$prefix/bin/windeployqt6.exe" cat > "$prefix/bin/windeployqt.exe" <<'SH' #!/bin/bash if [ "$1" = --version ]; then echo 'windeployqt 5.15.0'; else exit 90; fi SH chmod +x "$prefix/bin/windeployqt.exe" run_case 6 echo 'PASS: incorrect Qt5 deploy tool ignored for Qt6, direct deployment succeeds' # Ошибка действительно отсутствующей сторонней DLL остаётся ошибкой сборки. rm "$case_dir/build/jpeg-helper.dll" "$prefix/bin/jpeg-helper.dll" if run_case 6; then echo 'FAIL: missing plugin dependency accepted'; exit 1; fi rg -q 'requires jpeg-helper.dll' "$case_dir/output.log" echo 'PASS: missing plugin dependency rejects incomplete deployment' prepare_case 5; run_case 5 assert_file "$case_dir/build/Qt5Gui.dll"; [ "$(cat "$case_dir/tool.log")" = 'Qt5 deploy' ] cmp "$case_dir/build/platforms/qwindows.dll" "$prefix/share/qt5/plugins/platforms/qwindows.dll" assert_file "$case_dir/build/webp-helper.dll" cmp "$case_dir/build/imageformats/qwebp.dll" "$prefix/share/qt5/plugins/imageformats/qwebp.dll" echo 'PASS: configured Qt5 fallback deploys matching DLLs and plugins'