Upgrade libusb (1.0.27) for Windows

Include the latest version of SDL in Windows releases.

Unfortunately, libusb stopped releasing binaries in the expected
directory structure (with the pkgconfig file), so recreate it manually.

Refs <https://github.com/libusb/libusb/issues/1468>
This commit is contained in:
Romain Vimont 2024-03-01 10:29:46 +01:00
parent 36189b90ea
commit b3491f9878
2 changed files with 37 additions and 14 deletions

View File

@ -6,11 +6,11 @@ cd "$DIR"
mkdir -p "$PREBUILT_DATA_DIR"
cd "$PREBUILT_DATA_DIR"
VERSION=1.0.26
VERSION=1.0.27
DEP_DIR="libusb-$VERSION"
FILENAME="libusb-$VERSION-binaries.7z"
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
FILENAME="libusb-$VERSION.7z"
SHA256SUM=19835e290f46fab6bd8ce4be6ab7dc5209f1c04bad177065df485e51dc4118c8
if [[ -d "$DEP_DIR" ]]
then
@ -24,14 +24,37 @@ get_file "https://github.com/libusb/libusb/releases/download/v$VERSION/$FILENAME
mkdir "$DEP_DIR"
cd "$DEP_DIR"
7z x "../$FILENAME" \
"libusb-$VERSION-binaries/libusb-MinGW-Win32/" \
"libusb-$VERSION-binaries/libusb-MinGW-x64/"
mkdir tmp
cd tmp
7z x "../../$FILENAME" \
"include/" \
"MinGW32/" \
"MinGW64/"
cd ..
mv "libusb-$VERSION-binaries/libusb-MinGW-Win32" .
mv "libusb-$VERSION-binaries/libusb-MinGW-x64" .
rm -rf "libusb-$VERSION-binaries"
for dir in MinGW32 MinGW64
do
mkdir -p "$dir"
cd "$dir"
mkdir -p include/libusb-1.0 bin lib
cp -r ../tmp/include/libusb.h include/libusb-1.0/
cp ../tmp/"$dir"/dll/libusb-1.0.dll bin/
cp ../tmp/"$dir"/static/libusb-1.0.dll.a lib/
mkdir lib/pkgconfig
cat > lib/pkgconfig/libusb-1.0.pc << "EOF"
prefix=/home/appveyor/$dir
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
# Rename the dll to get the same library name on all platforms
mv libusb-MinGW-Win32/bin/msys-usb-1.0.dll libusb-MinGW-Win32/bin/libusb-1.0.dll
mv libusb-MinGW-x64/bin/msys-usb-1.0.dll libusb-MinGW-x64/bin/libusb-1.0.dll
Name: libusb-1.0
Description: C API for USB device access from Linux, Mac OS X, Windows, OpenBSD/NetBSD and Solaris userspace
Version: 1.0.27
Libs: -L${libdir} -lusb-1.0
Libs.private:
Cflags: -I${includedir}/libusb-1.0
EOF
cd ..
done
rm -rf tmp

View File

@ -73,7 +73,7 @@ build-win32: prepare-deps
mkdir -p "$(WIN32_BUILD_DIR)/local"
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win32/. "$(WIN32_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/SDL2-2.28.5/i686-w64-mingw32/. "$(WIN32_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-Win32/. "$(WIN32_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/libusb-1.0.27/MinGW32/. "$(WIN32_BUILD_DIR)/local/"
meson setup "$(WIN32_BUILD_DIR)" \
--pkg-config-path="$(WIN32_BUILD_DIR)/local/lib/pkgconfig" \
-Dc_args="-I$(PWD)/$(WIN32_BUILD_DIR)/local/include" \
@ -89,7 +89,7 @@ build-win64: prepare-deps
mkdir -p "$(WIN64_BUILD_DIR)/local"
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win64/. "$(WIN64_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/SDL2-2.28.5/x86_64-w64-mingw32/. "$(WIN64_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-x64/. "$(WIN64_BUILD_DIR)/local/"
cp -r app/prebuilt-deps/data/libusb-1.0.27/MinGW64/. "$(WIN64_BUILD_DIR)/local/"
meson setup "$(WIN64_BUILD_DIR)" \
--pkg-config-path="$(WIN64_BUILD_DIR)/local/lib/pkgconfig" \
-Dc_args="-I$(PWD)/$(WIN64_BUILD_DIR)/local/include" \