Cross-build Windows native bundle on Linux
All checks were successful
Core validation / Linux core gate (push) Successful in 2m13s
Linux release build / Linux x64 artifact (push) Successful in 1m21s
Linux release build / Publish tagged Gitea release (push) Has been skipped

This commit is contained in:
gamer147
2026-08-03 21:28:18 -04:00
parent 304b290a02
commit 60ac6fc64f
10 changed files with 395 additions and 11 deletions

View File

@@ -23,10 +23,10 @@ if ($actualHash -ne $manifest.sha256) {
if (-not (Test-Path -LiteralPath $extractRoot)) {
Expand-Archive -LiteralPath $archivePath -DestinationPath $Destination
}
$sdkRoot = Get-ChildItem -LiteralPath $Destination -Directory |
Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName 'include\libavformat\avformat.h') } |
Select-Object -First 1 -ExpandProperty FullName
if (-not $sdkRoot) { throw "FFmpeg SDK was not found under $Destination" }
$sdkRoot = $extractRoot
if (-not (Test-Path -LiteralPath (Join-Path $sdkRoot 'include\libavformat\avformat.h'))) {
throw "Pinned FFmpeg SDK was not found at $sdkRoot"
}
$reported = & (Join-Path $sdkRoot 'bin\ffmpeg.exe') -version | Select-Object -First 1
$expectedVersion = $manifest.ffmpeg_version -replace '-20260721$', ''
if ($reported -notlike "*$expectedVersion*" ) {

View 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"

View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "usage: $0 <ffmpeg-sdk-root> [output-directory]" >&2
exit 2
fi
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd -- "$script_dir/../.." && pwd)"
sdk_root="$(cd -- "$1" && pwd)"
output_directory_input="${2:-$repo_root/build/native/win-x64}"
mkdir -p -- "$output_directory_input"
output_directory="$(cd -- "$output_directory_input" && pwd)"
include_directory="$sdk_root/include"
library_directory="$sdk_root/lib"
binary_directory="$sdk_root/bin"
compiler="${MINGW_CC:-x86_64-w64-mingw32-gcc}"
objdump="${MINGW_OBJDUMP:-x86_64-w64-mingw32-objdump}"
shim="$output_directory/age_movie_ffmpeg.dll"
for command in "$compiler" "$objdump" python3; do
command -v "$command" >/dev/null 2>&1 || {
echo "required command was not found: $command" >&2
exit 1
}
done
for required in \
"$include_directory/libavformat/avformat.h" \
"$library_directory/libavformat.dll.a" \
"$library_directory/libavcodec.dll.a" \
"$library_directory/libavutil.dll.a" \
"$library_directory/libswscale.dll.a" \
"$library_directory/libswresample.dll.a" \
"$sdk_root/LICENSE.txt"; do
if [[ ! -e "$required" ]]; then
echo "missing FFmpeg SDK file: $required" >&2
exit 1
fi
done
"$compiler" \
-std=c11 -O2 -Wall -Wextra -static-libgcc \
-I "$include_directory" \
-shared -Wl,--no-undefined -Wl,--no-insert-timestamp \
-o "$shim" "$script_dir/age_movie.c" \
-L "$library_directory" \
-lavformat -lavcodec -lavutil -lswscale -lswresample
runtime_libraries=(
avformat-62.dll
avcodec-62.dll
avutil-60.dll
swscale-9.dll
swresample-6.dll
)
for runtime in "${runtime_libraries[@]}"; do
source_library="$binary_directory/$runtime"
if [[ ! -f "$source_library" ]]; then
echo "missing FFmpeg runtime library: $source_library" >&2
exit 1
fi
cp -- "$source_library" "$output_directory/$runtime"
done
cp -- "$sdk_root/LICENSE.txt" "$output_directory/FFmpeg-LICENSE.txt"
python3 -X utf8 "$repo_root/tools/verify_windows_native.py" \
"$output_directory" \
--objdump "$objdump" \
--report "$output_directory/verification.json"
printf '%s\n' "$shim"