你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 通用交叉編譯腳本

iOS 通用交叉編譯腳本

編輯:IOS開發綜合


唔. 一般在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"


  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved