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