1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 03:57:50 +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

5
.gitignore vendored
View File

@@ -11,3 +11,8 @@ captures/
*.dex
third-party/*
app/.*
bin
lib
include
.log_capture
debug-capture

View File

@@ -34,6 +34,7 @@ public final class SettingsUi {
}
/** @deprecated use {@link #bindSender} or {@link #bindReceiver} */
@Deprecated
public static void bind(AppCompatActivity activity, CastSettings settings) {
bindSender(activity, settings);
}

View File

@@ -107,18 +107,25 @@ reconnect_known_devices() {
adb devices -l
}
echo "==> Cleaning and building debug APK (JAVA_HOME=$JAVA_HOME)"
./gradlew clean assembleDebug
# shellcheck source=android_find_latest_ndk.sh
source "$ROOT/android_find_latest_ndk.sh"
export ANDROID_NDK_HOME="$(android_find_ndk_root "$ROOT")"
export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME"
echo "==> Using NDK: $ANDROID_NDK_HOME"
export ANDROID_NDK_HOME="/home/foxx/Android/Sdk/ndk/29.0.14206865/"
ARCH_ABIS="armeabi-v7a arm64-v8a x86"
rm -drf ./build/native/* ||:
# Match app/build.gradle defaultConfig.ndk.abiFilters
ARCH_ABIS="armeabi-v7a arm64-v8a x86_64"
echo "==> Building libvpx for: ${ARCH_ABIS}"
rm -rf "$ROOT/build/native"
mkdir -p "$ROOT/build/native"
for ARCH_ABI in ${ARCH_ABIS}; do
unset ANDROIDCAST_LIBVPX_LIB
./scripts/build-native-codecs.sh "${ARCH_ABI}" || exit $?
./gradlew assembleDebug || exit $?
LC_ALL=C ./scripts/build-native-codecs.sh "${ARCH_ABI}"
done
echo "==> Building debug APK (JAVA_HOME=$JAVA_HOME)"
./gradlew clean assembleDebug
if [[ "$RUN_UNIT_TESTS" == "1" ]]; then
echo "==> Running unit tests (./gradlew testDebugUnitTest)"
./gradlew testDebugUnitTest

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)