1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #6409

Maxim Biro (1):
      refactor(windows): simplify dll check logic
This commit is contained in:
Anthony Bilinski 2021-11-07 17:33:47 -08:00
commit 3b3779c850
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -1460,72 +1460,6 @@ then
fi fi
winecfg winecfg
# qtox.exe dll checks
# (system32 contains 32-bit libraries on win32 prefix, but 64-bit on win64
# prefix)
python3 $MINGW_LDD_PREFIX_DIR/bin/mingw-ldd.py $QTOX_PREFIX_DIR/qtox.exe --dll-lookup-dirs $QTOX_PREFIX_DIR ~/.wine/drive_c/windows/system32 > /tmp/$ARCH-qtox-ldd
find "$QTOX_PREFIX_DIR" -name '*.dll' > /tmp/$ARCH-qtox-dll-find
# dlls loded at run time that don't showup as a link time dependency
echo "$QTOX_PREFIX_DIR/libssl-1_1.dll
$QTOX_PREFIX_DIR/libssl-1_1-x64.dll
$QTOX_PREFIX_DIR/libsnore-qt5/libsnore_backend_windowstoast.dll
$QTOX_PREFIX_DIR/iconengines/qsvgicon.dll
$QTOX_PREFIX_DIR/imageformats/qgif.dll
$QTOX_PREFIX_DIR/imageformats/qico.dll
$QTOX_PREFIX_DIR/imageformats/qjpeg.dll
$QTOX_PREFIX_DIR/imageformats/qsvg.dll
$QTOX_PREFIX_DIR/platforms/qdirect2d.dll
$QTOX_PREFIX_DIR/platforms/qminimal.dll
$QTOX_PREFIX_DIR/platforms/qoffscreen.dll
$QTOX_PREFIX_DIR/platforms/qwindows.dll" > /tmp/$ARCH-qtox-dll-whitelist
# Check that all dlls are in place
if grep 'not found' /tmp/$ARCH-qtox-ldd
then
cat /tmp/$ARCH-qtox-ldd
echo "Error: Missing some dlls."
exit 1
fi
# Check that no extra dlls get bundled
while IFS= read -r line
do
# skip over whitelisted dlls
if grep "$line" /tmp/$ARCH-qtox-dll-whitelist
then
continue
fi
if ! grep "$line" /tmp/$ARCH-qtox-ldd
then
echo "Error: extra dll included: $line. If this is a mistake and the dll is actually needed (e.g. it's loaded at run-time), please add it to the whitelist."
exit 1
fi
done < /tmp/$ARCH-qtox-dll-find
# SnoreToast.exe dll checks
# (always 32-bit as SnoreToast.exe is 32-bit itself, so check system32 on win32
# prefix but syswow64 on win64 prefix)
if [[ "$ARCH" == "i686" ]]
then
SNORETOAST_WINE_DLLS=/root/.wine/drive_c/windows/system32
elif [[ "$ARCH" == "x86_64" ]]
then
SNORETOAST_WINE_DLLS=/root/.wine/drive_c/windows/syswow64
fi
python3 $MINGW_LDD_PREFIX_DIR/bin/mingw-ldd.py $QTOX_PREFIX_DIR/SnoreToast.exe --dll-lookup-dirs $SNORETOAST_WINE_DLLS > /tmp/$ARCH-SnoreToast-ldd
# Check that all dlls are in place
if grep 'not found' /tmp/$ARCH-SnoreToast-ldd
then
cat /tmp/$ARCH-SnoreToast-ldd
echo "Error: Missing some dlls."
exit 1
fi
# Run tests (only on Travis) # Run tests (only on Travis)
set +u set +u
if [[ -n "$TRAVIS_CI_STAGE" ]] if [[ -n "$TRAVIS_CI_STAGE" ]]
@ -1549,15 +1483,6 @@ then
# Get debug scripts # Get debug scripts
cp -r $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin/* "$QTOX_PREFIX_DIR/" cp -r $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin/* "$QTOX_PREFIX_DIR/"
cp -r $GDB_PREFIX_DIR/bin/gdb.exe "$QTOX_PREFIX_DIR/" cp -r $GDB_PREFIX_DIR/bin/gdb.exe "$QTOX_PREFIX_DIR/"
# Check that all dlls are in place
python3 $MINGW_LDD_PREFIX_DIR/bin/mingw-ldd.py $QTOX_PREFIX_DIR/gdb.exe --dll-lookup-dirs $QTOX_PREFIX_DIR ~/.wine/drive_c/windows/system32 > /tmp/$ARCH-gdb-ldd
if grep 'not found' /tmp/$ARCH-gdb-ldd
then
cat /tmp/$ARCH-gdb-ldd
echo "Error: Missing some dlls."
exit 1
fi
fi fi
# Strip # Strip
@ -1598,6 +1523,63 @@ then
cd .. cd ..
fi fi
# dll check
# Create lists of all .exe and .dll files
find "$QTOX_PREFIX_DIR" -iname '*.dll' > dlls
find "$QTOX_PREFIX_DIR" -iname '*.exe' > exes
# Create a list of dlls that are loaded during the runtime (not listed in the PE
# import table, thus ldd doesn't print those)
echo "$QTOX_PREFIX_DIR/libsnore-qt5/libsnore_backend_windowstoast.dll
$QTOX_PREFIX_DIR/iconengines/qsvgicon.dll
$QTOX_PREFIX_DIR/imageformats/qgif.dll
$QTOX_PREFIX_DIR/imageformats/qico.dll
$QTOX_PREFIX_DIR/imageformats/qjpeg.dll
$QTOX_PREFIX_DIR/imageformats/qsvg.dll
$QTOX_PREFIX_DIR/platforms/qdirect2d.dll
$QTOX_PREFIX_DIR/platforms/qminimal.dll
$QTOX_PREFIX_DIR/platforms/qoffscreen.dll
$QTOX_PREFIX_DIR/platforms/qwindows.dll" > runtime-dlls
if [[ "$ARCH" == "i686" ]]
then
echo "$QTOX_PREFIX_DIR/libssl-1_1.dll" >> runtime-dlls
elif [[ "$ARCH" == "x86_64" ]]
then
echo "$QTOX_PREFIX_DIR/libssl-1_1-x64.dll" >> runtime-dlls
fi
# Create a tree of all required dlls
# Assumes all .exe files are directly in $QTOX_PREFIX_DIR, not in subdirs
while IFS= read -r line
do
if [[ "$ARCH" == "i686" ]]
then
WINE_DLL_DIR="/root/.wine/drive_c/windows/system32"
elif [[ "$ARCH" == "x86_64" ]]
then
WINE_DLL_DIR="/root/.wine/drive_c/windows/system32 /root/.wine/drive_c/windows/syswow64"
fi
python3 $MINGW_LDD_PREFIX_DIR/bin/mingw-ldd.py $line --dll-lookup-dirs $QTOX_PREFIX_DIR $WINE_DLL_DIR --output-format tree >> dlls-required
done < <(cat exes runtime-dlls)
# Check that no extra dlls get bundled
while IFS= read -r line
do
if ! grep -q "$line" dlls-required
then
echo "Error: extra dll included: $line. If this is a mistake and the dll is actually needed (e.g. it's loaded at runtime), please add it to the runtime dll list."
exit 1
fi
done < dlls
# Check that no dll is missing
if grep -q 'not found' dlls-required
then
cat dlls-required
echo "Error: Missing some dlls."
exit 1
fi
cd .. cd ..
rm -rf ./qtox rm -rf ./qtox