[Android] [PATCH 1/7] Support compiling on Android-x86

Edward Wang edward.c.wang at compdigitec.com
Wed Jul 18 13:17:00 CEST 2012


On 12-07-17 04:30 PM, Rafaël Carré <funman at videolan.org> wrote:
> Le 2012-07-15 22:27, Edward Wang a écrit :
>> This also softens the ground for the upcoming MIPS port too.
>> ---
>>   compile.sh        |   10 ++++++++--
>>   configure.sh      |   39 +++++++++++++++++++++++++--------------
>>   setup-abi-vars.sh |   19 +++++++++++++++++++
>>   3 files changed, 52 insertions(+), 16 deletions(-)
>>   create mode 100755 setup-abi-vars.sh
>>
>> diff --git a/compile.sh b/compile.sh
>> index 63c0046..43bfa9c 100755
>> --- a/compile.sh
>> +++ b/compile.sh
>> @@ -31,9 +31,12 @@ if [ -z $REL ]; then
>>       exit 1
>>   fi
>>   
>> +# Set up ABI variables (TARGET_TUPLET, PATH_HOST)
> Apparently "tuplet" is related to music, you want "tuple".
OK.
>
>> +source setup-abi-vars.sh
> Please just put the code in compile.sh
The script is used again in a later patch, and it's better to avoid code 
duplication IMO, so I think we should keep this.
>
>> +
>>   # Add the NDK toolchain to the PATH, needed both for contribs and for building
>>   # stub libraries
>> -export PATH=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:${PATH}
>> +export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin:${PATH}
>>   
>>   # 1/ libvlc, libvlccore and its plugins
>>   TESTED_HASH=e75d2024
>> @@ -71,7 +74,7 @@ fi
>>   echo "Building the contribs"
>>   mkdir -p contrib/android
>>   cd contrib/android
>> -../bootstrap --host=arm-linux-androideabi --disable-disc --disable-sout --enable-small \
>> +../bootstrap --host=${TARGET_TUPLET} --disable-disc --disable-sout --enable-small \
>>       --disable-sdl \
>>       --disable-SDL_image \
>>       --disable-fontconfig \
>> @@ -109,6 +112,9 @@ elif [ ${ANDROID_ABI} = "armeabi" ] ; then
>>               EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp"
>>           fi
>>       fi
>> +elif [ ${ANDROID_ABI} = "x86" ] ; then
>> +    # do x86 stuff
> isn't the comment redundant with the line above?
OK.
>> +    EXTRA_CFLAGS="-g -march=pentium -ffunction-sections -funwind-tables -frtti -fno-exceptions"
>>   else
>>       echo "Unknown ABI. Die, die, die!"
>>       exit 2
>> diff --git a/configure.sh b/configure.sh
>> index c5dd97f..823b8b0 100755
>> --- a/configure.sh
>> +++ b/configure.sh
>> @@ -6,32 +6,43 @@ if [ -z "$ANDROID_NDK" -o -z "$ANDROID_ABI" ]; then
>>       exit 1
>>   fi
>>   
>> +# Set up ABI variables (TARGET_TUPLET, PATH_HOST, HAVE_*)
>> +source $(dirname $0)/setup-abi-vars.sh
>> +
>>   # Must use android-9 here. Any replacement functions needed are in the vlc-android/jni
>>   # folder.
>>   ANDROID_API=android-9
>>   
>>   VLC_SOURCEDIR=..
>>   
>> -CFLAGS="-g -O2 -mlong-calls -fstrict-aliasing -funsafe-math-optimizations"
>> +CFLAGS="-g -O2 -fstrict-aliasing -funsafe-math-optimizations"
>> +# on x86, the compiler spits out
>> +# cc1: error: unrecognized command line option "-mlong-calls"
> This option is correctly documented in gcc as ARM only, no need to
> mention it here.
OK.
>> +if [ -n "$HAVE_ARM" ]; then
>> +    CFLAGS="${CFLAGS} -mlong-calls"
> Why do we use -mlong-calls btw?
>
Was introduced by j-b in 
http://git.videolan.org/?p=vlc.git;a=commit;f=extras/package/android/configure.sh;h=a9873b8120fa499e51f30ab62f520310b8d510ac
>> +fi
>> +
>>   LDFLAGS="-Wl,-Bdynamic,-dynamic-linker=/system/bin/linker -Wl,--no-undefined"
>>   
>> -if [ -z "$NO_NEON" ]; then
>> -    NO_NEON=0
>> -fi
>> +if [ -n "$HAVE_ARM" ]; then
>> +    if [ -z "$NO_NEON" ]; then
>> +        NO_NEON=0
>> +    fi
>>   
>> -if [ $NO_NEON -gt 0 ]; then
>> -    EXTRA_PARAMS=" --disable-neon"
>> -else
>> -    EXTRA_PARAMS=" --enable-neon"
>> -    LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
>> +    if [ $NO_NEON -gt 0 ]; then
>> +        EXTRA_PARAMS=" --disable-neon"
>> +    else
>> +        EXTRA_PARAMS=" --enable-neon"
>> +        LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
>> +    fi
>>   fi
>>   
>>   CPPFLAGS="-I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_ABI}/include"
>>   LDFLAGS="$LDFLAGS -L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_ABI}"
>>   
>> -SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-arm
>> -ANDROID_BIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86/bin/
>> -CROSS_COMPILE=${ANDROID_BIN}/arm-linux-androideabi-
>> +SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-$PLATFORM_SHORT_ARCH
>> +ANDROID_BIN=$ANDROID_NDK/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin/
>> +CROSS_COMPILE=${ANDROID_BIN}/${TARGET_TUPLET}-
>>   
>>   CPPFLAGS="$CPPFLAGS" \
>>   CFLAGS="$CFLAGS ${VLC_EXTRA_CFLAGS}" \
>> @@ -43,7 +54,7 @@ NM="${CROSS_COMPILE}nm" \
>>   STRIP="${CROSS_COMPILE}strip" \
>>   RANLIB="${CROSS_COMPILE}ranlib" \
>>   AR="${CROSS_COMPILE}ar" \
>> -sh $VLC_SOURCEDIR/configure --host=arm-linux-androideabi --build=x86_64-unknown-linux $EXTRA_PARAMS \
>> +sh $VLC_SOURCEDIR/configure --host=$TARGET_TUPLET --build=x86_64-unknown-linux $EXTRA_PARAMS \
>>                   --enable-live555 --enable-realrtsp \
>>                   --enable-avformat \
>>                   --enable-swscale \
>> diff --git a/setup-abi-vars.sh b/setup-abi-vars.sh
>> new file mode 100755
>> index 0000000..aebd1a0
>> --- /dev/null
>> +++ b/setup-abi-vars.sh
>> @@ -0,0 +1,19 @@
>> +#!/bin/sh
>> +
>> +# Set up architecture specific variables
>> +if [ ${ANDROID_ABI} = "x86" ] ; then
>> +    TARGET_TUPLET="i686-android-linux"
>> +    PATH_HOST="x86"
>> +    HAVE_X86=1
>> +    PLATFORM_SHORT_ARCH="x86"
>> +elif [ ${ANDROID_ABI} = "mips" ] ; then
>> +    TARGET_TUPLET="mipsel-linux-android"
>> +    PATH_HOST=$TARGET_TUPLET
>> +    HAVE_MIPS=1
>> +    PLATFORM_SHORT_ARCH="mips"
>> +else
>> +    TARGET_TUPLET="arm-linux-androideabi"
>> +    PATH_HOST=$TARGET_TUPLET
>> +    HAVE_ARM=1
>> +    PLATFORM_SHORT_ARCH="arm"
>> +fi
>>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> http://mailman.videolan.org/listinfo/android




More information about the Android mailing list