Skip to content

Commit

Permalink
Merge pull request mevansam#18 from paleozogt/ios-like-android
Browse files Browse the repository at this point in the history
make ios build more like android build
  • Loading branch information
mevansam committed Feb 3, 2013
2 parents 6d7946d + caccd83 commit 55d3e4d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 111 deletions.
1 change: 1 addition & 0 deletions build-droid/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export LIBGSASL_VERSION="1.8.0"

# Project version to use to build boost C++ libraries
export BOOST_VERSION="1.52.0"
export BOOST_LIBS="date_time filesystem program_options regex signals system thread iostreams"

# Project version to use to build tinyxml
export TINYXML_VERSION="2.6.2"
Expand Down
8 changes: 3 additions & 5 deletions build-droid/build-boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ tar xvf "${TOPDIR}/build-droid/droid-boost-patch.tar.gz"
# ---------

# Make the initial bootstrap
echo "Performing boost boostrap"

./bootstrap.sh
BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g")
echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)"
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
if [ $? != 0 ] ; then
echo "ERROR: Could not perform boostrap! See $TMPLOG for more info."
exit 1
Expand Down Expand Up @@ -183,8 +183,6 @@ using android : arm : ${DROIDTOOLS}-g++ :
EOF

cat >> project-config.jam <<EOF
libraries = --with-date_time --with-filesystem --with-program_options --with-regex --with-signals --with-system --with-thread --with-iostreams ;
option.set prefix : ${ROOTDIR}/ ;
option.set exec-prefix : ${ROOTDIR}/bin ;
option.set libdir : ${ROOTDIR}/lib ;
Expand Down
11 changes: 4 additions & 7 deletions build-ios/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export LIBGSASL_VERSION="1.8.0"

# Project version to use to build boost C++ libraries
export BOOST_VERSION="1.52.0"
export BOOST_LIBS="date_time filesystem program_options regex signals system thread iostreams"

# Project version to use to build tinyxml
export TINYXML_VERSION="2.6.2"
Expand Down Expand Up @@ -102,9 +103,6 @@ do
mkdir -p "${ROOTDIR}"
done

# Build BOOST
${TOPDIR}/build-ios/build-boost.sh > "${LOGDIR}/boost.log"

for PLATFORM in ${PLATFORMS}
do
LOGPATH="${LOGDIR}/${PLATFORM}"
Expand Down Expand Up @@ -186,6 +184,9 @@ do
# Build libgsasl
${TOPDIR}/build-ios/build-libgsasl.sh > "${LOGPATH}-libgsasl.log"

# Build BOOST
${TOPDIR}/build-ios/build-boost.sh > "${LOGPATH}-boost.log"

# Build tinyxml
${TOPDIR}/build-ios/build-tinyxml.sh > "${LOGPATH}-tinyxml.log"

Expand Down Expand Up @@ -218,10 +219,6 @@ do

done

# Remove individual boost libraries as all were combined into one
# libboost.a (comment this line if individual libraries are required)
find ${TMPDIR}/build/ios -name "libboost_*.*" -exec rm -f {} \;

# Create Lipo Archives and Framework bundle

DEVROOT=${DEVELOPER}/Platforms/iPhoneOS.platform/Developer
Expand Down
143 changes: 46 additions & 97 deletions build-ios/build-boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ fi
#===============================================================================

: ${IPHONE_SDKVERSION:=${SDK}}
: ${BOOST_LIBS:="date_time filesystem program_options regex signals system thread iostreams"}
: ${EXTRA_CPPFLAGS:="-Os -DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS"}

# The EXTRA_CPPFLAGS definition works around a thread race issue in
Expand All @@ -70,32 +69,31 @@ fi
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS

: ${TARBALLDIR:=`pwd`}
: ${SRCDIR:=`pwd`/boost/src}
: ${BUILDDIR:=`pwd`/boost/build}
: ${PREFIXDIR:=`pwd`/boost/prefix}

BOOST_TARBALL=$TARBALLDIR/${BOOST_SOURCE_NAME}.tar.gz
BOOST_SRC=$SRCDIR/${BOOST_SOURCE_NAME}

#===============================================================================

ARM_DEV_DIR=${DEVELOPER}/Platforms/iPhoneOS.platform/Developer/usr/bin/
SIM_DEV_DIR=${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/usr/bin/

ARM_COMBINED_LIB=$BUILDDIR/lib_boost_arm.a
SIM_COMBINED_LIB=$BUILDDIR/lib_boost_x86.a
DEV_DIR=${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/usr/bin/

#===============================================================================

echo "BOOST_VERSION: $BOOST_VERSION"
echo "BOOST_LIBS: $BOOST_LIBS"
echo "BOOST_TARBALL: $BOOST_TARBALL"
echo "BOOST_SRC: $BOOST_SRC"
echo "BUILDDIR: $BUILDDIR"
echo "PREFIXDIR: $PREFIXDIR"
echo "IPHONE_SDKVERSION: $IPHONE_SDKVERSION"
echo

# boost needs its own versions of some values
if [ "${PLATFORM}" == "iPhoneSimulator" ]
then
BOOST_PLAT="iphonesim"
BOOST_ARCH="x86"
else
BOOST_PLAT="iphone"
BOOST_ARCH="arm"
fi

#===============================================================================
# Functions
#===============================================================================
Expand All @@ -120,19 +118,21 @@ doneSection()
cleanEverythingReadyToStart()
{
echo Cleaning everything before we start to build...
rm -rf $BOOST_SRC
rm -rf $BUILDDIR
rm -rf $PREFIXDIR
rm -rf $BOOST_SOURCE_NAME
doneSection
}

#===============================================================================
unpackBoost()
{
echo Unpacking boost into $SRCDIR...
[ -d $SRCDIR ] || mkdir -p $SRCDIR
[ -d $BOOST_SRC ] || ( cd $SRCDIR; tar zxvf $BOOST_TARBALL )
[ -d $BOOST_SRC ] && echo " ...unpacked as $BOOST_SRC"
echo Unpacking boost into $BOOST_SOURCE_NAME...

rm -rfv "$BOOST_SOURCE_NAME"

tar zxvf $BOOST_TARBALL
[ -d $BOOST_SOURCE_NAME ] && echo " ...unpacked as $BOOST_SOURCE_NAME"
cd $BOOST_SOURCE_NAME

doneSection
}

Expand All @@ -143,18 +143,12 @@ writeBjamUserConfig()
# You need to do this to point bjam at the right compiler
# ONLY SEEMS TO WORK IN HOME DIR GRR
echo Writing usr-config
#mkdir -p $BUILDDIR
#cat > ~/user-config.jam <<EOF
cat >> $BOOST_SRC/tools/build/v2/user-config.jam <<EOF
using darwin : ${SDK}~iphone
: ${DEVELOPER}/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7 -mthumb -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
: <striper>
: <architecture>arm <target-os>iphone
;
using darwin : ${SDK}~iphonesim
: ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
: <striper>
: <architecture>x86 <target-os>iphone

cat >> tools/build/v2/user-config.jam <<EOF
using darwin : ${SDK}~${BOOST_PLAT}
: ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/usr/bin/gcc -arch $ARCH -mthumb -fvisibility=hidden -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
:
: <architecture>$BOOST_ARCH <target-os>iphone
;
EOF
doneSection
Expand All @@ -168,14 +162,13 @@ inventMissingHeaders()
# They are supported on the device, so we copy them from x86 SDK to a staging area
# to use them on ARM, too.
echo Invent missing headers
cp ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDKVERSION}.sdk/usr/include/{crt_externs,bzlib}.h $BOOST_SRC
cp ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDKVERSION}.sdk/usr/include/{crt_externs,bzlib}.h .
}

#===============================================================================

bootstrapBoost()
{
cd $BOOST_SRC
BOOST_LIBS_COMMA=$(echo $BOOST_LIBS | sed -e "s/ /,/g")
echo "Bootstrapping (with libs $BOOST_LIBS_COMMA)"
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
Expand All @@ -186,69 +179,31 @@ bootstrapBoost()

buildBoostForiPhoneOS()
{
cd $BOOST_SRC

./bjam --prefix="$PREFIXDIR" toolset=darwin architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install
doneSection

./bjam toolset=darwin architecture=x86 target-os=iphone macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage
./bjam --prefix="$ROOTDIR" toolset=darwin architecture=$BOOST_ARCH target-os=iphone macosx-version=${BOOST_PLAT}-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install
doneSection
}

#===============================================================================

scrunchAllLibsTogetherInOneLibPerPlatform()
scrunchAllLibsTogetherInOneLib()
{
ALL_LIBS_ARM=""
ALL_LIBS_SIM=""
for NAME in $BOOST_LIBS; do
ALL_LIBS_ARM="$ALL_LIBS_ARM $BOOST_SRC/bin.v2/libs/$NAME/build/darwin-${SDK}~iphone/release/architecture-arm/link-static/macosx-version-iphone-$IPHONE_SDKVERSION/target-os-iphone/threading-multi/libboost_$NAME.a";
ALL_LIBS_SIM="$ALL_LIBS_SIM $BOOST_SRC/bin.v2/libs/$NAME/build/darwin-${SDK}~iphonesim/release/architecture-x86/link-static/macosx-version-iphonesim-$IPHONE_SDKVERSION/target-os-iphone/threading-multi/libboost_$NAME.a";
OBJDIR=$BOOST_SOURCE_NAME/tmp/obj
mkdir -p $OBJDIR
for a in $ROOTDIR/lib/libboost_*.a; do

# telling bjam to make armv7 always makes fat arm6/7 binaries (ug); we need to thin it to just the arch we want
if [ "${ARCH}" == "armv7" ]
then
echo thining $a...
lipo -thin $ARCH $a -output $a
fi

echo Decomposing $a...
(cd $OBJDIR; ${DEV_DIR}/ar -x $a );
done;

mkdir -p $BUILDDIR/armv6/obj
mkdir -p $BUILDDIR/armv7/obj
mkdir -p $BUILDDIR/i386/obj

mkdir -p ${TMPDIR}/build/ios/iPhoneOS-V6/lib
mkdir -p ${TMPDIR}/build/ios/iPhoneOS-V7/lib
mkdir -p ${TMPDIR}/build/ios/iPhoneSimulator/lib

ALL_LIBS=""

echo Splitting all existing fat binaries...
for NAME in $BOOST_LIBS; do
ALL_LIBS="$ALL_LIBS libboost_$NAME.a"
lipo "$BOOST_SRC/bin.v2/libs/$NAME/build/darwin-${SDK}~iphone/release/architecture-arm/link-static/macosx-version-iphone-$IPHONE_SDKVERSION/target-os-iphone/threading-multi/libboost_$NAME.a" -thin armv6 -o $BUILDDIR/armv6/libboost_$NAME.a
lipo "$BOOST_SRC/bin.v2/libs/$NAME/build/darwin-${SDK}~iphone/release/architecture-arm/link-static/macosx-version-iphone-$IPHONE_SDKVERSION/target-os-iphone/threading-multi/libboost_$NAME.a" -thin armv7 -o $BUILDDIR/armv7/libboost_$NAME.a
cp "$BOOST_SRC/bin.v2/libs/$NAME/build/darwin-${SDK}~iphonesim/release/architecture-x86/link-static/macosx-version-iphonesim-$IPHONE_SDKVERSION/target-os-iphone/threading-multi/libboost_$NAME.a" $BUILDDIR/i386/libboost_$NAME.a

cp $BUILDDIR/armv6/libboost_$NAME.a ${TMPDIR}/build/ios/iPhoneOS-V6/lib
cp $BUILDDIR/armv7/libboost_$NAME.a ${TMPDIR}/build/ios/iPhoneOS-V7/lib
cp $BUILDDIR/i386/libboost_$NAME.a ${TMPDIR}/build/ios/iPhoneSimulator/lib
done

echo "Decomposing each architecture's .a files"
for NAME in $ALL_LIBS; do
echo Decomposing $NAME...
(cd $BUILDDIR/armv6/obj; ar -x ../$NAME );
(cd $BUILDDIR/armv7/obj; ar -x ../$NAME );
(cd $BUILDDIR/i386/obj; ar -x ../$NAME );
done

echo "Linking each architecture into an uberlib ($ALL_LIBS => libboost.a )"
rm -f ${TMPDIR}/build/ios/*/lib/libboost.a
echo ...armv6
(cd $BUILDDIR/armv6; $ARM_DEV_DIR/ar crus ${TMPDIR}/build/ios/iPhoneOS-V6/lib/libboost.a obj/*.o; )
echo ...armv7
(cd $BUILDDIR/armv7; $ARM_DEV_DIR/ar crus ${TMPDIR}/build/ios/iPhoneOS-V7/lib/libboost.a obj/*.o; )
echo ...i386
(cd $BUILDDIR/i386; $SIM_DEV_DIR/ar crus ${TMPDIR}/build/ios/iPhoneSimulator/lib/libboost.a obj/*.o; )

echo "Copying header files"
cp -r ${PREFIXDIR}/include ${TMPDIR}/build/ios/iPhoneOS-V6
cp -r ${PREFIXDIR}/include ${TMPDIR}/build/ios/iPhoneOS-V7
cp -r ${PREFIXDIR}/include ${TMPDIR}/build/ios/iPhoneSimulator
echo creating $ROOTDIR/lib/libboost.a
(cd $OBJDIR; ${DEV_DIR}/ar crus $ROOTDIR/lib/libboost.a *.o; )
}

#===============================================================================
Expand All @@ -257,19 +212,13 @@ scrunchAllLibsTogetherInOneLibPerPlatform()

[ -f "$BOOST_TARBALL" ] || abort "Source tarball missing."

mkdir -p $BUILDDIR

cleanEverythingReadyToStart
unpackBoost
inventMissingHeaders
writeBjamUserConfig
bootstrapBoost
writeBjamUserConfig
buildBoostForiPhoneOS
scrunchAllLibsTogetherInOneLibPerPlatform
scrunchAllLibsTogetherInOneLib

echo "Completed successfully"

#===============================================================================

# Clean up
rm -rf "$TARBALLDIR/boost"
4 changes: 2 additions & 2 deletions build-ios/build-icu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"

pushd "icu/source"
./configure --host=${ARCH}-apple-darwin --prefix=${ROOTDIR} --with-cross-build="${HOSTBUILD}" --enable-static --disable-shared
./configure --host=${ARCH}-apple-darwin --prefix=${ROOTDIR} --with-cross-build="${HOSTBUILD}" --enable-static --disable-shared --enable-extras=no --enable-strict=no --enable-tests=no --enable-samples=no --enable-dyload=no --enable-tools=no --with-data-packaging=archive

make
make VERBOSE=1
make install
popd

Expand Down

0 comments on commit 55d3e4d

Please sign in to comment.