ffmpeg-kit/scripts/android/openh264.sh

53 lines
1.6 KiB
Bash
Raw Normal View History

2020-08-05 03:53:02 +03:00
#!/bin/bash
2020-11-23 00:51:45 +02:00
# UPDATE BUILD FLAGS
export CFLAGS="$CFLAGS $(pkg-config --cflags libiconv) $(pkg-config --cflags cpu-features)"
export LDFLAGS="$LDFLAGS $(pkg-config --libs --static libiconv) $(pkg-config --libs --static cpu-features)"
2020-08-05 03:53:02 +03:00
2020-11-23 00:51:45 +02:00
# SET BUILD OPTIONS
2020-08-05 03:53:02 +03:00
case ${ARCH} in
2020-11-23 00:51:45 +02:00
arm-v7a-neon)
ASM_OPTIONS=arm
CFLAGS+=" -DHAVE_NEON -DANDROID_NDK"
;;
arm64-v8a)
ASM_OPTIONS=arm64
CFLAGS+=" -DHAVE_NEON_AARCH64 -DANDROID_NDK"
;;
x86*)
ASM_OPTIONS=x86
CFLAGS+=" -DHAVE_AVX2 -DANDROID_NDK"
;;
2020-08-05 03:53:02 +03:00
esac
2020-11-23 00:51:45 +02:00
# ALWAYS CLEAN THE PREVIOUS BUILD
2020-08-05 03:53:02 +03:00
make clean 2>/dev/null 1>/dev/null
2020-11-23 00:51:45 +02:00
# DISCARD APPLE WORKAROUNDS
git checkout "${BASEDIR}"/src/"${LIB_NAME}"/build || return 1
git checkout "${BASEDIR}"/src/"${LIB_NAME}"/codec || return 1
2020-08-05 03:53:02 +03:00
2020-11-23 00:51:45 +02:00
# WORKAROUND TO DISABLE PARTS THAT COMPILE cpu-features INTO libopenh264.a
${SED_INLINE} 's/^COMMON_INCLUDES +=/# COMMON_INCLUDES +=/' "${BASEDIR}"/src/"${LIB_NAME}"/build/platform-android.mk
${SED_INLINE} 's/^COMMON_OBJS +=/# COMMON_OBJS +=/' "${BASEDIR}"/src/"${LIB_NAME}"/build/platform-android.mk
${SED_INLINE} 's/^COMMON_CFLAGS +=/# COMMON_CFLAGS +=/' "${BASEDIR}"/src/"${LIB_NAME}"/build/platform-android.mk
2020-08-05 03:53:02 +03:00
make -j$(get_cpu_count) \
2020-11-23 00:51:45 +02:00
ARCH="$(get_toolchain_arch)" \
CC="$CC" \
CFLAGS="$CFLAGS" \
CXX="$CXX" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" \
OS=android \
PREFIX="${LIB_INSTALL_PREFIX}" \
NDKLEVEL="${API}" \
NDKROOT="${ANDROID_NDK_ROOT}" \
NDK_TOOLCHAIN_VERSION=clang \
AR="$AR" \
ASM_OPTIONS=${ASM_OPTIONS} \
TARGET="android-${API}" install-static || return 1
2020-08-05 03:53:02 +03:00
# MANUALLY COPY PKG-CONFIG FILES
2020-11-23 00:51:45 +02:00
cp "${BASEDIR}"/src/"${LIB_NAME}"/openh264-static.pc "${INSTALL_PKG_CONFIG_DIR}"/openh264.pc || return 1