aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/include.sh/build-dep.sh
blob: 1af2a5c4f6e152ac9a57e323cf6564af4143b4bb (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/sh

build_git_ios()
{
  if test "x$name" = x ; then
    return
  fi

  simarchs="i386 x86_64"
  if xcodebuild -showsdks 2>/dev/null|grep iphoneos8.1 >/dev/null ; then
    sdkversion=8.1
    devicearchs="armv7 armv7s arm64"
  elif xcodebuild -showsdks 2>/dev/null|grep iphoneos8.0 >/dev/null ; then
    sdkversion=8.0
    devicearchs="armv7 armv7s arm64"
  elif xcodebuild -showsdks 2>/dev/null|grep iphoneos7.1 >/dev/null ; then
    sdkversion=7.1
    devicearchs="armv7 armv7s arm64"
  elif xcodebuild -showsdks 2>/dev/null|grep iphoneos7.0 >/dev/null ; then
    sdkversion=7.0
    devicearchs="armv7 armv7s arm64"
  elif xcodebuild -showsdks 2>/dev/null|grep iphoneos6.1 >/dev/null ; then
    sdkversion=6.1
    devicearchs="armv7 armv7s"
  else
    echo SDK not found
    exit 1
  fi

  versions_path="$scriptpath/deps-versions.plist"
  version="`defaults read "$versions_path" "$name" 2>/dev/null`"
  version="$(($version+1))"

  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"

  echo "working in $tempbuilddir"

  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 "$name" ; then
    cd "$name"
    git pull --rebase
  else
    git clone $url "$name"
    cd "$name"
  fi
  #version=`echo $rev | cut -c1-10`

  popd >/dev/null

  pushd . >/dev/null

  cp -R "$builddir/downloads/$name" "$srcdir/$name"
  cd "$srcdir/$name"
  git checkout -q $rev
  echo building $name $version - $rev

  cd "$srcdir/$name/build-mac"
  sdk="iphoneos$sdkversion"
  echo building $sdk
  xctool -project "$xcode_project" -sdk $sdk -scheme "$xcode_target" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$devicearchs" IPHONEOS_DEPLOYMENT_TARGET="$sdkversion"
  if test x$? != x0 ; then
    echo failed
    exit 1
  fi
  sdk="iphonesimulator$sdkversion"
  echo building $sdk
  xctool -project "$xcode_project" -sdk $sdk -scheme "$xcode_target" -configuration Release SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj" ARCHS="$simarchs" IPHONEOS_DEPLOYMENT_TARGET="$sdkversion"
  if test x$? != x0 ; then
    echo failed
    exit 1
  fi
  echo finished

  cd "$tmpdir/bin"
  mkdir -p "$name-$version/$name"
  mkdir -p "$name-$version/$name/lib"
  mv Release-iphoneos/include "$name-$version/$name"
  lipo -create "Release-iphoneos/$library" \
    "Release-iphonesimulator/$library" \
      -output "$name-$version/$name/lib/$library"
  for dep in $embedded_deps ; do
    mv "$srcdir/$name/build-mac/$dep" "$name-$version"
  done
  echo "$rev"> "$name-$version/git-rev"
  mkdir -p "$resultdir/$name"
  zip -qry "$resultdir/$name/$name-$version.zip" "$name-$version"

  echo build of $name-$version done

  popd >/dev/null

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

  defaults write "$versions_path" "$name" "$version"
}

build_git_osx()
{
  sdk="macosx10.9"
  archs="x86_64"
  
  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))"

  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"

  echo "working in $tempbuilddir"

  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 "$name" ; then
  	cd "$name"
  	git pull --rebase
  else
  	git clone $url "$name"
  	cd "$name"
  fi
  #version=`echo $rev | cut -c1-10`

  popd >/dev/null

  pushd . >/dev/null

  cp -R "$builddir/downloads/$name" "$srcdir/$name"
  cd "$srcdir/$name"
  git checkout -q $rev
  echo building $name $version - $rev

  cd "$srcdir/$name/build-mac"
  xctool -project "$xcode_project" -sdk $sdk -scheme "$xcode_target" -configuration Release ARCHS="$archs" SYMROOT="$tmpdir/bin" OBJROOT="$tmpdir/obj"
  if test x$? != x0 ; then
    echo failed
    exit 1
  fi
  echo finished

  cd "$tmpdir/bin"
  mkdir -p "$name-$version/$name"
  mkdir -p "$name-$version/$name/lib"
  mv Release/include "$name-$version/$name"
  mv "Release/$library" "$name-$version/$name/lib"
  for dep in $embedded_deps ; do
    mv "$srcdir/$name/build-mac/$dep" "$name-$version"
  done
  echo "$rev"> "$name-$version/git-rev"
  mkdir -p "$resultdir/$name"
  zip -qry "$resultdir/$name/$name-$version.zip" "$name-$version"

  echo build of $name-$version done

  popd >/dev/null

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

  defaults write "$versions_path" "$name" "$version"
}

get_prebuilt_dep()
{
  url="http://d.etpan.org/mailcore2-deps"

  if test "x$name" = x ; then
    return
  fi

  versions_path="$scriptpath/deps-versions.plist"
  version="`defaults read "$versions_path" "$name" 2>/dev/null`"

  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"
  mv "$name-$version/$name" "$scriptpath/../Externals"
  rm -rf "$tempbuilddir"
}