Slightly revamp dist-build/ios.sh

- Compile arm32 and arm64 targets separately
- Compile for the iOS simulator

The resulting fat library include arm32, arm64, 32-bit simulator and
64-bit OSX targets.

This is a bit better than what we previously had regarding the simulator,
but still not optimal, as the 64-bit simulator version should also be
included. However, a fat library cannot include both the 64-bit simulator
version and a version for OSX since the architecture is the same.

The proper way to address this is probably to generate two libraries.
This requires some prior changes to Swift-Sodium.
This commit is contained in:
Frank Denis 2015-04-18 11:50:27 +02:00
parent 7a9dc9bdc8
commit a26a126a51

View File

@ -10,55 +10,99 @@
# Merge libs into final version for xcode import
export PREFIX="$(pwd)/libsodium-ios"
export IOS_PREFIX="$PREFIX/tmp/ios"
export OSX32_PREFIX="$PREFIX/tmp/osx32"
export OSX64_PREFIX="$PREFIX/tmp/osx64"
export IOS32_PREFIX="$PREFIX/tmp/ios32"
export IOS64_PREFIX="$PREFIX/tmp/ios64"
export SIMULATOR32_PREFIX="$PREFIX/tmp/simulator32"
export SIMULATOR64_PREFIX="$PREFIX/tmp/simulator64"
export OSX_PREFIX="$PREFIX/tmp/osx"
export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"5.1.1"}
export IOS_VERSION_MIN=${IOS_VERSION_MIN-"5.1.1"}
export XCODEDIR=$(xcode-select -p)
mkdir -p $IOS_PREFIX $OSX32_PREFIX $OSX64_PREFIX || exit 1
mkdir -p $SIMULATOR32_PREFIX $SIMULATOR64_PREFIX $IOS32_PREFIX $IOS64_PREFIX $OSX_PREFIX || exit 1
# Build for OSX32 First
export CFLAGS="-Oz -arch i386"
./configure --disable-shared \
--enable-minimal \
--prefix="$OSX32_PREFIX" || exit 1
# Build for the simulator
export BASEDIR="${XCODEDIR}/Platforms/iPhoneSimulator.platform/Developer"
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
export SDK="${BASEDIR}/SDKs/iPhoneSimulator.sdk"
make clean > /dev/null && make -j3 check && make -j3 install || exit 1
## i386 simulator
export CFLAGS="-O2 -arch i386 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
export LDFLAGS="-arch i386 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
# Cleanup
make distclean > /dev/null
# Build for OSX64 Then
export CFLAGS="-Oz -arch x86_64"
./configure --disable-shared \
--enable-minimal \
--prefix="$OSX64_PREFIX"
--prefix="$SIMULATOR32_PREFIX" || exit 1
make clean > /dev/null && make -j3 check && make -j3 install || exit 1
make -j3 install || exit 1
# Cleanup
make distclean > /dev/null || exit 1
## x86_64 simulator
export CFLAGS="-O2 -arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
export LDFLAGS="-arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
make distclean > /dev/null
./configure --disable-shared \
--enable-minimal \
--prefix="$SIMULATOR64_PREFIX"
make -j3 install || exit 1
# Build for OSX
export CFLAGS="-O2 -arch x86_64 -mmacosx-version-min=10.8 -march=core2"
export LDFLAGS="-arch x86_64 -mmacosx-version-min=10.8"
make distclean > /dev/null
./configure --disable-shared \
--enable-minimal \
--prefix="$OSX_PREFIX"
make -j3 check && make install || exit 1
# Build for iOS
export XCODEDIR=$(xcode-select -p)
export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer"
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
export SDK="${BASEDIR}/SDKs/iPhoneOS.sdk"
export IPHONEOS_VERSION_MIN=${IPHONEOS_VERSION_MIN-"5.1.1"}
export CFLAGS="-Oz -mthumb -arch armv7 -arch armv7s -arch arm64 -isysroot ${SDK} -miphoneos-version-min=${IPHONEOS_VERSION_MIN}"
export LDFLAGS="-mthumb -arch armv7 -arch armv7s -arch arm64 -isysroot ${SDK} -miphoneos-version-min=${IPHONEOS_VERSION_MIN}"
## 32-bit iOS
export CFLAGS="-Oz -mthumb -arch armv7 -arch armv7s -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
export LDFLAGS="-mthumb -arch armv7 -arch armv7s -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
make distclean > /dev/null
./configure --host=arm-apple-darwin10 \
--disable-shared \
--enable-minimal \
--prefix="$IOS_PREFIX" || exit 1
--prefix="$IOS32_PREFIX" || exit 1
make clean > /dev/null && make -j3 install || exit 1
make -j3 install || exit 1
## 64-bit iOS
export CFLAGS="-Oz -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
export LDFLAGS="-arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
make distclean > /dev/null
./configure --host=arm-apple-darwin10 \
--disable-shared \
--enable-minimal \
--prefix="$IOS64_PREFIX" || exit 1
make -j3 install || exit 1
# Create universal binary and include folder
rm -fr -- "$PREFIX/include" "$PREFIX/libsodium.a" 2> /dev/null
mkdir -p -- "$PREFIX"
lipo -create "$IOS_PREFIX/lib/libsodium.a" "$OSX32_PREFIX/lib/libsodium.a" "$OSX64_PREFIX/lib/libsodium.a" -output "$PREFIX/libsodium.a"
mv -f -- "$IOS_PREFIX/include" "$PREFIX/"
lipo -create \
"$SIMULATOR32_PREFIX/lib/libsodium.a" \
"$OSX_PREFIX/lib/libsodium.a" \
"$IOS32_PREFIX/lib/libsodium.a" \
"$IOS64_PREFIX/lib/libsodium.a" \
-output "$PREFIX/libsodium.a"
mv -f -- "$IOS32_PREFIX/include" "$PREFIX/"
echo
echo "libsodium has been installed into $PREFIX"