mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-29 01:53:54 +03:00
devops: cross-compile ffmpeg to arm64 linux (#9979)
This commit is contained in:
parent
d9d41b2e01
commit
ad4632935f
@ -66,6 +66,12 @@ elif [[ "$BUILD_FLAVOR" == "ffmpeg-linux" ]]; then
|
||||
EXPECTED_HOST_OS="Ubuntu"
|
||||
EXPECTED_HOST_OS_VERSION="20.04"
|
||||
BUILD_BLOB_NAME="ffmpeg-linux.zip"
|
||||
elif [[ "$BUILD_FLAVOR" == "ffmpeg-linux-arm64" ]]; then
|
||||
BROWSER_NAME="ffmpeg"
|
||||
EXTRA_BUILD_ARGS="--cross-compile-linux-arm64"
|
||||
EXPECTED_HOST_OS="Ubuntu"
|
||||
EXPECTED_HOST_OS_VERSION="20.04"
|
||||
BUILD_BLOB_NAME="ffmpeg-linux-arm64.zip"
|
||||
elif [[ "$BUILD_FLAVOR" == "ffmpeg-cross-compile-win64" ]]; then
|
||||
BROWSER_NAME="ffmpeg"
|
||||
EXTRA_BUILD_ARGS="--cross-compile-win64"
|
||||
|
@ -1,4 +1,5 @@
|
||||
ffmpeg-mac.zip
|
||||
ffmpeg-linux.zip
|
||||
ffmpeg-linux-arm64.zip
|
||||
ffmpeg-win64.zip
|
||||
|
||||
|
@ -46,30 +46,31 @@ if [[ -t 0 ]]; then
|
||||
dockerflags="-it"
|
||||
fi
|
||||
|
||||
function ensure_docker_or_die() {
|
||||
if ! command -v docker >/dev/null; then
|
||||
echo "ERROR: docker is required for the script"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$1" == "--mac" ]]; then
|
||||
bash ./build-mac.sh
|
||||
cd output && zip ffmpeg.zip ffmpeg-mac "${LICENSE_FILE}"
|
||||
elif [[ "$1" == "--linux" ]]; then
|
||||
if ! command -v docker >/dev/null; then
|
||||
echo "ERROR: docker is required for the script"
|
||||
exit 1
|
||||
fi
|
||||
ensure_docker_or_die
|
||||
|
||||
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/build-linux.sh /host/output/ffmpeg-linux
|
||||
cd output && zip ffmpeg.zip ffmpeg-linux "${LICENSE_FILE}"
|
||||
elif [[ "$1" == --cross-compile-win* ]]; then
|
||||
if ! command -v docker >/dev/null; then
|
||||
echo "ERROR: docker is required for the script"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$1" == --cross-compile-win64 ]]; then
|
||||
ensure_docker_or_die
|
||||
|
||||
if [[ "$1" == "--cross-compile-win64" ]]; then
|
||||
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/crosscompile-from-linux-to-win.sh --win64 /host/output/ffmpeg-win64.exe
|
||||
cd output && zip ffmpeg.zip ffmpeg-win64.exe "${LICENSE_FILE}"
|
||||
else
|
||||
echo "ERROR: unsupported platform - $1"
|
||||
exit 1
|
||||
fi
|
||||
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/crosscompile-from-linux.sh --win64 /host/output/ffmpeg-win64.exe
|
||||
cd output && zip ffmpeg.zip ffmpeg-win64.exe "${LICENSE_FILE}"
|
||||
elif [[ "$1" == "--cross-compile-linux-arm64" ]]; then
|
||||
ensure_docker_or_die
|
||||
|
||||
time docker run --init --rm -v"${PWD}":/host ${dockerflags} ubuntu:18.04 bash /host/crosscompile-from-linux.sh --linux-arm64 /host/output/ffmpeg-linux-arm64
|
||||
cd output && zip ffmpeg.zip ffmpeg-linux-arm64 "${LICENSE_FILE}"
|
||||
else
|
||||
echo "ERROR: unsupported platform - $1"
|
||||
exit 1
|
||||
|
@ -20,27 +20,30 @@ function die() { echo "$@"; exit 1; }
|
||||
|
||||
|
||||
PREFIX="${HOME}/prefix"
|
||||
TOOLCHAIN_PREFIX_32="/usr/bin/i686-w64-mingw32-"
|
||||
TOOLCHAIN_PREFIX_64="/usr/bin/x86_64-w64-mingw32-"
|
||||
TOOLCHAIN_PREFIX_ARM64="/usr/bin/aarch64-linux-gnu-"
|
||||
|
||||
arch=""
|
||||
toolchain_prefix=""
|
||||
binary=""
|
||||
|
||||
if [[ "$(uname)" != "Linux" ]]; then
|
||||
echo "ERROR: this script is designed to be run on Linux. Can't run on $(uname)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" == "--win32" ]]; then
|
||||
arch="win32";
|
||||
toolchain_prefix="${TOOLCHAIN_PREFIX_32}"
|
||||
elif [[ "$1" == "--win64" ]]; then
|
||||
if [[ "$1" == "--win64" ]]; then
|
||||
arch="win64";
|
||||
toolchain_prefix="${TOOLCHAIN_PREFIX_64}"
|
||||
binary="ffmpeg.exe"
|
||||
elif [[ "$1" == "--linux-arm64" ]]; then
|
||||
arch="linux-arm64";
|
||||
toolchain_prefix="${TOOLCHAIN_PREFIX_ARM64}"
|
||||
binary="ffmpeg"
|
||||
elif [[ -z "$1" ]]; then
|
||||
die "ERROR: expect --win32 or --win64 as the first argument"
|
||||
die "ERROR: expect --win64 or --linux-arm64 as the first argument"
|
||||
else
|
||||
die "ERROR: unknown arch '$1' - expected --win32 or --win64"
|
||||
die "ERROR: unknown arch '$1' - expected --win64 or --linux-arm64"
|
||||
fi
|
||||
|
||||
output_path="$2"
|
||||
@ -77,10 +80,10 @@ function build_libvpx {
|
||||
# Cross-compiling libvpx according to the docs:
|
||||
# - https://chromium.googlesource.com/webm/libvpx/+/master/README
|
||||
local target=""
|
||||
if [[ $arch == "win32" ]]; then
|
||||
target="x86-win32-gcc";
|
||||
elif [[ $arch == "win64" ]]; then
|
||||
if [[ $arch == "win64" ]]; then
|
||||
target="x86_64-win64-gcc";
|
||||
elif [[ $arch == "linux-arm64" ]]; then
|
||||
target="arm64-linux-gcc";
|
||||
else
|
||||
die "ERROR: unsupported arch to compile libvpx - $arch"
|
||||
fi
|
||||
@ -98,16 +101,20 @@ function build_ffmpeg {
|
||||
export PKG_CONFIG_LIBDIR=
|
||||
|
||||
local ffmpeg_arch=""
|
||||
if [[ $arch == "win32" ]]; then
|
||||
ffmpeg_arch="x86";
|
||||
elif [[ $arch == "win64" ]]; then
|
||||
local ffmpeg_target_os=""
|
||||
if [[ $arch == "win64" ]]; then
|
||||
ffmpeg_arch="x86_64";
|
||||
ffmpeg_target_os="mingw32"
|
||||
elif [[ $arch == "linux-arm64" ]]; then
|
||||
ffmpeg_arch="arm64";
|
||||
ffmpeg_target_os="linux"
|
||||
else
|
||||
die "ERROR: unsupported arch to compile ffmpeg - $arch"
|
||||
fi
|
||||
./configure --arch="${ffmpeg_arch}" \
|
||||
--target-os=mingw32 \
|
||||
--target-os="${ffmpeg_target_os}" \
|
||||
--cross-prefix="${toolchain_prefix}" \
|
||||
--disable-doc \
|
||||
--pkg-config=pkg-config \
|
||||
--pkg-config-flags="--static" \
|
||||
--extra-cflags="-I/${PREFIX}/include" \
|
||||
@ -124,12 +131,17 @@ cd "$(dirname $0)"
|
||||
source ./CONFIG.sh
|
||||
|
||||
apt-get update
|
||||
apt-get install -y mingw-w64 git make yasm pkg-config
|
||||
apt-get install -y git make yasm pkg-config
|
||||
if [[ "${arch}" == "linux-arm64" ]]; then
|
||||
apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
||||
else
|
||||
apt-get install -y mingw-w64
|
||||
fi
|
||||
|
||||
build_zlib
|
||||
build_libvpx
|
||||
build_ffmpeg
|
||||
|
||||
# put resulting executable where we were asked to
|
||||
cp "${HOME}/ffmpeg/bin/ffmpeg.exe" "${output_path}"
|
||||
cp "${HOME}/ffmpeg/bin/${binary}" "${output_path}"
|
||||
${toolchain_prefix}strip "${output_path}"
|
Loading…
Reference in New Issue
Block a user