Skip to content

Instantly share code, notes, and snippets.

@eddiezato
Created December 13, 2023 16:16
Show Gist options
  • Save eddiezato/321157d0e2f51f23e50c6954ff19ba0b to your computer and use it in GitHub Desktop.
Save eddiezato/321157d0e2f51f23e50c6954ff19ba0b to your computer and use it in GitHub Desktop.
Build qBittorrent in msys2/clang64
#!/bin/bash
while getopts 'cbd' flag ; do
case "${flag}" in
c) CLNFL=1 ;; # remove folder
b) BLD=1 ;; # build
d) DPL=1 ;; # deploy
esac
done
set -e
export CC=clang CXX=clang++
CFL='-flto=thin -ffunction-sections -fdata-sections -march=native -mtune=native -O3 -pipe'
LFL='-flto=thin -Wl,--gc-sections'
if [[ ! -d qBittorrent || $CLNFL == 1 ]]; then
rm -rf qBittorrent
git clone --depth 1 https://github.com/qbittorrent/qBittorrent.git
fi
if [[ $BLD == 1 ]]; then
cd qBittorrent
rm -rf build
cmake -B build -G Ninja -S ./ \
-DCMAKE_BUILD_TYPE=Release -DSTACKTRACE=OFF -DWEBUI=OFF \
-DCMAKE_CXX_FLAGS="$CFL -pthread" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
ninja -C build
cd ..
fi
if [[ $DPL == 1 ]]; then
rm -rf qBt
mkdir -p qBt/profile
cp qBittorrent/build/qBittorrent.exe qBt
cd qBt
windeployqt-qt6 qBittorrent.exe\
--compiler-runtime \
--no-system-d3d-compiler \
--no-translations \
--skip-plugin-types generic,networkinformation \
--exclude-plugins qgif,qicns,qjp2,qjpeg,qmng,qtga,qtiff,qwbmp,qwebp,qsqlmysql,qsqlodbc,qsqlpsql,qcertonlybackend,qopensslbackend \
--qtpaths "/clang64/bin/qtpaths-qt6.exe"
while
files2=$files1
files1=$(ldd *.{exe,dll} | grep "/clang64/bin/" | grep -v 'Qt6' | sed 's/.* => //;s/ (.*//' | sort -u)
printf '.'
for f in $files1; do
cp -u $f ./
done
[[ $files1 != $files2 ]]
do :; done
strip -s qBittorrent.exe {./,*/}*.dll
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment