Skip to content

Commit

Permalink
Merge pull request #459 from meganz/release/v2.8.0
Browse files Browse the repository at this point in the history
Merge the last stable developments into master
  • Loading branch information
javiserrano authored Nov 9, 2016
2 parents 49c9a06 + 0877a11 commit 2c9286c
Show file tree
Hide file tree
Showing 73 changed files with 2,257 additions and 1,195 deletions.
2 changes: 2 additions & 0 deletions bindings/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/MEGASDK.xcodeproj/xcuserdata/MEGA.xcuserdatad/xcschemes/MEGASDK.xcscheme
/MEGASDK.xcodeproj/xcuserdata/MEGA.xcuserdatad/xcschemes/xcschememanagement.plist
3 changes: 3 additions & 0 deletions bindings/ios/3rdparty/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
/cryptopp*.zip
/curl*
/openssl*
/libsodium*
/include
/lib
/karere-native
/webrtc

12 changes: 12 additions & 0 deletions bindings/ios/3rdparty/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

set -e

# MEGA SDK deps
sh build-cryptopp.sh
sh build-openssl.sh
sh build-cares.sh
sh build-curl.sh
sh build-libuv.sh
sh build-libsodium.sh

# MEGAchat deps
if [ "$1" == "--enable-chat"]; then
sh build-expat.sh
sh build-libevent2.sh
sh build-libws.sh
sh build-webrtc.sh

sh build-megachat.sh
fi

echo "Done."

10 changes: 5 additions & 5 deletions bindings/ios/3rdparty/build-cares.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set -e

if [ ! -e "c-ares-${CARES_VERSION}.tar.gz" ]
then
curl -O "http://c-ares.haxx.se/download/c-ares-${CARES_VERSION}.tar.gz"
wget "http://c-ares.haxx.se/download/c-ares-${CARES_VERSION}.tar.gz"
fi

tar zxf c-ares-${CARES_VERSION}.tar.gz
Expand Down Expand Up @@ -70,7 +70,7 @@ else
./configure --host=${ARCH}-apple-darwin --enable-static --disable-shared
fi

make
make -j8
cp -f .libs/libcares.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
make clean

Expand All @@ -79,9 +79,9 @@ done
popd
mkdir lib || true
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libcares.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libcares.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libcares.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libcares.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libcares.a -output ${CURRENTPATH}/lib/libcares.a
mkdir -p include/cares || true
cp -f c-ares-${CARES_VERSION}/ares.h c-ares-${CARES_VERSION}/ares_build.h c-ares-${CARES_VERSION}/ares_dns.h c-ares-${CARES_VERSION}/ares_rules.h c-ares-${CARES_VERSION}/ares_version.h include/cares/
sed -i '' $'s/\#define CARES_SIZEOF_LONG 8/\#ifdef __LP64__\\\n\#define CARES_SIZEOF_LONG 8\\\n#else\\\n\#define CARES_SIZEOF_LONG 4\\\n\#endif/' include/cares/ares_build.h
mkdir -p include || true
cp -f c-ares-${CARES_VERSION}/ares.h c-ares-${CARES_VERSION}/ares_build.h c-ares-${CARES_VERSION}/ares_dns.h c-ares-${CARES_VERSION}/ares_rules.h c-ares-${CARES_VERSION}/ares_version.h include/
sed -i '' $'s/\#define CARES_SIZEOF_LONG 8/\#ifdef __LP64__\\\n\#define CARES_SIZEOF_LONG 8\\\n#else\\\n\#define CARES_SIZEOF_LONG 4\\\n\#endif/' include/ares_build.h


rm -rf c-ares-${CARES_VERSION}
Expand Down
4 changes: 2 additions & 2 deletions bindings/ios/3rdparty/build-cryptopp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi
unzip cryptopp${CRYPTOPP_VERSION}.zip -d cryptopp

# Step 1. Build versions for devices and simulator
xcodebuild -target cryptopp ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -target cryptopp ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -jobs 8 -target cryptopp ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
xcodebuild -jobs 8 -target cryptopp ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"

# Make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
Expand Down
4 changes: 2 additions & 2 deletions bindings/ios/3rdparty/build-curl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set -e

if [ ! -e "curl-${CURL_VERSION}.tar.gz" ]
then
curl -O "https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz"
wget "https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz"
fi

for ARCH in ${ARCHS}
Expand Down Expand Up @@ -71,7 +71,7 @@ else
./configure --host=${ARCH}-apple-darwin --enable-static --disable-shared --with-ssl=${OPENSSL_PREFIX} --with-zlib --disable-manual --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-sspi --enable-ipv6 --disable-smb
fi

make
make -j8
cp -f lib/.libs/libcurl.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
#make clean

Expand Down
94 changes: 94 additions & 0 deletions bindings/ios/3rdparty/build-expat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/sh

EXPAT_VERSION="2.1.1"
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version`

##############################################
CURRENTPATH=`pwd`
OPENSSL_PREFIX="${CURRENTPATH}"
ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=`xcode-select -print-path`

if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

case $DEVELOPER in
*\ * )
echo "Your Xcode path contains whitespaces, which is not supported."
exit 1
;;
esac

case $CURRENTPATH in
*\ * )
echo "Your path contains whitespaces, which is not supported by 'make install'."
exit 1
;;
esac

set -e

if [ ! -e "expat-${EXPAT_VERSION}.tar.bz2" ]
then
wget "http://downloads.sourceforge.net/project/expat/expat/2.1.1/expat-${EXPAT_VERSION}.tar.bz2"
fi

for ARCH in ${ARCHS}
do
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi

rm -rf expat-${EXPAT_VERSION}
tar zxf expat-${EXPAT_VERSION}.tar.bz2
pushd "expat-${EXPAT_VERSION}"

export BUILD_TOOLS="${DEVELOPER}"
export BUILD_DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export BUILD_SDKROOT="${BUILD_DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk"

export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"

# Build
export LDFLAGS="-Os -arch ${ARCH} -Wl,-dead_strip -miphoneos-version-min=7.0 -L${BUILD_SDKROOT}/usr/lib"
export CFLAGS="-Os -arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${BUILD_SDKROOT} -miphoneos-version-min=7.0 -Wno-implicit-function-declaration"
export CPPFLAGS="${CFLAGS} -I${BUILD_SDKROOT}/usr/include"
export CXXFLAGS="${CPPFLAGS}"

if [ "${ARCH}" == "arm64" ]; then
./configure --host=aarch64-apple-darwin --enable-static --disable-shared
else
./configure --host=${ARCH}-apple-darwin --enable-static --disable-shared
fi

make -j8
cp -f .libs/libexpat.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
#make clean

popd

done


mkdir lib || true
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libexpat.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libexpat.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libexpat.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libexpat.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libexpat.a -output ${CURRENTPATH}/lib/libexpat.a

mkdir -p include/expat || true
cp -f expat-${EXPAT_VERSION}/lib/*.h include/expat/

rm -rf bin
rm -rf expat-${EXPAT_VERSION}
rm -rf expat-${EXPAT_VERSION}.tar.bz2


echo "Done."
107 changes: 107 additions & 0 deletions bindings/ios/3rdparty/build-libevent2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/bin/sh

MEGACHAT_VERSION="GIT"
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version`

##############################################
CURRENTPATH=`pwd`
OPENSSL_PREFIX="${CURRENTPATH}"
ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=`xcode-select -print-path`

if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

case $DEVELOPER in
*\ * )
echo "Your Xcode path contains whitespaces, which is not supported."
exit 1
;;
esac

case $CURRENTPATH in
*\ * )
echo "Your path contains whitespaces, which is not supported by 'make install'."
exit 1
;;
esac

set -e

if [ ! -d "karere-native" ]
then
git clone --recursive -b develop https://code.developers.mega.co.nz/messenger/karere-native
fi

for ARCH in ${ARCHS}
do
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi

pushd karere-native/third-party/libevent
git reset --hard && git clean -dfx

export BUILD_TOOLS="${DEVELOPER}"
export BUILD_DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export BUILD_SDKROOT="${BUILD_DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk"

export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"

# Build
export LDFLAGS="-Os -arch ${ARCH} -Wl,-dead_strip -miphoneos-version-min=7.0 -L${BUILD_SDKROOT}/usr/lib -L${OPENSSL_PREFIX}/lib"
export CFLAGS="-Os -arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${BUILD_SDKROOT} -miphoneos-version-min=7.0 -I${OPENSSL_PREFIX}/include"
export CPPFLAGS="${CFLAGS} -I${BUILD_SDKROOT}/usr/include"
export CXXFLAGS="${CPPFLAGS}"

./autogen.sh

if [ "${ARCH}" == "arm64" ]; then
./configure --host=aarch64-apple-darwin --enable-static --disable-shared --disable-libevent-regress --disable-tests --disable-samples
else
./configure --host=${ARCH}-apple-darwin --enable-static --disable-shared --disable-libevent-regress --disable-tests --disable-samples
fi

make -j8
cp -f .libs/libevent.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
cp -f .libs/libevent_core.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
cp -f .libs/libevent_extra.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
cp -f .libs/libevent_pthreads.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/
cp -f .libs/libevent_openssl.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/

#make clean

popd

done


mkdir lib || true
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libevent.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libevent.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libevent.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libevent.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libevent.a -output ${CURRENTPATH}/lib/libevent.a

lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libevent_core.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libevent_core.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libevent_core.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libevent_core.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libevent_core.a -output ${CURRENTPATH}/lib/libevent_core.a

lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libevent_extra.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libevent_extra.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libevent_extra.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libevent_extra.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libevent_extra.a -output ${CURRENTPATH}/lib/libevent_extra.a

lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libevent_pthreads.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libevent_pthreads.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libevent_pthreads.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libevent_pthreads.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libevent_pthreads.a -output ${CURRENTPATH}/lib/libevent_pthreads.a

lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libevent_openssl.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libevent_openssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libevent_openssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libevent_openssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libevent_openssl.a -output ${CURRENTPATH}/lib/libevent_openssl.a

mkdir -p include/libevent || true
cp -f -R karere-native/third-party/libevent/include/* include/libevent/

#rm -rf bin
#rm -rf expat-${EXPAT_VERSION}
#rm -rf expat-${EXPAT_VERSION}.tar.bz2

echo "Done."
77 changes: 70 additions & 7 deletions bindings/ios/3rdparty/build-libsodium.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,91 @@
#!/bin/sh

LIBSODIUM_VERSION="1.0.11"
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version`

##############################################
CURRENTPATH=`pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=`xcode-select -print-path`

if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

case $DEVELOPER in
*\ * )
echo "Your Xcode path contains whitespaces, which is not supported."
exit 1
;;
esac

case $CURRENTPATH in
*\ * )
echo "Your path contains whitespaces, which is not supported by 'make install'."
exit 1
;;
esac

set -e

if [ ! -e "libsodium-${LIBSODIUM_VERSION}.tar.gz" ]
then
curl -LO "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VERSION}/libsodium-${LIBSODIUM_VERSION}.tar.gz"
wget "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VERSION}/libsodium-${LIBSODIUM_VERSION}.tar.gz"
fi

for ARCH in ${ARCHS}
do
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi

rm -rf libsodium-${LIBSODIUM_VERSION}
tar zxf libsodium-${LIBSODIUM_VERSION}.tar.gz
pushd "libsodium-${LIBSODIUM_VERSION}"

sh dist-build/ios.sh
export BUILD_TOOLS="${DEVELOPER}"
export BUILD_DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export BUILD_SDKROOT="${BUILD_DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk"

cp -f libsodium-ios/lib/libsodium.a ../lib
cp -fR libsodium-ios/include/sodium* ../include
#make clean
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"

# Build
export LDFLAGS="-Os -arch ${ARCH} -Wl,-dead_strip -miphoneos-version-min=7.0 -L${BUILD_SDKROOT}/usr/lib"
export CFLAGS="-Os -arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${BUILD_SDKROOT} -miphoneos-version-min=7.0"
export CPPFLAGS="${CFLAGS} -I${BUILD_SDKROOT}/usr/include"
export CXXFLAGS="${CPPFLAGS}"

if [ "${ARCH}" == "arm64" ]; then
./configure --host=aarch64-apple-darwin --disable-shared --enable-minimal
else
./configure --host=${ARCH}-apple-darwin --disable-shared --enable-minimal
fi

make -j8

cp -f src/libsodium/.libs/libsodium.a ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/

popd

rm -rf libsodium-${LIBSODIUM_VERSION}
rm -rf libsodium-${LIBSODIUM_VERSION}.tar.gz
done


mkdir lib || true
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/libsodium.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/libsodium.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/libsodium.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/libsodium.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/libsodium.a -output ${CURRENTPATH}/lib/libsodium.a

cp -fR libsodium-${LIBSODIUM_VERSION}/src/libsodium/include/sodium* include

rm -rf bin
rm -rf libsodium-${LIBSODIUM_VERSION}

echo "Done."

Loading

0 comments on commit 2c9286c

Please sign in to comment.