forked from appsquickly/typhoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
271 lines (232 loc) · 11 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
<?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="
--make.dirs,
--clean,
--make.dirs,
--tests.build,
--assemble.coverage.data,
--coverage.report,
--api.report"/>
<target name="clean" depends="--clean"/>
<target name="build-publish" depends="
build,
--publish.site"/>
<target name="fast">
<property name="fast" value="yes"/>
</target>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END PUBLIC TARGETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRIVATE TARGETS (MUST NOT depend on other targets!) ~~~~~~~~~~~~~~~~~~~ -->
<target name="--make.dirs">
<mkdir dir="${target.dir}"/>
<mkdir dir="${temp.dir}"/>
<mkdir dir="${temp.dir}/coverage-data"/>
<mkdir dir="${reports.dir}"/>
<mkdir dir="${reports.dir}/tests"/>
</target>
<target name="--clean" unless="fast">
<delete dir="${target.dir}"/>
<delete verbose="yes" failonerror="no">
<fileset dir="/tmp" includes="**/*.pbxproj,**/*.m,**/*.h"/>
</delete>
</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>
<echo message="Coverage info files: ${gcno.list}"/>
<copy todir="${temp.dir}/coverage-data" flatten="true">
<fileset dir="${target.dir}" 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="${target.dir}" includes="${gcda.list}"/>
</copy>
</target>
<target name="--tests.build">
<property name="tests.report" value="${reports.dir}/tests/test-results.txt"/>
<exec executable="xcodebuild" failonerror="false" outputproperty="unit.tests.output">
<arg line="-target Tests TEST_AFTER_BUILD=YES"/>
</exec>
<!-- 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="FAILURE"/>
</filterreader>
</filterchain>
</loadfile>
<echo message="Convert test output"/>
<echo file="${temp.dir}/convert-test-output.sh">
#!/bin/sh
cd ${temp.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="--coverage.report">
<property name="coverage.reports.dir" value="${reports.dir}/coverage"/>
<mkdir dir="${coverage.reports.dir}"/>
<echo file="${temp.dir}/geninfo.sh">
#!/bin/sh
geninfo "${temp.dir}/coverage-data/"*.gcda --no-recursion -o "${temp.dir}/coverage-temp.info"
#Remove symbols we're not interested in.
lcov -r "${temp.dir}/coverage-temp.info" _string.h NSRange.h once.h TyphoonRXMLElement.m TyphoonRXMLElement.h TyphoonJRSwizzle.m > "${temp.dir}/coverage.info"
</echo>
<chmod perm="+x" file="${temp.dir}/geninfo.sh"/>
<exec executable="${temp.dir}/geninfo.sh" failonerror="true" failifexecutionfails="true">
<env key="PATH" value="${tools.paths}"/>
</exec>
<echo file="${temp.dir}/genhtml.sh">
#!/bin/sh
genhtml -p "${source.main.dir}" --no-function-coverage --no-branch-coverage -o "${coverage.reports.dir}" \
--prefix "${basedir}" "${temp.dir}/coverage.info"
</echo>
<chmod perm="+x" file="${temp.dir}/genhtml.sh"/>
<exec executable="${temp.dir}/genhtml.sh" failonerror="true" failifexecutionfails="true">
<env key="PATH" value="${tools.paths}"/>
</exec>
</target>
<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">
<echo file="${temp.dir}/publish-site.sh">
#!/bin/sh
cd ${basedir}
cp -fr ${basedir}/schema ${reports.dir}
git remote add origin [email protected]:jasperblues/Typhoon.git
git remote set-url origin [email protected]:jasperblues/Typhoon.git
git fetch origin gh-pages:gh-pages
git fetch origin gh-pages
git checkout gh-pages
git pull
rm -fr ./coverage
cp -fr ${reports.dir}/coverage/ ./coverage
git add ./coverage
rm -fr ./api
cp -fr ${reports.dir}/api ./api
git add api
rm -fr ./test-results
cp -fr ${reports.dir}/test-results/ ./test-results
git add ./test-results
cp -fr ${reports.dir}/schema ./schema
git add schema
git commit -a -m "publish reports to gh-pages"
git push -u origin gh-pages
git checkout master
</echo>
<chmod perm="+x" file="${temp.dir}/publish-site.sh"/>
<exec executable="${temp.dir}/publish-site.sh" failonerror="true" failifexecutionfails="true">
<env key="PATH" value="${tools.paths}"/>
</exec>
</target>
<target name="--build.ios.universal">
<delete dir="${target.dir}"/>
<exec executable="${xcodebuild}" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/simulator' -sdk iphonesimulator${module.sdk.version} -arch i386 -target Typhoon-iOS-StaticLib"/>
</exec>
<exec executable="${xcodebuild}" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/device' -sdk iphoneos${module.sdk.version} -arch armv7 -target Typhoon-iOS-StaticLib"/>
</exec>
<echo file="${temp.dir}/lipo.sh">
#!/bin/sh
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/libTyphoon-iOS-StaticLib.a" "${temp.dir}/device/libTyphoon-iOS-StaticLib.a" -create -output "${target.dir}/ios-universal/libTyphoon-iOS.a"
</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>
<target name="--build.osx">
<exec executable="xcodebuild" failonerror="true">
<arg line="CONFIGURATION_BUILD_DIR='${temp.dir}/osx' -target Typhoon-OSX"/>
</exec>
<copy todir="${target.dir}/osx/Typhoon-OSX.framework">
<fileset dir="${temp.dir}/osx/Typhoon-OSX.framework"/>
</copy>
</target>
</project>