Skip to content

Commit 38cdcdd

Browse files
committed
Improve prebuilt system
This aims to fix two issues with the previous implementation: 1. the whole content of downloaded archives were extracted, while only few files are necessary; 2. the archives were extracted in the prebuild-deps/ directory as is. As a consequence of (2), the actual directory name relied on the root directory of the archive. For adb, this root directory was always "platform-tools", so when bumping the adb version, the target directory already existed and the dependency was not upgraded (the old one had to be removed manually). Expose common function to download a file and check its checksum, but let the custom script for each dependency extract only the needed files and reorganize the content if necessary.
1 parent eaba613 commit 38cdcdd

File tree

12 files changed

+198
-125
lines changed

12 files changed

+198
-125
lines changed

app/meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ if not crossbuild_windows
109109
else
110110
# cross-compile mingw32 build (from Linux to Windows)
111111
prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2')
112-
sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/bin'
113-
sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/lib'
114-
sdl2_include_dir = '../prebuilt-deps/' + prebuilt_sdl2 + '/include'
112+
sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_sdl2 + '/bin'
113+
sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_sdl2 + '/lib'
114+
sdl2_include_dir = '../prebuilt-deps/data/' + prebuilt_sdl2 + '/include'
115115

116116
sdl2 = declare_dependency(
117117
dependencies: [
@@ -122,8 +122,8 @@ else
122122
)
123123

124124
prebuilt_ffmpeg = meson.get_cross_property('prebuilt_ffmpeg')
125-
ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_ffmpeg + '/bin'
126-
ffmpeg_include_dir = '../prebuilt-deps/' + prebuilt_ffmpeg + '/include'
125+
ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/data/' + prebuilt_ffmpeg + '/bin'
126+
ffmpeg_include_dir = '../prebuilt-deps/data/' + prebuilt_ffmpeg + '/include'
127127

128128
# ffmpeg versions are different for win32 and win64 builds
129129
ffmpeg_avcodec = meson.get_cross_property('ffmpeg_avcodec')

cross_win32.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ endian = 'little'
1919
ffmpeg_avcodec = 'avcodec-58'
2020
ffmpeg_avformat = 'avformat-58'
2121
ffmpeg_avutil = 'avutil-56'
22-
prebuilt_ffmpeg = 'ffmpeg-4.3.1-win32-shared'
22+
prebuilt_ffmpeg = 'ffmpeg-win32-4.3.1'
2323
prebuilt_sdl2 = 'SDL2-2.0.20/i686-w64-mingw32'

cross_win64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ endian = 'little'
1919
ffmpeg_avcodec = 'avcodec-59'
2020
ffmpeg_avformat = 'avformat-59'
2121
ffmpeg_avutil = 'avutil-57'
22-
prebuilt_ffmpeg = 'ffmpeg-5.0-full_build-shared'
22+
prebuilt_ffmpeg = 'ffmpeg-win64-5.0'
2323
prebuilt_sdl2 = 'SDL2-2.0.20/x86_64-w64-mingw32'

prebuilt-deps/.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
*
2-
!/.gitignore
3-
!/Makefile
4-
!/prepare-dep
1+
/data

prebuilt-deps/Makefile

Lines changed: 0 additions & 33 deletions
This file was deleted.

prebuilt-deps/common

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PREBUILT_DATA_DIR=data
2+
3+
checksum() {
4+
local file="$1"
5+
local sum="$2"
6+
echo "$file: verifying checksum..."
7+
echo "$sum $file" | sha256sum -c
8+
}
9+
10+
get_file() {
11+
local url="$1"
12+
local file="$2"
13+
local sum="$3"
14+
if [[ -f "$file" ]]
15+
then
16+
echo "$file: found"
17+
else
18+
echo "$file: not found, downloading..."
19+
wget "$url" -O "$file"
20+
fi
21+
checksum "$file" "$sum"
22+
}

prebuilt-deps/prepare-adb.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
DIR=$(dirname ${BASH_SOURCE[0]})
4+
cd "$DIR"
5+
. common
6+
mkdir -p "$PREBUILT_DATA_DIR"
7+
cd "$PREBUILT_DATA_DIR"
8+
9+
DEP_DIR=platform-tools-31.0.3
10+
11+
FILENAME=platform-tools_r31.0.3-windows.zip
12+
SHA256SUM=0f4b8fdd26af2c3733539d6eebb3c2ed499ea1d4bb1f4e0ecc2d6016961a6e24
13+
14+
if [[ -d "$DEP_DIR" ]]
15+
then
16+
echo "$DEP_DIR" found
17+
exit 0
18+
fi
19+
20+
get_file "https://dl.google.com/android/repository/$FILENAME" \
21+
"$FILENAME" "$SHA256SUM"
22+
23+
mkdir "$DEP_DIR"
24+
cd "$DEP_DIR"
25+
26+
ZIP_PREFIX=platform-tools
27+
unzip "../$FILENAME" \
28+
"$ZIP_PREFIX"/AdbWinApi.dll \
29+
"$ZIP_PREFIX"/AdbWinUsbApi.dll \
30+
"$ZIP_PREFIX"/adb.exe
31+
mv "$ZIP_PREFIX"/* .
32+
rmdir "$ZIP_PREFIX"

prebuilt-deps/prepare-dep

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
DIR=$(dirname ${BASH_SOURCE[0]})
4+
cd "$DIR"
5+
. common
6+
mkdir -p "$PREBUILT_DATA_DIR"
7+
cd "$PREBUILT_DATA_DIR"
8+
9+
DEP_DIR=ffmpeg-win32-4.3.1
10+
11+
FILENAME_SHARED=ffmpeg-4.3.1-win32-shared.zip
12+
SHA256SUM_SHARED=357af9901a456f4dcbacd107e83a934d344c9cb07ddad8aaf80612eeab7d26d2
13+
14+
FILENAME_DEV=ffmpeg-4.3.1-win32-dev.zip
15+
SHA256SUM_DEV=230efb08e9bcf225bd474da29676c70e591fc94d8790a740ca801408fddcb78b
16+
17+
if [[ -d "$DEP_DIR" ]]
18+
then
19+
echo "$DEP_DIR" found
20+
exit 0
21+
fi
22+
23+
get_file "https://github.com/Genymobile/scrcpy/releases/download/v1.16/$FILENAME_SHARED" \
24+
"$FILENAME_SHARED" "$SHA256SUM_SHARED"
25+
get_file "https://github.com/Genymobile/scrcpy/releases/download/v1.16/$FILENAME_DEV" \
26+
"$FILENAME_DEV" "$SHA256SUM_DEV"
27+
28+
mkdir "$DEP_DIR"
29+
cd "$DEP_DIR"
30+
31+
ZIP_PREFIX_SHARED=ffmpeg-4.3.1-win32-shared
32+
unzip "../$FILENAME_SHARED" \
33+
"$ZIP_PREFIX_SHARED"/bin/avutil-56.dll \
34+
"$ZIP_PREFIX_SHARED"/bin/avcodec-58.dll \
35+
"$ZIP_PREFIX_SHARED"/bin/avformat-58.dll \
36+
"$ZIP_PREFIX_SHARED"/bin/swresample-3.dll \
37+
"$ZIP_PREFIX_SHARED"/bin/swscale-5.dll
38+
39+
ZIP_PREFIX_DEV=ffmpeg-4.3.1-win32-dev
40+
unzip "../$FILENAME_DEV" \
41+
"$ZIP_PREFIX_DEV/include/*"
42+
43+
mv "$ZIP_PREFIX_SHARED"/* .
44+
mv "$ZIP_PREFIX_DEV"/* .
45+
rmdir "$ZIP_PREFIX_SHARED" "$ZIP_PREFIX_DEV"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
DIR=$(dirname ${BASH_SOURCE[0]})
4+
cd "$DIR"
5+
. common
6+
mkdir -p "$PREBUILT_DATA_DIR"
7+
cd "$PREBUILT_DATA_DIR"
8+
9+
DEP_DIR=ffmpeg-win64-5.0
10+
11+
FILENAME=ffmpeg-5.0-full_build-shared.7z
12+
SHA256SUM=e5900f6cecd4c438d398bd2fc308736c10b857cd8dd61c11bcfb05bff5d1211a
13+
14+
if [[ -d "$DEP_DIR" ]]
15+
then
16+
echo "$DEP_DIR" found
17+
exit 0
18+
fi
19+
20+
get_file "https://github.com/GyanD/codexffmpeg/releases/download/5.0/$FILENAME" \
21+
"$FILENAME" "$SHA256SUM"
22+
23+
mkdir "$DEP_DIR"
24+
cd "$DEP_DIR"
25+
26+
ZIP_PREFIX=ffmpeg-5.0-full_build-shared
27+
7z x "../$FILENAME" \
28+
"$ZIP_PREFIX"/bin/avutil-57.dll \
29+
"$ZIP_PREFIX"/bin/avcodec-59.dll \
30+
"$ZIP_PREFIX"/bin/avformat-59.dll \
31+
"$ZIP_PREFIX"/bin/swresample-4.dll \
32+
"$ZIP_PREFIX"/bin/swscale-6.dll \
33+
"$ZIP_PREFIX"/include
34+
mv "$ZIP_PREFIX"/* .
35+
rmdir "$ZIP_PREFIX"

0 commit comments

Comments
 (0)