2014-03-20 23:21:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-03-21 00:15:09 +00:00
|
|
|
#
|
|
|
|
# Written and maintained by the.arul@gmail.com (2014)
|
|
|
|
#
|
2014-03-20 23:21:28 +00:00
|
|
|
|
|
|
|
BUILD_DIR="./lib/iOS"
|
|
|
|
|
2018-03-19 11:17:18 +00:00
|
|
|
###################################
|
|
|
|
# SDK Version
|
|
|
|
###################################
|
|
|
|
IOS_SDK_VERSION=$(xcodebuild -version -sdk iphoneos | grep SDKVersion | cut -f2 -d ':' | tr -d '[[:space:]]')
|
|
|
|
###################################
|
2014-03-20 23:21:28 +00:00
|
|
|
|
2018-03-20 11:46:03 +00:00
|
|
|
BUILD_SHARED_LIBS=OFF
|
|
|
|
BUILD_TYPE=Release
|
2018-03-19 13:49:16 +00:00
|
|
|
|
2018-03-19 11:17:18 +00:00
|
|
|
################################################
|
|
|
|
# Minimum iOS deployment target version
|
|
|
|
################################################
|
|
|
|
MIN_IOS_VERSION="8.0"
|
2014-03-20 23:21:28 +00:00
|
|
|
|
2018-03-19 11:17:18 +00:00
|
|
|
IOS_SDK_TARGET=$MIN_IOS_VERSION
|
|
|
|
XCODE_ROOT_DIR=$(xcode-select --print-path)
|
|
|
|
TOOLCHAIN=$XCODE_ROOT_DIR/Toolchains/XcodeDefault.xctoolchain
|
|
|
|
|
2018-03-20 15:09:50 +00:00
|
|
|
BUILD_ARCHS_DEVICE="arm64 armv7"
|
|
|
|
BUILD_ARCHS_SIMULATOR="x86_64 i386"
|
|
|
|
BUILD_ARCHS_ALL=(armv7 arm64 x86_64 i386)
|
2014-03-20 23:21:28 +00:00
|
|
|
|
|
|
|
CPP_DEV_TARGET_LIST=(miphoneos-version-min mios-simulator-version-min)
|
|
|
|
CPP_DEV_TARGET=
|
|
|
|
CPP_STD_LIB_LIST=(libc++ libstdc++)
|
|
|
|
CPP_STD_LIB=
|
2017-01-25 07:38:20 +00:00
|
|
|
CPP_STD_LIST=(c++11 c++14)
|
2016-06-24 09:17:36 +00:00
|
|
|
CPP_STD=
|
2014-03-20 23:21:28 +00:00
|
|
|
|
|
|
|
function join { local IFS="$1"; shift; echo "$*"; }
|
|
|
|
|
|
|
|
build_arch()
|
|
|
|
{
|
|
|
|
IOS_SDK_DEVICE=iPhoneOS
|
|
|
|
CPP_DEV_TARGET=${CPP_DEV_TARGET_LIST[0]}
|
|
|
|
|
|
|
|
if [[ "$BUILD_ARCHS_SIMULATOR" =~ "$1" ]]
|
|
|
|
then
|
|
|
|
echo '[!] Target SDK set to SIMULATOR.'
|
|
|
|
IOS_SDK_DEVICE=iPhoneSimulator
|
|
|
|
CPP_DEV_TARGET=${CPP_DEV_TARGET_LIST[1]}
|
|
|
|
else
|
|
|
|
echo '[!] Target SDK set to DEVICE.'
|
|
|
|
fi
|
|
|
|
|
2014-03-21 00:15:09 +00:00
|
|
|
unset DEVROOT SDKROOT CFLAGS LDFLAGS CPPFLAGS CXXFLAGS
|
2014-03-20 23:21:28 +00:00
|
|
|
|
2018-03-19 11:17:18 +00:00
|
|
|
export DEVROOT=$XCODE_ROOT_DIR/Platforms/$IOS_SDK_DEVICE.platform/Developer
|
2014-03-20 23:21:28 +00:00
|
|
|
export SDKROOT=$DEVROOT/SDKs/$IOS_SDK_DEVICE$IOS_SDK_VERSION.sdk
|
|
|
|
export CFLAGS="-arch $1 -pipe -no-cpp-precomp -stdlib=$CPP_STD_LIB -isysroot $SDKROOT -$CPP_DEV_TARGET=$IOS_SDK_TARGET -I$SDKROOT/usr/include/"
|
|
|
|
export LDFLAGS="-L$SDKROOT/usr/lib/"
|
|
|
|
export CPPFLAGS=$CFLAGS
|
2016-06-24 09:17:36 +00:00
|
|
|
export CXXFLAGS="$CFLAGS -std=$CPP_STD"
|
2014-03-20 23:21:28 +00:00
|
|
|
|
|
|
|
rm CMakeCache.txt
|
|
|
|
|
2018-03-20 11:46:03 +00:00
|
|
|
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS
|
2014-03-20 23:21:28 +00:00
|
|
|
|
|
|
|
echo "[!] Building $1 library"
|
|
|
|
|
2018-03-19 11:17:18 +00:00
|
|
|
$XCODE_ROOT_DIR/usr/bin/make clean
|
|
|
|
$XCODE_ROOT_DIR/usr/bin/make assimp -j 8 -l
|
2014-03-20 23:21:28 +00:00
|
|
|
|
2018-03-19 20:51:52 +00:00
|
|
|
echo "[!] Moving built libraries into: $BUILD_DIR/$1/"
|
2014-03-20 23:21:28 +00:00
|
|
|
|
2018-03-19 20:51:52 +00:00
|
|
|
if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then
|
|
|
|
mv ./lib/libassimp*.dylib $BUILD_DIR/$1/
|
|
|
|
else
|
|
|
|
mv ./lib/libassimp.a $BUILD_DIR/$1/
|
|
|
|
fi
|
|
|
|
|
|
|
|
mv ./lib/libIrrXML.a $BUILD_DIR/$1/
|
|
|
|
mv ./lib/libzlibstatic.a $BUILD_DIR/$1/
|
2014-03-20 23:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "[!] $0 - assimp iOS build script"
|
|
|
|
|
|
|
|
CPP_STD_LIB=${CPP_STD_LIB_LIST[0]}
|
2016-06-24 09:17:36 +00:00
|
|
|
CPP_STD=${CPP_STD_LIST[0]}
|
2014-03-20 23:21:28 +00:00
|
|
|
DEPLOY_ARCHS=${BUILD_ARCHS_ALL[*]}
|
|
|
|
DEPLOY_FAT=1
|
|
|
|
|
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
2016-06-24 09:17:36 +00:00
|
|
|
-s=*|--std=*)
|
|
|
|
CPP_STD=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
|
|
|
|
echo "[!] Selecting c++ standard: $CPP_STD"
|
|
|
|
;;
|
2014-03-20 23:21:28 +00:00
|
|
|
-l=*|--stdlib=*)
|
|
|
|
CPP_STD_LIB=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
|
2014-03-21 00:25:35 +00:00
|
|
|
echo "[!] Selecting c++ std lib: $CPP_STD_LIB"
|
2014-03-20 23:21:28 +00:00
|
|
|
;;
|
|
|
|
-a=*|--archs=*)
|
|
|
|
DEPLOY_ARCHS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
|
|
|
|
echo "[!] Selecting architectures: $DEPLOY_ARCHS"
|
|
|
|
;;
|
|
|
|
-n|--no-fat)
|
|
|
|
DEPLOY_FAT=0
|
|
|
|
echo "[!] Fat binary will not be created."
|
2018-03-19 13:49:16 +00:00
|
|
|
;;
|
2014-03-20 23:21:28 +00:00
|
|
|
-h|--help)
|
2014-03-21 00:15:09 +00:00
|
|
|
echo " - don't build fat library (--no-fat)."
|
|
|
|
echo " - supported architectures (--archs): $(echo $(join , ${BUILD_ARCHS_ALL[*]}) | sed 's/,/, /g')"
|
2016-06-24 09:17:36 +00:00
|
|
|
echo " - supported C++ STD libs (--stdlib): $(echo $(join , ${CPP_STD_LIB_LIST[*]}) | sed 's/,/, /g')"
|
|
|
|
echo " - supported C++ standards (--std): $(echo $(join , ${CPP_STD_LIST[*]}) | sed 's/,/, /g')"
|
2014-03-20 23:21:28 +00:00
|
|
|
exit
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
cd ../../
|
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
|
|
|
|
for ARCH_TARGET in $DEPLOY_ARCHS; do
|
|
|
|
mkdir -p $BUILD_DIR/$ARCH_TARGET
|
|
|
|
build_arch $ARCH_TARGET
|
|
|
|
#rm ./lib/libassimp.a
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "$DEPLOY_FAT" -eq 1 ]]; then
|
2018-03-19 20:51:52 +00:00
|
|
|
echo '[+] Creating fat libassimp binary ...'
|
|
|
|
for ARCH_TARGET in $DEPLOY_ARCHS; do
|
|
|
|
if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.dylib "
|
|
|
|
else
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libassimp.a "
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ "$BUILD_SHARED_LIBS" =~ "ON" ]]; then
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.dylib"
|
|
|
|
else
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libassimp-fat.a"
|
|
|
|
fi
|
|
|
|
lipo $LIPO_ARGS
|
|
|
|
echo "[!] Done! The fat binary can be found at $BUILD_DIR"
|
|
|
|
LIPO_ARGS=""
|
|
|
|
|
|
|
|
echo '[+] Creating fat libIrrXML binary ...'
|
|
|
|
for ARCH_TARGET in $DEPLOY_ARCHS; do
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libIrrXML.a "
|
|
|
|
done
|
|
|
|
LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libIrrXML-fat.a"
|
|
|
|
lipo $LIPO_ARGS
|
|
|
|
echo "[!] Done! The fat binary can be found at $BUILD_DIR"
|
|
|
|
LIPO_ARGS=""
|
|
|
|
|
|
|
|
echo '[+] Creating fat libzlibstatic binary ...'
|
2014-03-20 23:21:28 +00:00
|
|
|
for ARCH_TARGET in $DEPLOY_ARCHS; do
|
2018-03-19 20:51:52 +00:00
|
|
|
LIPO_ARGS="$LIPO_ARGS-arch $ARCH_TARGET $BUILD_DIR/$ARCH_TARGET/libzlibstatic.a "
|
2014-03-20 23:21:28 +00:00
|
|
|
done
|
2018-03-19 20:51:52 +00:00
|
|
|
LIPO_ARGS="$LIPO_ARGS-create -output $BUILD_DIR/libzlibstatic-fat.a"
|
2014-03-20 23:21:28 +00:00
|
|
|
lipo $LIPO_ARGS
|
2014-03-21 00:15:09 +00:00
|
|
|
echo "[!] Done! The fat binary can be found at $BUILD_DIR"
|
2018-03-19 20:51:52 +00:00
|
|
|
LIPO_ARGS=""
|
2014-03-20 23:21:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|