aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/prepare-libetpan-ios.sh
blob: 7a5a054b568e637b8c214c6d9c5115a4e51918fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh

sdkversion=6.1
url="https://github.com/dinhviethoa/libetpan.git"
rev=78427a0506be00e1e72ac8f88aa4b71bebd4137f

pushd `dirname $0` > /dev/null
scriptpath=`pwd`
popd > /dev/null
builddir="$scriptpath/../Externals/builds"

#builddir="$HOME/MailCore-Builds/dependencies"
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"

mkdir -p "$resultdir"
mkdir -p "$logdir"
mkdir -p "$tmpdir"
mkdir -p "$srcdir"

pushd . >/dev/null
mkdir -p "$builddir/downloads"
cd "$builddir/downloads"
if test -d libetpan ; then
	cd libetpan
	git pull --rebase
else
	git clone $url
	cd libetpan
fi
#version=`git rev-parse HEAD | cut -c1-10`
version=`echo $rev | cut -c1-10`

if test -f "$resultdir/libetpan-ios-$version.zip" ; then
	echo install from cache
	popd >/dev/null
	rm -rf ../Externals/libetpan-ios
	rm -rf ../Externals/libsasl-ios
	mkdir -p ../Externals/tmp
	unzip -q "$resultdir/libetpan-ios-$version.zip" -d ../Externals/tmp
	unzip -q "$resultdir/libsasl-ios-$version.zip" -d ../Externals/tmp
	mv "../Externals/tmp/libetpan-ios-$version/libetpan-ios" ../Externals
	mv "../Externals/tmp/libsasl-ios-$version/libsasl-ios" ../Externals
  mkdir -p ../Externals/installed
  ln -sf "$resultdir/libetpan-ios-$version.zip" ../Externals/installed
  ln -sf "$resultdir/libsasl-ios-$version.zip" ../Externals/installed
	rm -rf ../Externals/tmp
	exit 0
fi
popd >/dev/null

pushd . >/dev/null

cp -R "$builddir/downloads/libetpan" "$srcdir/libetpan"
cd "$srcdir/libetpan"
git checkout $rev
echo building libetpan

cd "$srcdir/libetpan/build-mac"
sdk="iphoneos$sdkversion"
archs="armv7 armv7s"
echo building $sdk
xcodebuild -project libetpan.xcodeproj -sdk $sdk -target "libetpan ios" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$archs"
if test x$? != x0 ; then
  echo failed
  exit 1
fi
sdk="iphonesimulator$sdkversion"
archs="i386"
echo building $sdk
xcodebuild -project libetpan.xcodeproj -sdk $sdk -target "libetpan ios" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$archs"
if test x$? != x0 ; then
  echo failed
  exit 1
fi
echo finished

cd "$tmpdir/bin"
mkdir -p "libetpan-ios-$version/libetpan-ios"
mkdir -p "libetpan-ios-$version/libetpan-ios/lib"
mv Release-iphoneos/include "libetpan-ios-$version/libetpan-ios"
lipo -create Release-iphoneos/libetpan-ios.a \
  Release-iphonesimulator/libetpan-ios.a \
  -output "libetpan-ios-$version/libetpan-ios/lib/libetpan-ios.a"
zip -qry "$resultdir/libetpan-ios-$version.zip" "libetpan-ios-$version"
mkdir -p "libsasl-ios-$version"
mv "$srcdir/libetpan/build-mac/libsasl-ios" "libsasl-ios-$version"
zip -qry "$resultdir/libsasl-ios-$version.zip" "libsasl-ios-$version"
rm -f "$resultdir/libetpan-ios-latest.zip"
rm -f "$resultdir/libsasl-ios-latest.zip"
cd "$resultdir"
ln -s "libetpan-ios-$version.zip" "libetpan-ios-latest.zip"
ln -s "libsasl-ios-$version.zip" "libsasl-ios-latest.zip"

echo build of libetpan-ios-$version done

popd >/dev/null

rm -rf ../Externals/libetpan-ios
rm -rf ../Externals/libsasl-ios
mkdir -p ../Externals/tmp
unzip -q "$resultdir/libetpan-ios-$version.zip" -d ../Externals/tmp
unzip -q "$resultdir/libsasl-ios-$version.zip" -d ../Externals/tmp
mv "../Externals/tmp/libetpan-ios-$version/libetpan-ios" ../Externals
mv "../Externals/tmp/libsasl-ios-$version/libsasl-ios" ../Externals
rm -rf ../Externals/tmp

echo cleaning
rm -rf "$tempbuilddir"
echo "$tempbuilddir"