1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 04:18:09 +03:00

libvpx build

This commit is contained in:
Anton Afanasyeu
2026-05-18 16:13:34 +02:00
parent f7e200fa94
commit 1dbfc996c2
4 changed files with 58 additions and 29 deletions

View File

@@ -27,23 +27,14 @@ if [[ ! -d "$VPX_SRC_REAL" ]]; then
exit 1
fi
NDK=""
if [[ -f "$ROOT/local.properties" ]]; then
NDK="$(sed -n 's/^ndk\.dir=//p' "$ROOT/local.properties" | tr -d '\r' | head -1)"
fi
if [[ -z "$NDK" && -n "${ANDROID_NDK_HOME:-}" ]]; then
NDK="$ANDROID_NDK_HOME"
fi
if [[ -z "$NDK" && -n "${ANDROID_NDK_ROOT:-}" ]]; then
NDK="$ANDROID_NDK_ROOT"
fi
NDK="${NDK%/}"
if [[ -z "$NDK" || ! -d "$NDK" ]]; then
echo "ERROR: Set ndk.dir in local.properties or ANDROID_NDK_HOME"
# shellcheck source=android_find_latest_ndk.sh
source "$ROOT/android_find_latest_ndk.sh"
if ! NDK="$(android_find_ndk_root "$ROOT")"; then
exit 1
fi
if [[ ! -x "$NDK/ndk-build" ]]; then
echo "ERROR: ndk-build not found under $NDK"
NDK_HOST_BIN="$(android_ndk_host_prebuilt_bin "$NDK")"
if [[ ! -d "$NDK_HOST_BIN" ]]; then
echo "ERROR: NDK host toolchain bin not found under $NDK"
exit 1
fi
@@ -79,8 +70,23 @@ if path_has_space "$ROOT" || path_has_space "$VPX_SRC_REAL"; then
fi
mkdir -p "$BUILD_DIR" "$OUT" "$PROJECT_OUT"
export ANDROID_NDK_HOME="$NDK"
export ANDROID_NDK_ROOT="$NDK"
export PATH="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH"
export PATH="$NDK_HOST_BIN:$PATH"
VPX_CONFIGURE_EXTRA=()
APP_CFLAGS_EXTRA=""
case "$ABI" in
x86)
# NDK does not infer -msse4.1/-mavx from libvpx source names; AVX-512 is unused on Android x86.
VPX_CONFIGURE_EXTRA+=(--disable-avx512)
APP_CFLAGS_EXTRA="-msse4.1 -mavx"
;;
x86_64)
VPX_CONFIGURE_EXTRA+=(--disable-avx512)
APP_CFLAGS_EXTRA="-msse4.1 -mavx -mavx2"
;;
esac
echo "Building libvpx for $ABI (target=$VPX_TARGET) ..."
echo " source: $VPX_SRC"
@@ -110,6 +116,12 @@ elif [[ ! -f "$LIBS_MK" ]] || ! grep -q "^TOOLCHAIN := ${VPX_TARGET}\$" "$BUILD_
make distclean >/dev/null 2>&1 || rm -f Makefile config.mk "$LIBS_MK" vpx_config.h vpx_config.c vpx_config.asm \
vpx_version.h vp8_rtcd.h vp9_rtcd.h vpx_scale_rtcd.h vpx_dsp_rtcd.h
need_configure=true
elif [[ "$ABI" == x86 || "$ABI" == x86_64 ]] && [[ -f "$BUILD_DIR/vpx_config.h" ]] \
&& grep -q '#define HAVE_AVX512 1' "$BUILD_DIR/vpx_config.h"; then
echo "Re-configuring (AVX-512 disabled for Android NDK on $ABI)..."
make distclean >/dev/null 2>&1 || rm -f Makefile config.mk "$LIBS_MK" vpx_config.h vpx_config.c vpx_config.asm \
vpx_version.h vp8_rtcd.h vp9_rtcd.h vpx_scale_rtcd.h vpx_dsp_rtcd.h
need_configure=true
fi
if $need_configure; then
@@ -135,7 +147,8 @@ if $need_configure; then
--enable-spatial-resampling \
--disable-debug-libs \
--disable-docs \
--enable-external-build
--enable-external-build \
"${VPX_CONFIGURE_EXTRA[@]}"
fi
# armeabi-v7a ndk-build runs make in ndk-app/ and needs vpx_config.asm (not required for arm64).
@@ -175,11 +188,14 @@ if [[ -f "$LIBS_MK_NDK" ]]; then
ln -sfn "$LIBS_MK_NDK" "$JNI_DIR/libs-${VPX_TARGET}.mk"
fi
cat > "$JNI_DIR/Application.mk" <<EOF
APP_ABI := $ABI
APP_PLATFORM := android-29
APP_STL := c++_static
EOF
{
echo "APP_ABI := $ABI"
echo "APP_PLATFORM := android-29"
echo "APP_STL := c++_static"
if [[ -n "$APP_CFLAGS_EXTRA" ]]; then
echo "APP_CFLAGS += $APP_CFLAGS_EXTRA"
fi
} > "$JNI_DIR/Application.mk"
cat > "$JNI_DIR/Android.mk" <<'EOF'
LOCAL_PATH := $(call my-dir)