Files
Velix-MPV-Core/scripts/build-ffmpeg-ohos.sh

83 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
set -eu
. "$(dirname -- "$0")/setup-ohos-env.sh"
SOURCE=$OHOS_BUILD_ROOT/sources/ffmpeg
BUILD=$OHOS_BUILD_ROOT/build/ffmpeg
LOG_DIR=$OHOS_BUILD_ROOT/logs
JOBS=$(sysctl -n hw.ncpu)
test -f "$SOURCE/configure" || "$PROJECT_ROOT/scripts/fetch-phase1-sources.sh"
test -f "$PREFIX/lib/libssl.a" || "$PROJECT_ROOT/scripts/build-openssl-ohos.sh"
mkdir -p "$BUILD" "$LOG_DIR"
cd "$BUILD"
if ! "$SOURCE/configure" \
--prefix="$PREFIX" \
--enable-cross-compile \
--target-os=linux \
--arch=aarch64 \
--cc="$CC" \
--cxx="$CXX" \
--ar="$AR" \
--ranlib="$RANLIB" \
--strip="$STRIP" \
--nm="$NM" \
--sysroot="$OHOS_SYSROOT" \
--pkg-config="$PKG_CONFIG" \
--extra-cflags="--target=$TARGET -D__MUSL__ -fPIC" \
--extra-ldflags="--target=$TARGET -L$PREFIX/lib" \
--enable-pic \
--enable-static \
--disable-shared \
--disable-programs \
--disable-doc \
--disable-debug \
--disable-avdevice \
--disable-autodetect \
--enable-network \
--enable-openssl \
--enable-zlib \
--enable-ohcodec > "$LOG_DIR/ffmpeg-configure.log" 2>&1; then
tail -n 120 "$LOG_DIR/ffmpeg-configure.log" >&2
exit 1
fi
if ! make -j"$JOBS" > "$LOG_DIR/ffmpeg-build.log" 2>&1; then
tail -n 160 "$LOG_DIR/ffmpeg-build.log" >&2
exit 1
fi
make install > "$LOG_DIR/ffmpeg-install.log" 2>&1
"$PROJECT_ROOT/scripts/verify-static-archive.sh" \
"$PREFIX/lib/libavcodec.a" \
"$PREFIX/lib/libavfilter.a" \
"$PREFIX/lib/libavformat.a" \
"$PREFIX/lib/libavutil.a" \
"$PREFIX/lib/libswresample.a" \
"$PREFIX/lib/libswscale.a"
for library in libavcodec libavfilter libavformat libavutil libswresample libswscale; do
"$PKG_CONFIG" --modversion "$library"
done
for definition in \
CONFIG_H264_DECODER \
CONFIG_HEVC_DECODER \
CONFIG_H264_OH_DECODER \
CONFIG_HEVC_OH_DECODER \
CONFIG_MATROSKA_DEMUXER \
CONFIG_MOV_DEMUXER \
CONFIG_HTTP_PROTOCOL \
CONFIG_HTTPS_PROTOCOL \
CONFIG_TCP_PROTOCOL \
CONFIG_TLS_PROTOCOL; do
grep -q "^#define $definition 1$" "$BUILD/config_components.h" || {
printf 'Missing FFmpeg feature: %s\n' "$definition" >&2
exit 1
}
done
grep -q '^#define CONFIG_NETWORK 1$' "$BUILD/config.h"
grep -q '^#define CONFIG_OHCODEC 1$' "$BUILD/config.h"