-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathbuild.xml
294 lines (241 loc) · 12 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Typhoon" default="build">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CONFIGURATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property name="module.name" value="Typhoon"/>
<property name="target.dir" value="${basedir}/build"/>
<property name="source.main.dir" value="${basedir}/Source"/>
<property name="temp.dir" value="${target.dir}/temp"/>
<property name="reports.dir" value="${target.dir}/reports"/>
<property name="tools.paths" value="/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin"/>
<property name="scripts.dir" value="${basedir}/Scripts"/>
<property name="required.coverage" value="87.5"/>
<path id="headers">
<fileset dir="${source.main.dir}">
<include name="**/*.h"/>
<exclude name="**/TyphoonLinkerCategoryBugFix.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-publish" depends="
build,
--publish.site"/>
<target name="publish" depends="--publish.site"/>
<target name="build" depends="
--clean.make.dirs,
--stamp.build.failing,
--test.osx,
--test.ios,
--test.generate.report,
--assemble.coverage.data,
--coverage.report,
--doc,
--build.evaluate,
--stamp.build.passing"/>
<target name="test.ios" depends="--test.ios"/>
<target name="test.osx" depends="--test.osx"/>
<target name="doc" depends="--doc"/>
<target name="no-fail-tests">
<property name="no-fail-tests" value="yes"/>
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END PUBLIC TARGETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRIVATE TARGETS (MUST NOT depend on other targets!) ~~~~~~~~~~~~~~~~~~~ -->
<target name="--clean.make.dirs">
<mkdir dir="${temp.dir}"/>
<mkdir dir="${temp.dir}/coverage-data"/>
<mkdir dir="${reports.dir}"/>
<mkdir dir="${reports.dir}/tests"/>
<echo file="${temp.dir}/init-submodules.sh">
#!/bin/bash
set -e # fail script if any commands fail
rm -fr ${target.dir}
rm -fr ~/Library/Developer/Xcode/DerivedData
git submodule init
git submodule update
</echo>
<chmod perm="+x" file="${temp.dir}/init-submodules.sh"/>
<exec executable="${temp.dir}/init-submodules.sh" failonerror="true" failifexecutionfails="true"/>
</target>
<target name="--stamp.build.failing">
<mkdir dir="${reports.dir}/build-status"/>
<copy tofile="${reports.dir}/build-status/build-status.png" file="${scripts.dir}/build-failed.png"/>
</target>
<target name="--stamp.build.passing" unless="tests.failed">
<copy tofile="${reports.dir}/build-status/build-status.png" file="${scripts.dir}/build-passed.png" overwrite="true"/>
</target>
<target name="--test.osx">
<echo file="${temp.dir}/build.and.test.sh">
#!/bin/bash
xcodebuild -project ${module.name}.xcodeproj/ -scheme 'Typhoon-OSXTests' test
</echo>
<chmod perm="+x" file="${temp.dir}/build.and.test.sh"/>
<exec executable="${temp.dir}/build.and.test.sh" failonerror="false" failifexecutionfails="false" outputproperty="test.osx.output"/>
<echo message="${test.osx.output}"/>
</target>
<target name="--test.ios">
<echo file="${temp.dir}/build.and.test.sh">
#!/bin/bash
xcodebuild -project ${module.name}.xcodeproj/ -scheme 'Typhoon-iOSTests' -configuration Debug -destination OS=7.1,name=iPad test
</echo>
<chmod perm="+x" file="${temp.dir}/build.and.test.sh"/>
<exec executable="${temp.dir}/build.and.test.sh" failonerror="false" failifexecutionfails="false" outputproperty="test.ios.output"/>
<echo message="${test.ios.output}"/>
</target>
<target name="--test.generate.report">
<echo file="${temp.dir}/test-results.txt" message="${test.ios.output}"/>
<loadfile srcfile="${temp.dir}/test-results.txt" 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="${temp.dir}/test-results.txt" 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 ${temp.dir}/test-results.txt > ${temp.dir}/junit-parser.txt
</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="${basedir}/Scripts" 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>
</target>
<target name="--build.evaluate" unless="no-fail-tests">
<fail if="tests.failed" message="Tests failed. Report is at ${reports.dir}/test-results"/>
<exec executable="${scripts.dir}/CoverageChecker.groovy" failifexecutionfails="true" failonerror="true">
<arg line="-f ${temp.dir}/${module.name}.info -c ${required.coverage}"/>
</exec>
</target>
<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>
<copy todir="${temp.dir}/coverage-data" flatten="true">
<fileset dir="${user.home}/Library/Developer/Xcode/DerivedData" includes="${gcno.list}"
excludes="**/NSArray+TyphoonManualEnumeration.gcno,**/TyphoonAssemblyAdviser.gcno,**/TyphoonAssemblyDefinitionBuilder.gcno"/>
</copy>
<pathconvert pathsep=", " property="gcda.list" refid="classes">
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.m" to="**/*.gcda"/>
</chainedmapper>
</mapper>
</pathconvert>
<echo message="Coverage info files: ${gcno.list}"/>
<!--<echo message="Coverage data files: ${gcda.list}"/>-->
<copy todir="${temp.dir}/coverage-data" flatten="true">
<fileset dir="${user.home}/Library/Developer/Xcode/DerivedData" 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
geninfo ${temp.dir}/coverage-data/*.gcno --output-filename ${temp.dir}/${module.name}-temp.info
#Remove symbols we're not interested in.
lcov -r ${temp.dir}/${module.name}-temp.info TyphoonJRSwizzle.m once.h NSRange.h > ${temp.dir}/${module.name}.info
</echo>
<chmod perm="+x" file="${temp.dir}/geninfo.sh"/>
<exec executable="${temp.dir}/geninfo.sh" failonerror="false" failifexecutionfails="false" outputproperty="geninfo.out"
errorproperty="geninfo.error"/>
<echo message="${geninfo.out}"/>
<echo file="${temp.dir}/genhtml.sh">
#!/bin/bash
genhtml --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="false" failifexecutionfails="false" outputproperty="genhtml.out"
errorproperty="genhtml.error"/>
<exec executable="lcov">
<arg line="--summary ./build/temp/${module.name}.info"/>
</exec>
</target>
<target name="--doc">
<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="doxygen" outputproperty="doxygen.out" errorproperty="doxygen.error"/>
<mkdir dir="${reports.dir}/api/images"/>
<copy todir="${reports.dir}/api/images">
<fileset dir="images"/>
</copy>
<copy todir="${reports.dir}/api" file="${scripts.dir}/navtree.css" overwrite="yes"/>
<copy todir="${reports.dir}/api" file="${scripts.dir}/doxygen.png" overwrite="yes"/>
</target>
<target name="--publish.site">
<echo file="${dry.run.site.script}">
<![CDATA[
#!/bin/bash
set -e # fail script if any commands fail
cd ${basedir}
find Tests/ -type f -exec git update-index --assume-unchanged '{}' \; &> ${temp.dir}/index.out
git remote add origin [email protected]:typhoon-framework/Typhoon.git || true # allow `remote add` to fail without failing script
git remote set-url origin [email protected]:typhoon-framework/Typhoon.git
git fetch origin gh-pages:gh-pages
git fetch origin gh-pages
git stash
git checkout gh-pages
git branch --set-upstream-to=origin/gh-pages gh-pages
git pull
cp -fr ${reports.dir}/build-status/build-status.png ./build-status/build-status.png
rm -fr ./coverage
mkdir -p ${reports.dir}/coverage
cp -fr ${reports.dir}/coverage/ ./coverage
git add --all --ignore-removal ./coverage
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
git commit -a -m "publish reports to gh-pages"
git push -u origin gh-pages
git checkout master
find Tests -type f -exec git update-index --no-assume-unchanged '{}' \;
]]>
</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"/>
</project>