Build Opus Codec for iOS

来源:互联网 发布:唐安琪 知乎 编辑:程序博客网 时间:2024/06/04 18:35

项目中需要使用Opus Codec for iOS, 在github 上找了一个不错的脚本,  对其稍作修改, 编译非常顺利。 如下为脚本代码。 


#!/bin/bashVERSION="1.1.2"   #Opus VersionSDKVERSION="9.2"MINIOSVERSION="7.0"# by default, we won't build for debugging purposesif [ "${DEBUG}" == "true" ]; then    echo "Compiling for debugging ..."    OPT_CFLAGS="-O0 -fno-inline -g"    OPT_LDFLAGS=""    OPT_CONFIG_ARGS="--enable-assertions --disable-asm"else    OPT_CFLAGS="-Ofast -flto -g"    OPT_LDFLAGS="-flto"    OPT_CONFIG_ARGS=""fiARCHS="i386 x86_64 armv7 armv7s arm64"DEVELOPER=`xcode-select -print-path`cd "`dirname \"$0\"`"REPOROOT=$(pwd)OUTPUTDIR="${REPOROOT}/out"mkdir -p ${OUTPUTDIR}/includemkdir -p ${OUTPUTDIR}/libBUILDDIR="${REPOROOT}/build"echo $REPOROOTecho $OUTPUTDIRecho $BUILDDIRSRCDIR=$REPOROOTINTERDIR="${BUILDDIR}/built"mkdir -p $INTERDIRset +eCCACHE=`which ccache`if [ $? == "0" ]; then    echo "Building with ccache: $CCACHE"    CCACHE="${CCACHE} "else    echo "Building without ccache"    CCACHE=""fiset -eexport ORIGINALPATH=$PATHfor ARCH in ${ARCHS}do    if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then        PLATFORM="iPhoneSimulator"        EXTRA_CFLAGS="-arch ${ARCH}"        EXTRA_CONFIG=""    else        PLATFORM="iPhoneOS"        EXTRA_CFLAGS="-arch ${ARCH}"        EXTRA_CONFIG="--host=arm-apple-darwin"    fi    mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"    ./configure --enable-float-approx --disable-shared --enable-static --with-pic --disable-extra-programs --disable-doc ${EXTRA_CONFIG} \    --prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \    LDFLAGS="$LDFLAGS ${OPT_LDFLAGS} -fPIE -miphoneos-version-min=${MINIOSVERSION} -L${OUTPUTDIR}/lib" \    CFLAGS="$CFLAGS ${EXTRA_CFLAGS} ${OPT_CFLAGS} -fPIE -miphoneos-version-min=${MINIOSVERSION} -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \    # Build the application and install it to the fake SDK intermediary dir    # we have set up. Make sure to clean up afterward because we will re-use    # this source tree to cross-compile other targets.    make -j4    make install    make cleandone########################################echo "Build library..."# These are the libs that comprise libopus.OUTPUT_LIBS="libopus.a"for OUTPUT_LIB in ${OUTPUT_LIBS}; do    INPUT_LIBS=""    for ARCH in ${ARCHS}; do        if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];        then            PLATFORM="iPhoneSimulator"        else            PLATFORM="iPhoneOS"        fi        INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"        if [ -e $INPUT_ARCH_LIB ]; then            INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"        fi    done    # Combine the three architectures into a universal library.    if [ -n "$INPUT_LIBS"  ]; then        lipo -create $INPUT_LIBS \        -output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"    else        echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"    fidonefor ARCH in ${ARCHS}; do    if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];    then        PLATFORM="iPhoneSimulator"    else        PLATFORM="iPhoneOS"    fi    cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/    if [ $? == "0" ]; then        # We only need to copy the headers over once. (So break out of forloop        # once we get first success.)        break    fidone####################echo "Building done."echo "Cleaning up..."rm -fr ${INTERDIR}echo "Done."



Reference:  

     很棒的Opus iOS编译脚本,上面的代码大多从次复制。    https://github.com/chrisballinger/Opus-iOS



2 0
原创粉丝点击