From 87f88990a4c7a8ec74c59408b18dbb65918d0690 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 28 Jun 2016 13:14:57 -0700 Subject: Compile mailcore2 locally via cocoapods (#1460) --- .gitignore | 1 + mailcore2-ios.podspec.json | 26 +++ mailcore2-osx.podspec.json | 26 +++ scripts/build-mailcore2-ios-cocoapod.sh | 17 ++ scripts/build-mailcore2-ios.sh | 2 +- scripts/build-mailcore2-osx-cocoapod.sh | 17 ++ scripts/build-mailcore2-osx.sh | 2 +- scripts/include.sh/build-dep-cocoapod.sh | 300 +++++++++++++++++++++++++++++++ scripts/include.sh/build-dep.sh | 2 +- 9 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 mailcore2-ios.podspec.json create mode 100644 mailcore2-osx.podspec.json create mode 100755 scripts/build-mailcore2-ios-cocoapod.sh create mode 100755 scripts/build-mailcore2-osx-cocoapod.sh create mode 100755 scripts/include.sh/build-dep-cocoapod.sh diff --git a/.gitignore b/.gitignore index 45f23d58..6f6a32a5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ build-windows/mailcore2/test/Release build-windows/mailcore2/test/x64/Release build-windows/mailcore2/test/Debug build-windows/mailcore2/test/x64/Debug +cocoapods-build diff --git a/mailcore2-ios.podspec.json b/mailcore2-ios.podspec.json new file mode 100644 index 00000000..3fc54d34 --- /dev/null +++ b/mailcore2-ios.podspec.json @@ -0,0 +1,26 @@ +{ + "name": "mailcore2-ios", + "version": "0.6.4", + "summary": "Mailcore 2 for iOS", + "description": "MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP.", + "homepage": "http://libmailcore.com", + "license": { + "type": "BSD", + "file": "LICENSE" + }, + "authors": "MailCore Authors", + "source": { + "git": "http://github.com/MailCore/mailcore2.git", + "branch": "master" + }, + "platforms": { + "ios": 8.0 + }, + "header_dir": "MailCore", + "requires_arc": false, + "public_header_files": "cocoapods-build/include/MailCore/*.h", + "preserve_paths": "cocoapods-build/include/MailCore/*.h", + "vendored_libraries": "cocoapods-build/lib/libMailCore-ios.a", + "libraries": ["xml2", "iconv", "z", "c++", "resolv"], + "prepare_command": "./scripts/build-mailcore2-ios-cocoapod.sh" +} \ No newline at end of file diff --git a/mailcore2-osx.podspec.json b/mailcore2-osx.podspec.json new file mode 100644 index 00000000..83ad7cfb --- /dev/null +++ b/mailcore2-osx.podspec.json @@ -0,0 +1,26 @@ +{ + "name": "mailcore2-osx", + "version": "0.6.4", + "summary": "Mailcore 2 for OS X", + "description": "MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP.", + "homepage": "http://libmailcore.com", + "license": { + "type": "BSD", + "file": "LICENSE" + }, + "authors": "MailCore Authors", + "source": { + "git": "http://github.com/MailCore/mailcore2.git", + "branch": "master" + }, + "platforms": { + "osx": 10.8 + }, + "header_dir": "MailCore", + "requires_arc": false, + "public_header_files": "cocoapods-build/include/MailCore/*.h", + "preserve_paths": "cocoapods-build/include/MailCore/*.h", + "vendored_libraries": "cocoapods-build/lib/libMailCore.a", + "libraries": ["sasl2", "tidy", "xml2", "iconv", "z", "c++", "crypto", "ssl", "resolv"], + "prepare_command": "./scripts/build-mailcore2-osx-cocoapod.sh" +} \ No newline at end of file diff --git a/scripts/build-mailcore2-ios-cocoapod.sh b/scripts/build-mailcore2-ios-cocoapod.sh new file mode 100755 index 00000000..236779aa --- /dev/null +++ b/scripts/build-mailcore2-ios-cocoapod.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +pushd "`dirname "$0"`" > /dev/null +scriptpath="`pwd`" +popd > /dev/null + +. "$scriptpath/include.sh/build-dep-cocoapod.sh" + +name="mailcore2-ios" +xcode_target="static mailcore2 ios" +xcode_project="mailcore2.xcodeproj" +library="libMailCore-ios.a" +embedded_deps="ctemplate-ios libetpan-ios libsasl-ios tidy-html5-ios" +build_mailcore=1 +TOPDIR="$scriptpath/.." + +build_git_ios diff --git a/scripts/build-mailcore2-ios.sh b/scripts/build-mailcore2-ios.sh index b20d9d39..8216c649 100755 --- a/scripts/build-mailcore2-ios.sh +++ b/scripts/build-mailcore2-ios.sh @@ -15,4 +15,4 @@ library="libMailCore-ios.a" embedded_deps="ctemplate-ios libetpan-ios libsasl-ios tidy-html5-ios" build_mailcore=1 -build_git_ios +build_git_ios \ No newline at end of file diff --git a/scripts/build-mailcore2-osx-cocoapod.sh b/scripts/build-mailcore2-osx-cocoapod.sh new file mode 100755 index 00000000..8e5e4f9b --- /dev/null +++ b/scripts/build-mailcore2-osx-cocoapod.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +pushd "`dirname "$0"`" > /dev/null +scriptpath="`pwd`" +popd > /dev/null + +. "$scriptpath/include.sh/build-dep-cocoapod.sh" + +name="mailcore2-osx" +xcode_target="static mailcore2 osx" +xcode_project="mailcore2.xcodeproj" +library="libMailCore.a" +embedded_deps="ctemplate-osx libetpan-osx" +build_mailcore=1 +TOPDIR="$scriptpath/.." + +build_git_osx diff --git a/scripts/build-mailcore2-osx.sh b/scripts/build-mailcore2-osx.sh index 78d509bc..2d967135 100755 --- a/scripts/build-mailcore2-osx.sh +++ b/scripts/build-mailcore2-osx.sh @@ -15,4 +15,4 @@ library="libMailCore.a" embedded_deps="ctemplate-osx libetpan-osx" build_mailcore=1 -build_git_osx +build_git_osx \ No newline at end of file diff --git a/scripts/include.sh/build-dep-cocoapod.sh b/scripts/include.sh/build-dep-cocoapod.sh new file mode 100755 index 00000000..277290f8 --- /dev/null +++ b/scripts/include.sh/build-dep-cocoapod.sh @@ -0,0 +1,300 @@ +#!/bin/sh + +build_git_ios() +{ + if test "x$name" = x ; then + return + fi + + simarchs="i386 x86_64" + sdkminversion="7.0" + sdkversion="`xcodebuild -showsdks 2>/dev/null | grep iphoneos | sed 's/.*iphoneos\(.*\)/\1/'`" + devicearchs="armv7 armv7s arm64" + + versions_path="$scriptpath/deps-versions.plist" + version="`defaults read "$versions_path" "$name" 2>/dev/null`" + version="$(($version+1))" + if test x$build_for_external = x1 ; then + version=0 + fi + + if test x$build_for_external = x1 ; then + builddir="$scriptpath/../Externals/tmp/dependencies" + else + builddir="$HOME/MailCore-Builds/dependencies" + fi + BUILD_TIMESTAMP=`date +'%Y%m%d%H%M%S'` + tempbuilddir="$builddir/workdir/$BUILD_TIMESTAMP" + mkdir -p "$tempbuilddir" + srcdir="$tempbuilddir/src" + logdir="$tempbuilddir/log" + resultdir="$builddir/builds" + tmpdir="$tempbuilddir/tmp" + + + echo "working in $tempbuilddir" + + mkdir -p "$resultdir" + mkdir -p "$logdir" + mkdir -p "$tmpdir" + mkdir -p "$srcdir" + + pushd . >/dev/null + + + BITCODE_FLAGS="-fembed-bitcode" + if test "x$NOBITCODE" != x ; then + BITCODE_FLAGS="" + XCODE_BITCODE_FLAGS="ENABLE_BITCODE=NO" + fi + XCTOOL_OTHERFLAGS='$(inherited)' + XCTOOL_OTHERFLAGS="$XCTOOL_OTHERFLAGS $BITCODE_FLAGS" + cd "$TOPDIR/build-mac" + sdk="iphoneos$sdkversion" + echo building $sdk + xcodebuild -project "$xcode_project" -sdk $sdk -scheme "$xcode_target" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$devicearchs" IPHONEOS_DEPLOYMENT_TARGET="$sdkminversion" OTHER_CFLAGS="$XCTOOL_OTHERFLAGS" $XCODE_BITCODE_FLAGS + if test x$? != x0 ; then + echo failed + exit 1 + fi + sdk="iphonesimulator$sdkversion" + echo building $sdk + xcodebuild -project "$xcode_project" -sdk $sdk -scheme "$xcode_target" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$simarchs" IPHONEOS_DEPLOYMENT_TARGET="$sdkminversion" OTHER_CFLAGS='$(inherited)' + if test x$? != x0 ; then + echo failed + exit 1 + fi + echo finished + + if echo $library|grep '\.framework$'>/dev/null ; then + cd "$tmpdir/bin/Release" + defaults write "$tmpdir/bin/Release/$library/Resources/Info.plist" "git-rev" "$rev" + mkdir -p "$resultdir/$name" + zip -qry "$resultdir/$name/$name-$version.zip" "$library" + else + cd "$tmpdir/bin" + mkdir -p "$name-$version/$name" + mkdir -p "$name-$version/$name/lib" + if test x$build_mailcore = x1 ; then + mkdir -p "$name-$version/$name/include" + mv Release-iphoneos/include/MailCore "$name-$version/$name/include" + else + mv Release-iphoneos/include "$name-$version/$name" + fi + lipo -create "Release-iphoneos/$library" \ + "Release-iphonesimulator/$library" \ + -output "$name-$version/$name/lib/$library" + for dep in $embedded_deps ; do + if test -d "$TOPDIR/build-mac/$dep" ; then + mv "$TOPDIR/build-mac/$dep" "$name-$version" + elif test -d "$TOPDIR/Externals/$dep" ; then + mv "$TOPDIR/Externals/$dep" "$name-$version" + else + echo Dependency $dep not found + fi + if test x$build_mailcore = x1 ; then + cp -R "$name-$version/$dep/lib" "$name-$version/$name" + rm -rf "$name-$version/$dep" + fi + done + if test x$build_mailcore = x1 ; then + mv "$name-$version/$name/lib" "$name-$version" + mv "$name-$version/$name/include" "$name-$version" + rm -rf "$name-$version/$name" + libtool -static -o "$name-$version/$library" "$name-$version/lib"/*.a + rm -rf "$name-$version/lib" + mkdir -p "$name-$version/lib" + mv "$name-$version/$library" "$name-$version/lib" + fi + + if test x$build_for_external = x1 ; then + mkdir -p "$scriptpath/../Externals" + cp -R "$name-$version"/* "$scriptpath/../Externals" + rm -f "$scriptpath/../Externals/git-rev" + else + mkdir -p "$resultdir/$name" + zip -qry "$resultdir/$name/$name-$version.zip" "$name-$version" + fi + fi + + mkdir -p "$TOPDIR/cocoapods-build" + echo temp dir $tmpdir/bin/$name-$version + cp -a "$tmpdir/bin/$name-$version/" "$TOPDIR/cocoapods-build" + echo build of $name-$version done + + popd >/dev/null + + echo cleaning + rm -rf "$tempbuilddir" + + if test x$build_for_external != x1 ; then + defaults write "$versions_path" "$name" "$version" + plutil -convert xml1 "$versions_path" + fi +} + +build_git_osx() +{ + sdk="`xcodebuild -showsdks 2>/dev/null | grep macosx | sed 's/.*macosx\(.*\)/\1/'`" + archs="x86_64" + sdkminversion="10.7" + + if test "x$name" = x ; then + return + fi + + versions_path="$scriptpath/deps-versions.plist" + version="`defaults read "$versions_path" "$name" 2>/dev/null`" + version="$(($version+1))" + if test x$build_for_external = x1 ; then + version=0 + fi + + if test x$build_for_external = x1 ; then + builddir="$scriptpath/../Externals/tmp/dependencies" + else + builddir="$HOME/MailCore-Builds/dependencies" + fi + BUILD_TIMESTAMP=`date +'%Y%m%d%H%M%S'` + tempbuilddir="$builddir/workdir/$BUILD_TIMESTAMP" + mkdir -p "$tempbuilddir" + srcdir="$tempbuilddir/src" + logdir="$tempbuilddir/log" + resultdir="$builddir/builds" + tmpdir="$tempbuilddir/tmp" + + echo "working in $tempbuilddir" + + mkdir -p "$resultdir" + mkdir -p "$logdir" + mkdir -p "$tmpdir" + mkdir -p "$srcdir" + + pushd . >/dev/null + + + cd "$TOPDIR/build-mac" + xctool -project "$xcode_project" -sdk macosx$sdk -scheme "$xcode_target" -configuration Release ARCHS="$archs" SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" MACOSX_DEPLOYMENT_TARGET="$sdkminversion" + if test x$? != x0 ; then + echo failed + exit 1 + fi + echo finished + + if echo $library|grep '\.framework$'>/dev/null ; then + cd "$tmpdir/bin/Release" + defaults write "$tmpdir/bin/Release/$library/Resources/Info.plist" "git-rev" "$rev" + mkdir -p "$resultdir/$name" + zip -qry "$resultdir/$name/$name-$version.zip" "$library" + else + cd "$tmpdir/bin" + mkdir -p "$name-$version/$name" + mkdir -p "$name-$version/$name/lib" + if test x$build_mailcore = x1 ; then + mkdir -p "$name-$version/$name/include" + mv Release/include/MailCore "$name-$version/$name/include" + else + mv Release/include "$name-$version/$name" + fi + mv "Release/$library" "$name-$version/$name/lib" + for dep in $embedded_deps ; do + if test -d "$TOPDIR/build-mac/$dep" ; then + mv "$TOPDIR/build-mac/$dep" "$name-$version" + elif test -d "$TOPDIR/Externals/$dep" ; then + mv "$TOPDIR/Externals/$dep" "$name-$version" + else + echo Dependency $dep not found + fi + if test x$build_mailcore = x1 ; then + cp -R "$name-$version/$dep/lib" "$name-$version/$name" + rm -rf "$name-$version/$dep" + fi + done + if test x$build_mailcore = x1 ; then + mv "$name-$version/$name/lib" "$name-$version" + mv "$name-$version/$name/include" "$name-$version" + rm -rf "$name-$version/$name" + libtool -static -o "$name-$version/$library" "$name-$version/lib"/*.a + rm -rf "$name-$version/lib" + mkdir -p "$name-$version/lib" + mv "$name-$version/$library" "$name-$version/lib" + fi + + if test x$build_for_external = x1 ; then + mkdir -p "$scriptpath/../Externals" + cp -R "$name-$version"/* "$scriptpath/../Externals" + rm -f "$scriptpath/../Externals/git-rev" + else + mkdir -p "$resultdir/$name" + zip -qry "$resultdir/$name/$name-$version.zip" "$name-$version" + fi + fi + + mkdir -p "$TOPDIR/cocoapods-build" + echo temp dir $tmpdir/bin/$name-$version + cp -a "$tmpdir/bin/$name-$version/" "$TOPDIR/cocoapods-build" + echo build of $name-$version done + + popd >/dev/null + + echo cleaning + rm -rf "$tempbuilddir" + + if test x$build_for_external != x1 ; then + defaults write "$versions_path" "$name" "$version" + plutil -convert xml1 "$versions_path" + fi +} + +get_prebuilt_dep() +{ + url="http://d.etpan.org/mailcore2-deps" + + if test "x$name" = x ; then + return + fi + + versions_path="$scriptpath/deps-versions.plist" + installed_versions_path="$scriptpath/installed-deps-versions.plist" + if test ! -f "$versions_path" ; then + build_for_external=1 "$scriptpath/build-$name.sh" + return; + fi + + installed_version="`defaults read "$installed_versions_path" "$name" 2>/dev/null`" + if test ! -d "$scriptpath/../Externals/$name" ; then + installed_version= + fi + if test "x$installed_version" = x ; then + installed_version="none" + fi + version="`defaults read "$versions_path" "$name" 2>/dev/null`" + + echo $name, installed: $installed_version, required: $version + if test "x$installed_version" = "x$version" ; then + return + fi + + BUILD_TIMESTAMP=`date +'%Y%m%d%H%M%S'` + tempbuilddir="$scriptpath/../Externals/workdir/$BUILD_TIMESTAMP" + + mkdir -p "$tempbuilddir" + cd "$tempbuilddir" + echo "Downloading $name-$version" + curl -O "$url/$name/$name-$version.zip" + unzip -q "$name-$version.zip" + rm -rf "$scriptpath/../Externals/$name" + cd "$name-$version" + for folder in * ; do + rm -rf "$scriptpath/../Externals/$folder" + mv "$folder" "$scriptpath/../Externals" + done + cd .. + rm -f "$scriptpath/../Externals/git-rev" + rm -rf "$tempbuilddir" + + if test -d "$scriptpath/../Externals/$name" ; then + defaults write "$installed_versions_path" "$name" "$version" + plutil -convert xml1 "$installed_versions_path" + fi +} diff --git a/scripts/include.sh/build-dep.sh b/scripts/include.sh/build-dep.sh index ca50fbde..e7724e66 100755 --- a/scripts/include.sh/build-dep.sh +++ b/scripts/include.sh/build-dep.sh @@ -338,4 +338,4 @@ get_prebuilt_dep() defaults write "$installed_versions_path" "$name" "$version" plutil -convert xml1 "$installed_versions_path" fi -} +} \ No newline at end of file -- cgit v1.2.3