Cross-build Windows native bundle on Linux
This commit is contained in:
59
native/age_movie_ffmpeg/bootstrap-win64.sh
Executable file
59
native/age_movie_ffmpeg/bootstrap-win64.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
repo_root="$(cd -- "$script_dir/../.." && pwd)"
|
||||
destination="${1:-$repo_root/build/ffmpeg-sdk}"
|
||||
manifest="$script_dir/dependency-win64.json"
|
||||
|
||||
manifest_value() {
|
||||
python3 -c 'import json, sys; print(json.load(open(sys.argv[1], encoding="utf-8"))[sys.argv[2]])' \
|
||||
"$manifest" "$1"
|
||||
}
|
||||
|
||||
for command in python3 curl sha256sum awk; do
|
||||
command -v "$command" >/dev/null 2>&1 || {
|
||||
echo "required command was not found: $command" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
archive="$(manifest_value archive)"
|
||||
url="$(manifest_value url)"
|
||||
expected_hash="$(manifest_value sha256)"
|
||||
archive_root="${archive%.zip}"
|
||||
download_directory="$repo_root/build/downloads"
|
||||
archive_path="$download_directory/$archive"
|
||||
sdk_root="$destination/$archive_root"
|
||||
|
||||
mkdir -p -- "$download_directory" "$destination"
|
||||
if [[ ! -f "$archive_path" ]]; then
|
||||
curl --fail --location --retry 3 --output "$archive_path" "$url"
|
||||
fi
|
||||
|
||||
actual_hash="$(sha256sum "$archive_path" | awk '{ print $1 }')"
|
||||
if [[ "$actual_hash" != "$expected_hash" ]]; then
|
||||
echo "FFmpeg archive SHA-256 mismatch: expected $expected_hash, got $actual_hash" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$sdk_root" ]]; then
|
||||
python3 -m zipfile -e "$archive_path" "$destination"
|
||||
fi
|
||||
|
||||
for required in \
|
||||
"$sdk_root/include/libavformat/avformat.h" \
|
||||
"$sdk_root/lib/libavformat.dll.a" \
|
||||
"$sdk_root/lib/libavcodec.dll.a" \
|
||||
"$sdk_root/lib/libavutil.dll.a" \
|
||||
"$sdk_root/lib/libswscale.dll.a" \
|
||||
"$sdk_root/lib/libswresample.dll.a" \
|
||||
"$sdk_root/bin/ffmpeg.exe" \
|
||||
"$sdk_root/LICENSE.txt"; do
|
||||
if [[ ! -e "$required" ]]; then
|
||||
echo "FFmpeg SDK file was not found after extraction: $required" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf '%s\n' "$sdk_root"
|
||||
Reference in New Issue
Block a user