ios:编译vp8 libvpx

首先,

创建文件夹build-patches,添加两个文件libvpx-configure.sh.patch和libvpx-gen_asm_deps.sh.patch,文件内容如下:

libvpx-configure.sh.patch文件内容

--- build/src/libvpx-v1.1.0/build/make/configure.sh.orig 2012-05-08 16:14:00.000000000 -0700
+++ build/src/libvpx-v1.1.0/build/make/configure.sh 2012-10-29 13:40:35.000000000 -0700
@@ -844,7 +844,7 @@
             add_ldflags -arch_only ${tgt_isa}
 
             if [ -z "${alt_libc}" ]; then
-                alt_libc=${SDK_PATH}/SDKs/iPhoneOS5.1.sdk
+                alt_libc=${SDK_PATH}/SDKs/iPhoneOS6.1.sdk
             fi
 
             add_cflags  "-isysroot ${alt_libc}"

libvpx-gen_asm_deps.sh.patch文件内容

--- build/src/libvpx-v1.1.0/build/make/gen_asm_deps.sh.orig 2012-05-08 16:14:00.000000000 -0700
+++ build/src/libvpx-v1.1.0/build/make/gen_asm_deps.sh 2012-10-29 13:25:25.000000000 -0700
@@ -42,7 +42,7 @@
 
 [ -n "$srcfile" ] || show_help
 sfx=${sfx:-asm}
-includes=$(LC_ALL=C egrep -i "include +\"?+[a-z0-9_/]+\.${sfx}" $srcfile |
+includes=$(LC_ALL=C egrep -i "include +\"+[a-z0-9_/]+\.${sfx}" $srcfile |
            perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;")
 #" restore editor state
 for inc in ${includes}; do

创建脚本build-libvpx.sh,脚本如下:

#!/bin/bash
#  Builds libvpx for iPhone targets: iPhoneSimulator-i386,
#  iPhoneOS-armv7.
#
#  Copyright 2012 Mike Tigas <mike@tig.as>
#
#  Based on work by Felix Schulze on 16.12.10.
#  Copyright 2010 Felix Schulze. All rights reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
###########################################################################
#  Choose your libvpx version and your currently-installed iOS SDK version:
#
VERSION="1.1.0"
SDKVERSION="6.1"
#
#
###########################################################################
#
# Don't change anything under this line!
#
###########################################################################


# No need to change this since xcode build will only compile in the
# necessary bits from the libraries we create
ARCHS="i386 armv7"


DEVELOPER=`xcode-select -print-path`


cd "`dirname \"$0\"`"
REPOROOT=$(pwd)


# Where we'll end up storing things in the end
OUTPUTDIR="${REPOROOT}/dependencies"
mkdir -p ${OUTPUTDIR}/include
mkdir -p ${OUTPUTDIR}/lib
mkdir -p ${OUTPUTDIR}/bin




BUILDDIR="${REPOROOT}/build"


# where we will keep our sources and build from.
SRCDIR="${BUILDDIR}/src"
mkdir -p $SRCDIR
# where we will store intermediary builds
INTERDIR="${BUILDDIR}/built"
mkdir -p $INTERDIR


########################################


cd $SRCDIR


# Exit the script if an error happens
set -e


if [ ! -e "${SRCDIR}/libvpx-v${VERSION}.tar.bz2" ]; then
echo "Downloading libvpx-v${VERSION}.tar.bz2"
    curl -LO http://webm.googlecode.com/files/libvpx-v${VERSION}.tar.bz2


else
echo "Using libvpx-v${VERSION}.tar.bz2"
fi


tar zxf libvpx-v${VERSION}.tar.bz2 -C $SRCDIR
cd "${SRCDIR}/libvpx-v${VERSION}"


patch -p3 < ../../../build-patches/libvpx-configure.sh.patch
patch -p3 < ../../../build-patches/libvpx-gen_asm_deps.sh.patch


set +e # don't bail out of bash script if ccache doesn't exist
CCACHE=`which ccache`
if [ $? == "0" ]; then
    echo "Building with ccache: $CCACHE"
    CCACHE="${CCACHE} "
else
    echo "Building without ccache"
    CCACHE=""
fi
set -e # back to regular "bail out on error" mode


for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
        EXTRA_CONFIG="--target=x86-darwin12-gcc"
else
PLATFORM="iPhoneOS"
        EXTRA_CONFIG="--target=armv7-darwin-gcc"
fi


mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"


./configure --disable-shared --enable-static --enable-pic ${EXTRA_CONFIG} \
    --prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \
    --sdk-path="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" \


    # 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 -j2
make install
make clean
done


########################################


echo "Build library..."


# These are the libs that comprise libvpx.
OUTPUT_LIBS="libvpx.a"
for OUTPUT_LIB in ${OUTPUT_LIBS}; do
    INPUT_LIBS=""
    for ARCH in ${ARCHS}; do
        if [ "${ARCH}" == "i386" ];
        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?)"
    fi
done


for ARCH in ${ARCHS}; do
    if [ "${ARCH}" == "i386" ];
    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
    fi
done


for ARCH in ${ARCHS}; do
    if [ "${ARCH}" == "i386" ];
    then
        PLATFORM="iPhoneSimulator"
    else
        PLATFORM="iPhoneOS"
    fi
    cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/bin/* ${OUTPUTDIR}/bin/
    if [ $? == "0" ]; then
        # We only need to copy the binaries over once. (So break out of forloop
        # once we get first success.)
        break
    fi
done




####################


echo "Building done."
echo "Cleaning up..."
rm -fr ${INTERDIR}
rm -fr "${SRCDIR}/libvpx-v${VERSION}"
echo "Done."

运行脚本即可编译成功,注意libvpx版本和xcodeSDK版本。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值