码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 通用交叉编译脚本

时间:2014-11-25 23:34:31      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   os   sp   for   on   2014   log   


唔. 一般在pc上我们都是

./configure

make

make install

一套打完收工..但是ios上怎么破.? 

-0- 主要是一些环境需要手动配置...

这里写了一些比较常见的环境.


把这玩意放到configure同路径下. 执行这脚本就OK了.


测试bson和lame库都OK


#!/bin/bash
 
BUILD_I386_IOS_SIM=1
BUILD_ARMV7_IPHONE=1
BUILD_ARMV7S_IPHONE=1

BUILD_TARGET=lame 

IOS_MIN_SDK=6.1
 
(
 
PWD=`pwd`
PREFIX=${PWD}/${BUILD_TARGET}

rm -rf ${PREFIX}/platform
mkdir -p ${PREFIX}/platform
 
EXTRA_MAKE_FLAGS="-j4"
 
XCODEDIR=`xcode-select --print-path`

IOS_SDK=$(xcodebuild -showsdks | grep iphoneos | sort | head -n 1 | awk '{print $NF}')
SIM_SDK=$(xcodebuild -showsdks | grep iphonesimulator | sort | head -n 1 | awk '{print $NF}')


IPHONEOS_PLATFORM=${XCODEDIR}/Platforms/iPhoneOS.platform
IPHONEOS_SYSROOT=${IPHONEOS_PLATFORM}/Developer/SDKs/${IOS_SDK}.sdk

IPHONESIMULATOR_PLATFORM=${XCODEDIR}/Platforms/iPhoneSimulator.platform
IPHONESIMULATOR_SYSROOT=${IPHONESIMULATOR_PLATFORM}/Developer/SDKs/${SIM_SDK}.sdk

CC=clang
CFLAGS="-DNDEBUG -g -O0 -pipe -fPIC -fcxx-exceptions"
CXX=clang
CXXFLAGS="${CFLAGS} -std=c++11 -stdlib=libc++"
LDFLAGS="-stdlib=libc++"
LIBS="-lc++ -lc++abi"



if [ $BUILD_ARMV7_IPHONE -eq 1 ]
then


echo "##################"
echo " armv7 for iPhone"
echo "##################"


(
		cd ${PWD}
    
		make ${EXTRA_MAKE_FLAGS} distclean
    ./configure --build=x86_64-apple-darwin13.0.0 --host=armv7-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7 -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}"
    make ${EXTRA_MAKE_FLAGS}
    make ${EXTRA_MAKE_FLAGS} install 
		
		cd ${PREFIX}/platform
		rm -rf armv7
		mkdir armv7
		cp ${PREFIX}/lib/*.a ${PREFIX}/platform/armv7
		
)
ARMV7_IPHONE_OUTPUT=`find ${PREFIX}/platform/armv7/*.a`



else

ARMV7_IPHONE_OUTPUT=

fi

if [ $BUILD_ARMV7S_IPHONE -eq 1 ]
then

echo "###################"
echo " armv7s for iPhone"
echo "###################"


(
		cd ${PWD}
		
    make ${EXTRA_MAKE_FLAGS}  distclean
    ./configure --build=x86_64-apple-darwin13.0.0 --host=armv7s-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7s -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}"
    make ${EXTRA_MAKE_FLAGS}
    make ${EXTRA_MAKE_FLAGS} install 
		
		cd ${PREFIX}/platform
		rm -rf armv7s
		mkdir armv7s
		cp ${PREFIX}/lib/*.a ${PREFIX}/platform/armv7s

)
ARMV7S_IPHONE_OUTPUT=`find ${PREFIX}/platform/armv7s/*.a`


else

ARMV7S_IPHONE_OUTPUT=

fi



if [ $BUILD_I386_IOS_SIM -eq 1 ]
then

echo "###########################"
echo " i386 for iPhone Simulator"
echo "###########################"

(
		cd ${PWD}
		make ${EXTRA_MAKE_FLAGS} distclean
    ./configure --build=x86_64-apple-darwin13.0.0 --host=i386-apple-darwin13.0.0 --enable-static --disable-shared --prefix=${PREFIX} "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${IOS_MIN_SDK} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch i386 -miphoneos-version-min=${IOS_MIN_SDK} ${LDFLAGS}" "LIBS=${LIBS}"
    make ${EXTRA_MAKE_FLAGS}
    make ${EXTRA_MAKE_FLAGS} install
		
		
		cd ${PREFIX}/platform
		rm -rf sim
		mkdir sim
		cp ${PREFIX}/lib/*.a ${PREFIX}/platform/sim
)

IOS_SIM_OUTPUT=`find ${PREFIX}/platform/sim/*.a`

else

IOS_SIM_OUTPUT=

fi



echo "############################"
echo " Create Mixd Libraries"
echo "############################"



(

		cd ${PREFIX}/platform
		rm -rf mixd
		mkdir -p mixd

    lipo ${IOS_SIM_OUTPUT} ${ARMV7_IPHONE_OUTPUT} ${ARMV7S_IPHONE_OUTPUT} -create -output ${PREFIX}/platform/mixd/lib${BUILD_TARGET}.a
		
)


) 2>&1
#) >build.log 2>&1

echo "done"


iOS 通用交叉编译脚本

标签:blog   io   ar   os   sp   for   on   2014   log   

原文地址:http://blog.csdn.net/frodo_sens/article/details/41494081

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!