Skip to content

Commit

Permalink
allow defining a custom toolkit for android and enable asm for 64 bit…
Browse files Browse the repository at this point in the history
… architectures with x265
  • Loading branch information
tanersener committed May 4, 2024
1 parent e4476c2 commit 47eb7d3
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 84 deletions.
12 changes: 10 additions & 2 deletions android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ while [ ! $# -eq 0 ]; do
--no-ffmpeg-kit-protocols)
export NO_FFMPEG_KIT_PROTOCOLS="1"
;;
--toolchain=*)
ANDROID_TOOLCHAIN=$(echo $1 | sed -e 's/^--[a-z]*=//g')
export ANDROID_TOOLCHAIN="${ANDROID_TOOLCHAIN}"
;;
*)
print_unknown_option "$1"
;;
Expand All @@ -150,6 +154,12 @@ if [[ -z ${BUILD_VERSION} ]]; then
exit 1
fi

if [[ -z ${ANDROID_TOOLCHAIN} ]]; then
export ANDROID_TOOLCHAIN="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/"$(get_toolchain)"
fi

echo -e "INFO: Using Android toolchain at ${ANDROID_TOOLCHAIN}\n" 1>>"${BASEDIR}"/build.log 2>&1

# PROCESS FULL OPTION AS LAST OPTION
if [[ -n ${BUILD_FULL} ]]; then
for library in {0..61}; do
Expand Down Expand Up @@ -227,8 +237,6 @@ for run_arch in {0..12}; do
fi

export ARCH=$(get_arch_name $run_arch)
export TOOLCHAIN=$(get_toolchain)
export TOOLCHAIN_ARCH=$(get_toolchain_arch)

# EXECUTE MAIN BUILD SCRIPT
. "${BASEDIR}"/scripts/main-android.sh "${ENABLED_LIBRARIES[@]}" || exit 1
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/chromaprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_system_processor) \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DFFT_LIB=kissfft \
Expand Down
2 changes: 1 addition & 1 deletion scripts/android/ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo -e "INFO: $(uname -a)\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "----------------------------------------------------------------\n" 1>>"${BASEDIR}"/build.log 2>&1

FFMPEG_LIBRARY_PATH="${LIB_INSTALL_BASE}/${LIB_NAME}"
ANDROID_SYSROOT="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/"${TOOLCHAIN}"/sysroot
ANDROID_SYSROOT="${ANDROID_TOOLCHAIN}"/sysroot

# SET PATHS
set_toolchain_paths "${LIB_NAME}"
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/jpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DENABLE_STATIC=1 \
-DENABLE_SHARED=0 \
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/libaom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
${ASM_OPTIONS} \
-DENABLE_TESTS=0 \
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/libilbc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DWEBRTC_ANDROID=1 \
-DUNIX=1 \
Expand Down
8 changes: 4 additions & 4 deletions scripts/android/libvidstab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DUSE_OMP=0 \
${ASM_OPTIONS} \
Expand Down
24 changes: 18 additions & 6 deletions scripts/android/openh264.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@ export LDFLAGS="$LDFLAGS $(pkg-config --libs --static libiconv) $(pkg-config --l

# SET BUILD OPTIONS
case ${ARCH} in
arm-v7a)
BUILD_ARCH=arm
CFLAGS+=" -DANDROID_NDK"
;;
arm-v7a-neon)
ASM_OPTIONS=arm
BUILD_ARCH=arm
CFLAGS+=" -DHAVE_NEON -DANDROID_NDK"
;;
arm64-v8a)
ASM_OPTIONS=arm64
BUILD_ARCH=arm64
CFLAGS+=" -DHAVE_NEON_AARCH64 -DANDROID_NDK"
;;
x86*)
x86)
ASM_OPTIONS=x86
BUILD_ARCH=x86
CFLAGS+=" -DHAVE_AVX2 -DANDROID_NDK"
;;
x86-64)
ASM_OPTIONS=x86
BUILD_ARCH=x86_64
CFLAGS+=" -DHAVE_AVX2 -DANDROID_NDK"
;;
esac
Expand All @@ -33,18 +45,18 @@ ${SED_INLINE} 's/^COMMON_OBJS +=/# COMMON_OBJS +=/' "${BASEDIR}"/src/"${LIB_NAME
${SED_INLINE} 's/^COMMON_CFLAGS +=/# COMMON_CFLAGS +=/' "${BASEDIR}"/src/"${LIB_NAME}"/build/platform-android.mk

make -j$(get_cpu_count) \
ARCH="$(get_toolchain_arch)" \
CC="$CC" \
CFLAGS="$CFLAGS" \
CXX="$CXX" \
ARCH="${BUILD_ARCH}" \
CC="${CC}" \
CFLAGS="${CFLAGS}" \
CXX="${CXX}" \
AR="${AR}" \
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

Expand Down
10 changes: 5 additions & 5 deletions scripts/android/snappy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DSNAPPY_BUILD_TESTS=0 \
-DSNAPPY_BUILD_BENCHMARKS=0 \
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/soxr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DBUILD_TESTS=0 \
-DWITH_DEV_TRACE=0 \
Expand Down
10 changes: 5 additions & 5 deletions scripts/android/srt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ cmake -Wno-dev \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_SYSTEM_VERSION=${API} \
-DCMAKE_ANDROID_NDK=${ANDROID_NDK_ROOT} \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_TOOLCHAIN}/bin/$AS" \
-DCMAKE_SYSTEM_LOADED=1 \
-DCMAKE_SYSTEM_PROCESSOR="${SYSTEM_PROCESSOR}" \
-DENABLE_STDCXX_SYNC=1 \
Expand Down
29 changes: 16 additions & 13 deletions scripts/android/x265.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash

# SET BUILD OPTIONS
git checkout "${BASEDIR}"/src/"${LIB_NAME}"/source/CMakeLists.txt || return 1
ASM_OPTIONS=""
case ${ARCH} in
arm-v7a | arm-v7a-neon)
ASM_OPTIONS="-DENABLE_ASSEMBLY=0 -DCROSS_COMPILE_ARM=1"
ASM_OPTIONS="-DENABLE_ASSEMBLY=0"
${SED_INLINE} "s|ARM_ARGS -mcpu=native.*|ARM_ARGS $(get_arch_specific_cflags) --target=$(get_clang_host))|g" "${BASEDIR}"/src/"${LIB_NAME}"/source/CMakeLists.txt || return 1
;;
arm64-v8a)
ASM_OPTIONS="-DENABLE_ASSEMBLY=0 -DCROSS_COMPILE_ARM=1"
ASM_OPTIONS="-DENABLE_ASSEMBLY=1"
${SED_INLINE} "s|ARM_ARGS -fPIC -flax-vector-conversions.*|ARM_ARGS --target=$(get_clang_host) -fPIC -flax-vector-conversions)|g" "${BASEDIR}"/src/"${LIB_NAME}"/source/CMakeLists.txt || return 1
;;
x86)
ASM_OPTIONS="-DENABLE_ASSEMBLY=0 -DCROSS_COMPILE_ARM=0"
ASM_OPTIONS="-DENABLE_ASSEMBLY=0"
;;
x86-64)
ASM_OPTIONS="-DENABLE_ASSEMBLY=0 -DCROSS_COMPILE_ARM=0"
ASM_OPTIONS="-DENABLE_ASSEMBLY=1"
;;
esac

Expand All @@ -28,28 +31,28 @@ cmake -Wno-dev \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SYSROOT="${ANDROID_SYSROOT}" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_SYSROOT}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${LIB_INSTALL_PREFIX}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_SYSTEM_VERSION=${API} \
-DCMAKE_C_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_TOOLCHAIN}/bin/$AR" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DSTATIC_LINK_CRT=1 \
-DENABLE_PIC=1 \
-DENABLE_CLI=0 \
-DHIGH_BIT_DEPTH=1 \
${ASM_OPTIONS} \
-DCMAKE_SYSTEM_PROCESSOR="${ARCH}" \
-DCMAKE_SYSTEM_PROCESSOR="$(get_cmake_system_processor)"\
-DENABLE_SHARED=0 "${BASEDIR}"/src/"${LIB_NAME}"/source || return 1

make -j$(get_cpu_count) || return 1

make install || return 1

# CREATE PACKAGE CONFIG MANUALLY
create_x265_package_config "3.4" || return 1
create_x265_package_config "3.6" || return 1
Loading

0 comments on commit 47eb7d3

Please sign in to comment.