Skip to content

Display and control your Android device

Improve prebuilt system

Romain Vimont38cdcdda50de
diff --git a/app/meson.build b/app/meson.build
index 80a0d9d2..7f675035 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -109,9 +109,9 @@ if not crossbuild_windows
else
# cross-compile mingw32 build (from Linux to Windows)
prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2')
- sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/bin'
- sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/lib'
- sdl2_include_dir = '../prebuilt-deps/' + prebuilt_sdl2 + '/include'
+ sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_sdl2 + '/bin'
+ sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_sdl2 + '/lib'
+ sdl2_include_dir = '../prebuilt-deps/data/' + prebuilt_sdl2 + '/include'
sdl2 = declare_dependency(
dependencies: [
@@ -122,8 +122,8 @@ else
)
prebuilt_ffmpeg = meson.get_cross_property('prebuilt_ffmpeg')
- ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_ffmpeg + '/bin'
- ffmpeg_include_dir = '../prebuilt-deps/' + prebuilt_ffmpeg + '/include'
+ ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_ffmpeg + '/bin'
+ ffmpeg_include_dir = '../prebuilt-deps/data/' + prebuilt_ffmpeg + '/include'
# ffmpeg versions are different for win32 and win64 builds
ffmpeg_avcodec = meson.get_cross_property('ffmpeg_avcodec')
diff --git a/cross_win32.txt b/cross_win32.txt
index 9bf974e3..db448a00 100644
--- a/cross_win32.txt
+++ b/cross_win32.txt
@@ -19,5 +19,5 @@ endian = 'little'
ffmpeg_avcodec = 'avcodec-58'
ffmpeg_avformat = 'avformat-58'
ffmpeg_avutil = 'avutil-56'
-prebuilt_ffmpeg = 'ffmpeg-4.3.1-win32-shared'
+prebuilt_ffmpeg = 'ffmpeg-win32-4.3.1'
prebuilt_sdl2 = 'SDL2-2.0.20/i686-w64-mingw32'
diff --git a/cross_win64.txt b/cross_win64.txt
index 763e12e9..9d169a71 100644
--- a/cross_win64.txt
+++ b/cross_win64.txt
@@ -19,5 +19,5 @@ endian = 'little'
ffmpeg_avcodec = 'avcodec-59'
ffmpeg_avformat = 'avformat-59'
ffmpeg_avutil = 'avutil-57'
-prebuilt_ffmpeg = 'ffmpeg-5.0-full_build-shared'
+prebuilt_ffmpeg = 'ffmpeg-win64-5.0'
prebuilt_sdl2 = 'SDL2-2.0.20/x86_64-w64-mingw32'
diff --git a/prebuilt-deps/.gitignore b/prebuilt-deps/.gitignore
index 934bc04c..3af0ccb6 100644
--- a/prebuilt-deps/.gitignore
+++ b/prebuilt-deps/.gitignore
@@ -1,4 +1 @@
-*
-!/.gitignore
-!/Makefile
-!/prepare-dep
+/data
diff --git a/prebuilt-deps/Makefile b/prebuilt-deps/Makefile
deleted file mode 100644
index b40321b6..00000000
--- a/prebuilt-deps/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-.PHONY: prepare-win32 prepare-win64 \
- prepare-ffmpeg-win32 \
- prepare-ffmpeg-win64 \
- prepare-sdl2 \
- prepare-adb
-
-prepare-win32: prepare-sdl2 prepare-ffmpeg-win32 prepare-adb
-prepare-win64: prepare-sdl2 prepare-ffmpeg-win64 prepare-adb
-
-# Use old FFmpeg version for win32, there are no new prebuilts
-prepare-ffmpeg-win32:
- @./prepare-dep https://github.com/Genymobile/scrcpy/releases/download/v1.16/ffmpeg-4.3.1-win32-shared.zip \
- 357af9901a456f4dcbacd107e83a934d344c9cb07ddad8aaf80612eeab7d26d2 \
- ffmpeg-4.3.1-win32-shared
- @./prepare-dep https://github.com/Genymobile/scrcpy/releases/download/v1.16/ffmpeg-4.3.1-win32-dev.zip \
- 230efb08e9bcf225bd474da29676c70e591fc94d8790a740ca801408fddcb78b \
- ffmpeg-4.3.1-win32-dev
- ln -sf ../ffmpeg-4.3.1-win32-dev/include ffmpeg-4.3.1-win32-shared/
-
-prepare-ffmpeg-win64:
- @./prepare-dep https://github.com/GyanD/codexffmpeg/releases/download/5.0/ffmpeg-5.0-full_build-shared.7z \
- e5900f6cecd4c438d398bd2fc308736c10b857cd8dd61c11bcfb05bff5d1211a \
- ffmpeg-5.0-full_build-shared
-
-prepare-sdl2:
- @./prepare-dep https://libsdl.org/release/SDL2-devel-2.0.20-mingw.tar.gz \
- 38094d82a857d6c62352e5c5cdec74948c5b4d25c59cbd298d6d233568976bd1 \
- SDL2-2.0.20
-
-prepare-adb:
- @./prepare-dep https://dl.google.com/android/repository/platform-tools_r31.0.3-windows.zip \
- 0f4b8fdd26af2c3733539d6eebb3c2ed499ea1d4bb1f4e0ecc2d6016961a6e24 \
- platform-tools
diff --git a/prebuilt-deps/common b/prebuilt-deps/common
new file mode 100755
index 00000000..c97f7de4
--- /dev/null
+++ b/prebuilt-deps/common
@@ -0,0 +1,22 @@
+PREBUILT_DATA_DIR=data
+
+checksum() {
+ local file="$1"
+ local sum="$2"
+ echo "$file: verifying checksum..."
+ echo "$sum $file" | sha256sum -c
+}
+
+get_file() {
+ local url="$1"
+ local file="$2"
+ local sum="$3"
+ if [[ -f "$file" ]]
+ then
+ echo "$file: found"
+ else
+ echo "$file: not found, downloading..."
+ wget "$url" -O "$file"
+ fi
+ checksum "$file" "$sum"
+}
diff --git a/prebuilt-deps/prepare-adb.sh b/prebuilt-deps/prepare-adb.sh
new file mode 100755
index 00000000..2e7997e1
--- /dev/null
+++ b/prebuilt-deps/prepare-adb.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+set -e
+DIR=$(dirname ${BASH_SOURCE[0]})
+cd "$DIR"
+. common
+mkdir -p "$PREBUILT_DATA_DIR"
+cd "$PREBUILT_DATA_DIR"
+
+DEP_DIR=platform-tools-31.0.3
+
+FILENAME=platform-tools_r31.0.3-windows.zip
+SHA256SUM=0f4b8fdd26af2c3733539d6eebb3c2ed499ea1d4bb1f4e0ecc2d6016961a6e24
+
+if [[ -d "$DEP_DIR" ]]
+then
+ echo "$DEP_DIR" found
+ exit 0
+fi
+
+get_file "https://dl.google.com/android/repository/$FILENAME" \
+ "$FILENAME" "$SHA256SUM"
+
+mkdir "$DEP_DIR"
+cd "$DEP_DIR"
+
+ZIP_PREFIX=platform-tools
+unzip "../$FILENAME" \
+ "$ZIP_PREFIX"/AdbWinApi.dll \
+ "$ZIP_PREFIX"/AdbWinUsbApi.dll \
+ "$ZIP_PREFIX"/adb.exe
+mv "$ZIP_PREFIX"/* .
+rmdir "$ZIP_PREFIX"
diff --git a/prebuilt-deps/prepare-dep b/prebuilt-deps/prepare-dep
deleted file mode 100755
index a95b9bb6..00000000
--- a/prebuilt-deps/prepare-dep
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env bash
-set -e
-url="$1"
-sum="$2"
-dir="$3"
-
-checksum() {
- local file="$1"
- local sum="$2"
- echo "$file: verifying checksum..."
- echo "$sum $file" | sha256sum -c
-}
-
-get_file() {
- local url="$1"
- local file="$2"
- local sum="$3"
- if [[ -f "$file" ]]
- then
- echo "$file: found"
- else
- echo "$file: not found, downloading..."
- wget "$url" -O "$file"
- fi
- checksum "$file" "$sum"
-}
-
-extract() {
- local file="$1"
- echo "Extracting $file..."
- if [[ "$file" == *.zip ]]
- then
- unzip -q "$file"
- elif [[ "$file" == *.tar.gz ]]
- then
- tar xf "$file"
- elif [[ "$file" == *.7z ]]
- then
- 7z x "$file"
- else
- echo "Unsupported file: $file"
- return 1
- fi
-}
-
-get_dep() {
- local url="$1"
- local sum="$2"
- local dir="$3"
- local file="${url##*/}"
- if [[ -d "$dir" ]]
- then
- echo "$dir: found"
- else
- echo "$dir: not found"
- get_file "$url" "$file" "$sum"
- extract "$file"
- fi
-}
-
-get_dep "$url" "$sum" "$dir"
diff --git a/prebuilt-deps/prepare-ffmpeg-win32.sh b/prebuilt-deps/prepare-ffmpeg-win32.sh
new file mode 100755
index 00000000..2a6a3841
--- /dev/null
+++ b/prebuilt-deps/prepare-ffmpeg-win32.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+set -e
+DIR=$(dirname ${BASH_SOURCE[0]})
+cd "$DIR"
+. common
+mkdir -p "$PREBUILT_DATA_DIR"
+cd "$PREBUILT_DATA_DIR"
+
+DEP_DIR=ffmpeg-win32-4.3.1
+
+FILENAME_SHARED=ffmpeg-4.3.1-win32-shared.zip
+SHA256SUM_SHARED=357af9901a456f4dcbacd107e83a934d344c9cb07ddad8aaf80612eeab7d26d2
+
+FILENAME_DEV=ffmpeg-4.3.1-win32-dev.zip
+SHA256SUM_DEV=230efb08e9bcf225bd474da29676c70e591fc94d8790a740ca801408fddcb78b
+
+if [[ -d "$DEP_DIR" ]]
+then
+ echo "$DEP_DIR" found
+ exit 0
+fi
+
+get_file "https://github.com/Genymobile/scrcpy/releases/download/v1.16/$FILENAME_SHARED" \
+ "$FILENAME_SHARED" "$SHA256SUM_SHARED"
+get_file "https://github.com/Genymobile/scrcpy/releases/download/v1.16/$FILENAME_DEV" \
+ "$FILENAME_DEV" "$SHA256SUM_DEV"
+
+mkdir "$DEP_DIR"
+cd "$DEP_DIR"
+
+ZIP_PREFIX_SHARED=ffmpeg-4.3.1-win32-shared
+unzip "../$FILENAME_SHARED" \
+ "$ZIP_PREFIX_SHARED"/bin/avutil-56.dll \
+ "$ZIP_PREFIX_SHARED"/bin/avcodec-58.dll \
+ "$ZIP_PREFIX_SHARED"/bin/avformat-58.dll \
+ "$ZIP_PREFIX_SHARED"/bin/swresample-3.dll \
+ "$ZIP_PREFIX_SHARED"/bin/swscale-5.dll
+
+ZIP_PREFIX_DEV=ffmpeg-4.3.1-win32-dev
+unzip "../$FILENAME_DEV" \
+ "$ZIP_PREFIX_DEV/include/*"
+
+mv "$ZIP_PREFIX_SHARED"/* .
+mv "$ZIP_PREFIX_DEV"/* .
+rmdir "$ZIP_PREFIX_SHARED" "$ZIP_PREFIX_DEV"
diff --git a/prebuilt-deps/prepare-ffmpeg-win64.sh b/prebuilt-deps/prepare-ffmpeg-win64.sh
new file mode 100755
index 00000000..a62eb261
--- /dev/null
+++ b/prebuilt-deps/prepare-ffmpeg-win64.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -e
+DIR=$(dirname ${BASH_SOURCE[0]})
+cd "$DIR"
+. common
+mkdir -p "$PREBUILT_DATA_DIR"
+cd "$PREBUILT_DATA_DIR"
+
+DEP_DIR=ffmpeg-win64-5.0
+
+FILENAME=ffmpeg-5.0-full_build-shared.7z
+SHA256SUM=e5900f6cecd4c438d398bd2fc308736c10b857cd8dd61c11bcfb05bff5d1211a
+
+if [[ -d "$DEP_DIR" ]]
+then
+ echo "$DEP_DIR" found
+ exit 0
+fi
+
+get_file "https://github.com/GyanD/codexffmpeg/releases/download/5.0/$FILENAME" \
+ "$FILENAME" "$SHA256SUM"
+
+mkdir "$DEP_DIR"
+cd "$DEP_DIR"
+
+ZIP_PREFIX=ffmpeg-5.0-full_build-shared
+7z x "../$FILENAME" \
+ "$ZIP_PREFIX"/bin/avutil-57.dll \
+ "$ZIP_PREFIX"/bin/avcodec-59.dll \
+ "$ZIP_PREFIX"/bin/avformat-59.dll \
+ "$ZIP_PREFIX"/bin/swresample-4.dll \
+ "$ZIP_PREFIX"/bin/swscale-6.dll \
+ "$ZIP_PREFIX"/include
+mv "$ZIP_PREFIX"/* .
+rmdir "$ZIP_PREFIX"
diff --git a/prebuilt-deps/prepare-sdl.sh b/prebuilt-deps/prepare-sdl.sh
new file mode 100755
index 00000000..c414c854
--- /dev/null
+++ b/prebuilt-deps/prepare-sdl.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+set -e
+DIR=$(dirname ${BASH_SOURCE[0]})
+cd "$DIR"
+. common
+mkdir -p "$PREBUILT_DATA_DIR"
+cd "$PREBUILT_DATA_DIR"
+
+DEP_DIR=SDL2-2.0.20
+
+FILENAME=SDL2-devel-2.0.20-mingw.tar.gz
+SHA256SUM=38094d82a857d6c62352e5c5cdec74948c5b4d25c59cbd298d6d233568976bd1
+
+if [[ -d "$DEP_DIR" ]]
+then
+ echo "$DEP_DIR" found
+ exit 0
+fi
+
+get_file "https://libsdl.org/release/$FILENAME" "$FILENAME" "$SHA256SUM"
+
+mkdir "$DEP_DIR"
+cd "$DEP_DIR"
+
+TAR_PREFIX="$DEP_DIR" # root directory inside the tar has the same name
+tar xf "../$FILENAME" --strip-components=1 \
+ "$TAR_PREFIX"/i686-w64-mingw32/bin/SDL2.dll \
+ "$TAR_PREFIX"/i686-w64-mingw32/include/ \
+ "$TAR_PREFIX"/i686-w64-mingw32/lib/ \
+ "$TAR_PREFIX"/x86_64-w64-mingw32/bin/SDL2.dll \
+ "$TAR_PREFIX"/x86_64-w64-mingw32/include/ \
+ "$TAR_PREFIX"/x86_64-w64-mingw32/lib/ \
diff --git a/release.mk b/release.mk
index 2f2fe9e1..37b8d5c5 100644
--- a/release.mk
+++ b/release.mk
@@ -63,7 +63,9 @@ build-server:
ninja -C "$(SERVER_BUILD_DIR)"
prepare-deps-win32:
- -$(MAKE) -C prebuilt-deps prepare-win32
+ @prebuilt-deps/prepare-adb.sh
+ @prebuilt-deps/prepare-sdl.sh
+ @prebuilt-deps/prepare-ffmpeg-win32.sh
build-win32: prepare-deps-win32
[ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
@@ -75,7 +77,9 @@ build-win32: prepare-deps-win32
ninja -C "$(WIN32_BUILD_DIR)"
prepare-deps-win64:
- -$(MAKE) -C prebuilt-deps prepare-win64
+ @prebuilt-deps/prepare-adb.sh
+ @prebuilt-deps/prepare-sdl.sh
+ @prebuilt-deps/prepare-ffmpeg-win64.sh
build-win64: prepare-deps-win64
[ -d "$(WIN64_BUILD_DIR)" ] || ( mkdir "$(WIN64_BUILD_DIR)" && \
@@ -94,15 +98,15 @@ dist-win32: build-server build-win32
cp data/scrcpy-noconsole.vbs "$(DIST)/$(WIN32_TARGET_DIR)"
cp data/icon.png "$(DIST)/$(WIN32_TARGET_DIR)"
cp data/open_a_terminal_here.bat "$(DIST)/$(WIN32_TARGET_DIR)"
- cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
- cp prebuilt-deps/SDL2-2.0.20/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/swresample-3.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win32-4.3.1/bin/swscale-5.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
+ cp prebuilt-deps/data/SDL2-2.0.20/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
dist-win64: build-server build-win64
mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
@@ -112,15 +116,15 @@ dist-win64: build-server build-win64
cp data/scrcpy-noconsole.vbs "$(DIST)/$(WIN64_TARGET_DIR)"
cp data/icon.png "$(DIST)/$(WIN64_TARGET_DIR)"
cp data/open_a_terminal_here.bat "$(DIST)/$(WIN64_TARGET_DIR)"
- cp prebuilt-deps/ffmpeg-5.0-full_build-shared/bin/avutil-57.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-5.0-full_build-shared/bin/avcodec-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-5.0-full_build-shared/bin/avformat-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-5.0-full_build-shared/bin/swresample-4.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/ffmpeg-5.0-full_build-shared/bin/swscale-6.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/platform-tools/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
- cp prebuilt-deps/SDL2-2.0.20/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win64-5.0/bin/avutil-57.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win64-5.0/bin/avcodec-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win64-5.0/bin/avformat-59.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win64-5.0/bin/swresample-4.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/ffmpeg-win64-5.0/bin/swscale-6.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
+ cp prebuilt-deps/data/SDL2-2.0.20/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
zip-win32: dist-win32
cd "$(DIST)/$(WIN32_TARGET_DIR)"; \