Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NDK Unified headers support https://android.googlesource.com/pl… #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions build_scripts/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ if [ "$FLAVOR" = "lite" ]; then
# LITE flavor support android 16+
ARM_SYSROOT=$NDK/platforms/android-16/arch-arm/
X86_SYSROOT=$NDK/platforms/android-16/arch-x86/
UNIFIED_ANDROID_API=16
else
# FULL flavor require android 21 at minimum (because of including openssl)
ARM_SYSROOT=$NDK/platforms/android-21/arch-arm/
X86_SYSROOT=$NDK/platforms/android-21/arch-x86/
UNIFIED_ANDROID_API=21
fi
ARM_PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$OS
X86_PREBUILT=$NDK/toolchains/x86-4.9/prebuilt/$OS
Expand All @@ -55,6 +57,13 @@ X86_64_PREBUILT=$NDK/toolchains/x86_64-4.9/prebuilt/$OS
# MIPS64_PREBUILT=$NDK/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64
# MIPS64_CROSS_PREFIX=$MIPS64_PREBUILT/bin/$HOST-

# For unified headers https://android.googlesource.com/platform/ndk/+/ndk-release-r16/docs/UnifiedHeaders.md
UNIFIED_INCLUDEPATH=$NDK/sysroot/usr/include
ARM_UNIFIED_INCLUDEPATH=$NDK/sysroot/usr/include/arm-linux-androideabi
X86_UNIFIED_INCLUDEPATH=$NDK/sysroot/usr/include/i686-linux-android
ARM64_UNIFIED_INCLUDEPATH=$NDK/sysroot/usr/include/aarch64-linux-android
X86_64_UNIFIED_INCLUDEPATH=$NDK/sysroot/usr/include/x86_64-linux-android

if [ "$FFMPEG_VERSION" = "" ]; then
FFMPEG_VERSION="3.3.2"
fi
Expand Down Expand Up @@ -182,21 +191,25 @@ then
HOST=arm-linux-androideabi
CROSS_PREFIX=$ARM_PREBUILT/bin/$HOST-
OPTIMIZE_CFLAGS="$OPTIMIZE_CFLAGS "
UNIFIED_INCLUDEPATH_ARCH=$ARM_UNIFIED_INCLUDEPATH
elif [ $ARCH == "arm64" ]
then
SYSROOT=$ARM64_SYSROOT
HOST=aarch64-linux-android
CROSS_PREFIX=$ARM64_PREBUILT/bin/$HOST-
UNIFIED_INCLUDEPATH_ARCH=$ARM64_UNIFIED_INCLUDEPATH
elif [ $ARCH == "x86_64" ]
then
SYSROOT=$X86_64_SYSROOT
HOST=x86_64-linux-android
CROSS_PREFIX=$X86_64_PREBUILT/bin/$HOST-
UNIFIED_INCLUDEPATH_ARCH=$X86_64_UNIFIED_INCLUDEPATH
elif [ $ARCH == "i686" ]
then
SYSROOT=$X86_SYSROOT
HOST=i686-linux-android
CROSS_PREFIX=$X86_PREBUILT/bin/$HOST-
UNIFIED_INCLUDEPATH_ARCH=$X86_UNIFIED_INCLUDEPATH
# elif [ $ARCH == "mips" ]
# then
# SYSROOT=$MIPS_SYSROOT
Expand All @@ -219,9 +232,9 @@ export AR="${CROSS_PREFIX}ar"
export NM="${CROSS_PREFIX}nm"
export RANLIB="${CROSS_PREFIX}ranlib"
export LDFLAGS="-L$PREFIX/lib -fPIE -pie "
export CFLAGS="$OPTIMIZE_CFLAGS -I$PREFIX/include --sysroot=$SYSROOT -fPIE "
export CFLAGS="$OPTIMIZE_CFLAGS -I$PREFIX/include --sysroot=$SYSROOT -fPIE -isystem $UNIFIED_INCLUDEPATH -isystem $UNIFIED_INCLUDEPATH_ARCH -D__ANDROID_API__=$UNIFIED_ANDROID_API "
export CXXFLAGS="$CFLAGS "
export CPPFLAGS="--sysroot=$SYSROOT "
export CPPFLAGS="--sysroot=$SYSROOT -isystem $UNIFIED_INCLUDEPATH -isystem $UNIFIED_INCLUDEPATH_ARCH -D__ANDROID_API__=$UNIFIED_ANDROID_API "
export STRIP=${CROSS_PREFIX}strip
export PATH="$PATH:$PREFIX/bin/"

Expand Down