forked from appsquickly/typhoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
350 lines (297 loc) · 15.9 KB
/
build.xml
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="${module.name}" default="build"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="antlib:org.apache.ivy.ant ">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CONFIGURATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property file="build-configuration.properties"/>
<path id="headers">
<fileset dir="${source.main.dir}">
<include name="**/*.h"/>
</fileset>
</path>
<path id="classes">
<fileset dir="${source.main.dir}">
<include name="**/*.m"/>
<exclude name="**/main.m"/>
</fileset>
</path>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PUBLIC TARGETS (can depend on other targets) ~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="build" depends="
bootstrap,
__shouldbeprivate__build"/>
<target name="coverage" depends="
bootstrap,
__shouldbeprivate__coverage"/>
<target name="bootstrap" depends="
--make.dirs,
--clean,
--stamp.build.failing"/>
<target name="clean" depends="--clean"/>
<target name="build-publish" depends="
build-publish-dry-run,
--publish.site.push"/>
<target name="build-publish-dry-run" depends="
bootstrap,
__shouldbeprivate__build,
__shouldbeprivate__coverage,
--publish.site.dry.run"/>
<target name="fast">
<property name="fast" value="yes"/>
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END PUBLIC TARGETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SHOULD BE PRIVATE (but have dependencies on other targets) ~~~~~~~~~~~~~~~~~ -->
<target name="__shouldbeprivate__build" depends="
--test.cocoapods,
--test.generate.report,
--api.report,
--stamp.build.passing"/>
<!-- Building from the command line when using schemes is tricky. Implicit dependencies between targets in different projects are not correctly handled when building with `xcodebuild`.
We must manually build the 'libTyphoon-iOS.a' dependency of the test target which links against the static library before attempting to build that target. Do not attempt to
generate code coverage by linking the library test target to the universal library; this doesn't work. -->
<target name="__shouldbeprivate__coverage" depends="
__build.library.ios.simulator,
--test.library,
--assemble.coverage.data,
--coverage.report"/>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END SHOULD BE PRIVATE TARGETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRIVATE TARGETS (MUST NOT depend on other targets!) ~~~~~~~~~~~~~~~~~~~ -->
<target name="--make.dirs">
<mkdir dir="${target.dir}"/>
<mkdir dir="${intermediates.dir}"/>
<mkdir dir="${temp.dir}"/>
<mkdir dir="${temp.dir}/coverage-data"/>
<mkdir dir="${reports.dir}"/>
<mkdir dir="${reports.dir}/tests"/>
</target>
<target name="--stamp.build.failing">
<copy tofile="${reports.dir}/build-status.png" file="${basedir}/Scripts/build-failed.png"/>
</target>
<target name="--stamp.build.passing">
<copy tofile="${reports.dir}/build-status.png" file="${basedir}/Scripts/build-passed.png" overwrite="true"/>
</target>
<target name="--clean" unless="fast">
<delete dir="${target.dir}"/>
</target>
<target name="--test.cocoapods">
<property name="tests.report" value="${reports.dir}/tests/test-results.txt"/>
<exec executable="xcodebuild" failonerror="false" outputproperty="unit.tests.output">
<arg line="-workspace ${workspace} -scheme '${tests.ios.scheme.name}' test -destination OS=${module.sdk.version},name=iPad"/> <!-- TODO: move out of derived data -->
</exec>
</target>
<target name="__build.library.ios.simulator">
<exec executable="${xcodebuild}" failonerror="true">
<arg line="-destination OS=${module.sdk.version},name=iPhone -workspace ${workspace} -scheme '${library.ios.scheme}'"/>
</exec>
</target>
<property name="ios.simulator.build.dir" value="${target.dir}/ios-simulator"/>
<target name="--test.library">
<!-- The static library must be explicitly built before attempting to test, as of Xcode 4.6.3. A static library dependency is not built by xcodebuild when building the dependent. -->
<property name="tests.report" value="${reports.dir}/tests/test-results.txt"/>
<exec executable="xcodebuild" failonerror="false" outputproperty="unit.tests.output">
<arg line="-workspace ${workspace} test -scheme '${tests.ios.library.scheme.name}' CONFIGURATION_BUILD_DIR='${ios.simulator.build.dir}' CONFIGURATION_TEMP_DIR='${intermediates.dir}' LIBRARY_SEARCH_PATHS='${ios.simulator.build.dir}' -destination OS=${module.sdk.version},name=iPad"/>
</exec>
</target>
<target name="--test.generate.report">
<!-- Write report to disk -->
<echo file="${tests.report}" message="${unit.tests.output}"/>
<!-- Print report to console -->
<echo message="${unit.tests.output}"/>
<loadfile srcfile="${tests.report}" property="tests.error">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.LineContains">
<param type="contains" value="BUILD FAILED"/>
</filterreader>
</filterchain>
</loadfile>
<fail if="tests.error" message="Tests failed to build."/>
<loadfile srcfile="${tests.report}" property="tests.failed">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.LineContains">
<param type="contains" value="** TEST FAILED **"/>
</filterreader>
</filterchain>
</loadfile>
<echo message="Convert test output"/>
<echo file="${temp.dir}/convert-test-output.sh">
#!/bin/bash
set -e # fail script if any commands fail
cd ${temp.dir}
${scripts.dir}/ocunit2junit ${tests.report}
</echo>
<chmod perm="+x" file="${temp.dir}/convert-test-output.sh"/>
<exec executable="${temp.dir}/convert-test-output.sh" failonerror="true" failifexecutionfails="true"/>
<junitreport todir="${temp.dir}">
<fileset dir="${temp.dir}/test-reports" includes="*xml"/>
<report format="frames" styledir="${scripts.dir}" todir="${reports.dir}/test-results">
<param name="TITLE" expression="Test Results"/>
</report>
</junitreport>
<copy todir="${reports.dir}/test-results">
<fileset dir="${scripts.dir}" includes="**/*.png"/>
</copy>
<fail if="tests.failed" message="Tests failed. Report is at ${tests.report}"/>
</target>
<target name="--tests.bundle.install">
<exec executable="bundle" failonerror="true" dir="${source.unit.test.dir}"/>
</target>
<target name="--tests.pod.install">
<exec executable="pod" failonerror="true" dir="${source.unit.test.dir}"/>
</target>
<property name="objects.normal.root" value="${intermediates.dir}"/> <!-- TODO: make sure this only grabs coverage data from the run of iOS Tests (static library) -->
<target name="--assemble.coverage.data">
<mkdir dir="${temp.dir}/coverage-data"/>
<pathconvert pathsep=", " property="gcno.list" refid="classes">
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.m" to="**/*.gcno"/>
</chainedmapper>
</mapper>
</pathconvert>
<echo message="Coverage info files: ${gcno.list}"/>
<copy todir="${temp.dir}/coverage-data" flatten="true">
<fileset dir="${objects.normal.root}" includes="${gcno.list}"/>
</copy>
<pathconvert pathsep=", " property="gcda.list" refid="classes">
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.m" to="**/*.gcda"/>
</chainedmapper>
</mapper>
</pathconvert>
<echo message="Coverage data files: ${gcda.list}"/>
<copy todir="${temp.dir}/coverage-data" flatten="true">
<fileset dir="${objects.normal.root}" includes="${gcda.list}"/>
</copy>
</target>
<target name="--coverage.report">
<property name="coverage.reports.dir" value="${reports.dir}/coverage"/>
<mkdir dir="${coverage.reports.dir}"/>
<echo file="${temp.dir}/geninfo.sh">
#!/bin/bash
set -e # fail script if any commands fail
${gen.info} ${temp.dir}/coverage-data/*.gcno --no-recursion --output-filename \
${temp.dir}/${module.name}-temp.info
#Remove symbols we're not interested in.
${lcov} -r ${temp.dir}/${module.name}-temp.info ${framework.symbols} > ${temp.dir}/${module.name}.info
</echo>
<chmod perm="+x" file="${temp.dir}/geninfo.sh"/>
<exec executable="${temp.dir}/geninfo.sh" failonerror="true" failifexecutionfails="true"/>
<echo file="${temp.dir}/genhtml.sh">
#!/bin/bash
set -e # fail script if any commands fail
${gen.html} --no-function-coverage --no-branch-coverage -o ${coverage.reports.dir} \
--prefix ${basedir} ${temp.dir}/${module.name}.info
</echo>
<chmod perm="+x" file="${temp.dir}/genhtml.sh"/>
<exec executable="${temp.dir}/genhtml.sh" failonerror="true" failifexecutionfails="true"/>
</target>
<property name="framework.symbols" value="UIGeometry.h CGGeometry.h NSRange.h once.h"/>
<target name="--api.report">
<mkdir dir="${reports.dir}/api"/>
<mkdir dir="${user.home}/Library/Developer/Shared"/>
<mkdir dir="${user.home}/Library/Developer/Shared/Documentation"/>
<mkdir dir="${user.home}/Library/Developer/Shared/Documentation/Docsets"/>
<!-- In case it's turned up somehow, despite cleaning up. -->
<delete file="${basedir}/docset-installed.txt"/>
<pathconvert pathsep=" " property="doc.files.list" refid="headers">
<map from='${source.main.dir}' to='"${source.main.dir}"'/>
</pathconvert>
<echo message="Documenting: ${doc.files.list}"/>
<exec executable="appledoc">
<env key="PATH" value="${tools.paths}"/>
<arg line="--project-name=${module.name}"/>
<arg line="--project-company=${module.company}"/>
<arg line="--company-id=${module.company}"/>
<arg line="-h --keep-undocumented-objects --keep-undocumented-members"/>
<arg line="${doc.files.list}"/>
</exec>
<loadfile srcfile="${basedir}/docset-installed.txt" property="docset.installed"/>
<fail unless="docset.installed" message="Error creating documentation"/>
<!-- Don't leave it lying around -->
<delete file="${basedir}/docset-installed.txt"/>
<property name="docs.dir" value="${user.home}/Library/Developer/Shared/Documentation/Docsets"/>
<copy todir="${reports.dir}/api">
<fileset dir="${docs.dir}/${module.company}.${module.name}.docset/Contents/Resources/Documents"/>
</copy>
</target>
<target name="--publish.site.dry.run">
<echo file="${dry.run.site.script}">
#!/bin/bash
set -e # fail script if any commands fail
cd ${basedir}
cp -fr ${basedir}/schema ${reports.dir}
git remote add origin git@github.com:jasperblues/Typhoon.git || true # allow `remote add` to fail without failing script
git remote set-url origin git@github.com:jasperblues/Typhoon.git
git fetch origin gh-pages:gh-pages
git fetch origin gh-pages
git checkout gh-pages
git branch --set-upstream-to=origin/gh-pages gh-pages
git pull
rm -fr ./coverage
cp -fr ${reports.dir}/build-status.png ./build-status.png
git add --all --ignore-removal ./coverage
rm -fr ./coverage
cp -fr ${reports.dir}/coverage/ ./coverage
git add --all --ignore-removal ./build-status.png
rm -fr ./api
cp -fr ${reports.dir}/api ./api
git add --all --ignore-removal api
rm -fr ./test-results
cp -fr ${reports.dir}/test-results/ ./test-results
git add --all --ignore-removal ./test-results
cp -fr ${reports.dir}/schema ./schema
</echo>
<chmod perm="+x" file="${dry.run.site.script}"/>
<exec executable="${dry.run.site.script}" failonerror="true" failifexecutionfails="true">
<env key="PATH" value="${tools.paths}"/>
</exec>
</target>
<property name="dry.run.site.script" value="${temp.dir}/dry.run-site.sh"/>
<target name="--publish.site.push">
<echo file="${push.site.script}">
git commit -a -m "publish reports to gh-pages"
git push -u origin gh-pages
git checkout master
</echo>
<chmod perm="+x" file="${push.site.script}"/>
<exec executable="${push.site.script}" failonerror="true" failifexecutionfails="true">
<env key="PATH" value="${tools.paths}"/>
</exec>
</target>
<property name="push.site.script" value="${temp.dir}/push-site.sh"/>
<property name="library.ios.built.product.name" value="lib${library.ios.name}.a"/>
<target name="--library.ios.build.universal">
<exec executable="${xcodebuild}" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/simulator' CONFIGURATION_TEMP_DIR='${intermediates.dir}/simulator' -configuration Debug ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator${module.sdk.version} -arch i386 -workspace ${workspace} -scheme '${library.ios.scheme}'"/>
</exec>
<exec executable="${xcodebuild}" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/device' CONFIGURATION_TEMP_DIR='${intermediates.dir}/device' -configuration Debug ONLY_ACTIVE_ARCH=NO -sdk iphoneos${module.sdk.version} -arch armv7 -workspace ${workspace} -scheme '${library.ios.scheme}'"/>
</exec>
<echo file="${temp.dir}/lipo.sh">
#!/bin/bash
set -e # fail script if any commands fail
cd ${basedir}
# Create framework directory structure.
mkdir -p "${target.dir}/ios-universal/Headers" &&
# Generate universal binary from desktop, device, and simulator builds.
lipo "${temp.dir}/simulator/${library.ios.built.product.name}" "${temp.dir}/device/${library.ios.built.product.name}" -create -output "${target.dir}/ios-universal/${library.ios.built.product.name}"
</echo>
<chmod perm="+x" file="${temp.dir}/lipo.sh"/>
<exec executable="${temp.dir}/lipo.sh" failonerror="true" failifexecutionfails="true"/>
<copy todir="${target.dir}/ios-universal/Headers" flatten="true">
<fileset dir="${source.main.dir}">
<include name="**/*.h"/>
</fileset>
</copy>
</target>
<property name="library.osx.built.product.name" value="lib${library.osx.name}.a"/>
<target name="--library.build.osx">
<exec executable="xcodebuild" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/osx' CONFIGURATION_TEMP_DIR='${intermediates.dir}/osx' -workspace ${workspace} -scheme ${library.osx.scheme} -sdk macosx${module.osx.sdk.version}"/>
</exec>
<copy todir="${target.dir}/osx/${library.osx.built.product.name}">
<fileset dir="${temp.dir}/osx/${library.osx.built.product.name}"/>
</copy>
</target>
</project>