This repository has been archived by the owner on Feb 8, 2019. It is now read-only.
/
build.xml
484 lines (395 loc) · 21.2 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<project name="Kimera" default="debug" basedir=".">
<description>
Massimo Oliviero - Kimera, an iOS sample application.
</description>
<!-- ####################################### -->
<!-- PROPERTIES Section -->
<!-- ####################################### -->
<property environment="env"/>
<!-- APP Specific properties -->
<property name="app.name" value="Kimera"/>
<property name="app.workspace" value="Kimera.xcworkspace"/>
<property name="app.scheme" value="KimeraMobile"/>
<property name="app.scheme.tests" value="KimeraMobileTests"/>
<property name="app.target" value="KimeraMobile"/>
<property name="app.target.test" value="KimeraMobileTests"/>
<property name="app.plist" value="KimeraMobile/KimeraMobile/Application/KimeraMobile-Info.plist"/>
<property name="app.localization" value="Localization"/>
<property name="app.company" value="Massimo Oliviero"/>
<property name="app.company.domain" value="net.massimooliviero"/>
<!-- DIRECTORY, FILE and URL settings -->
<property name="app.dir.src" value="KimeraMobile"/>
<property name="app.dir.scripts" value="KimeraMobile.Build.Scripts"/>
<property name="app.dir.doc" value="KimeraMobile.Build.Doc"/>
<property name="app.dir.analyze" value="KimeraMobile.Build.Analyze"/>
<property name="app.dir.oclint" value="KimeraMobile.Build.OCLint"/>
<property name="app.dir.coverage" value="KimeraMobile.Build.TestCoverage"/>
<property name="app.dir.uatest" value="KimeraMobile.Build.UATest"/>
<property name="app.file.oclint" value=""${basedir}/${app.dir.oclint}/test.html""/>
<property name="app.file.readme" value="${basedir}/Readme.md"/>
<property name="app.repo.user" value=""/>
<property name="app.repo.api" value=""/>
<!-- PROVISIONING settings -->
<property name="provisioning.name" value="iPhone Distribution: Massimo Oliviero"/>
<property name="provisioning.file" value="./${app.dir.scripts}/embedded.mobileprovision"/>
<!-- Testflight properties -->
<property name="testflight.list" value="Kimera"/>
<property name="testflight.teamtoken" value="${env.TESTFLIGHT_TEAMTOKEN}"/>
<property name="testflight.apitoken" value="${env.TESTFLIGHT_APITOKEN}"/>
<property name="testflight.notes" value=""/>
<!-- Script properties -->
<property name="script.command.build" value="xcodebuild"/> <!-- or xctool.sh -->
<!-- ####################################### -->
<!-- TOP TARGET -->
<!-- ####################################### -->
<target name="debug" description="compile the source">
<antcall target="compile">
<param name="compile.workspace" value="${app.workspace}"/>
<param name="compile.scheme" value="${app.scheme}"/>
<param name="compile.configuration" value="Debug"/>
<param name="compile.sdk" value="iphonesimulator"/>
</antcall>
</target>
<target name="release" description="compile the source">
<antcall target="compile">
<param name="compile.workspace" value="${app.workspace}"/>
<param name="compile.scheme" value="${app.scheme}"/>
<param name="compile.configuration" value="Release"/>
<param name="compile.sdk" value="iphoneos"/>
</antcall>
</target>
<target name="adhoc" description="compile the source">
<antcall target="compile">
<param name="compile.workspace" value="${app.workspace}"/>
<param name="compile.scheme" value="${app.scheme}"/>
<param name="compile.configuration" value="AdHoc"/>
<param name="compile.sdk" value="iphoneos"/>
</antcall>
</target>
<target name="deploy" description="deploy the app" depends="changelog">
<echo message="TestFlight, Team Token: ${testflight.teamtoken}" />
<echo message="TestFlight, Api Token: ${testflight.apitoken}" />
<antcall target="plist"/>
<antcall target="adhoc"/>
<antcall target="ipa"/>
<antcall target="zip"/>
<antcall target="testflight"/>
<antcall target="tag"/>
<antcall target="pushtag"/>
</target>
<!-- ####################################### -->
<!-- SCRIPT Section -->
<!-- ####################################### -->
<scriptdef name="increase.number" language="javascript">
<attribute name="value" />
<attribute name="property"/>
<![CDATA[
var initVal = attributes.get("value");
var finalVal = parseInt(initVal) + 1;
project.setProperty(attributes.get("property"), finalVal);
]]>
</scriptdef>
<!-- ####################################### -->
<!-- HELP -->
<!-- ####################################### -->
<target name="help">
<echo message="This buildfile shows how to get help."/>
<echo>Target:</echo>
<echo>
[debug] = to compile project with 'Debug' configuration on iPhoneSimulator SDK
[release] = to compile project with 'Release' configuration on iPhoneOS SDK
[adhoc] = to compile project with 'AdHoc' configuration on iPhoneOS SDK
</echo>
</target>
<!-- ####################################### -->
<!-- ZIP dSYM -->
<!-- ####################################### -->
<target name="zip" description="">
<exec executable="zip" failOnError="true">
<arg line="-r build/${app.name}.app.dSYM.zip build/${app.name}.app.dSYM"/>
</exec>
</target>
<!-- ####################################### -->
<!-- GENSTRING - Localizations -->
<!-- ####################################### -->
<target name="genstring" description="generate string table from source code for localization">
<mkdir dir="${app.localization}"/>
<exec executable="bash" failOnError="true">
<arg value="-c"/>
<arg value="find ./ -name *.m -print0 | xargs -0 genstrings -o ${app.localization}"/>
</exec>
</target>
<!-- ####################################### -->
<!-- GIT TAG -->
<!-- ####################################### -->
<target name="tag" description="">
<exec executable="/usr/libexec/PlistBuddy" outputproperty="TagAppVersion" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Print :CFBundleShortVersionString"/>
<arg value="${app.plist}"/>
</exec>
<exec executable="/usr/libexec/PlistBuddy" outputproperty="TagAppBuild" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Print :CFBundleVersion"/>
<arg value="${app.plist}"/>
</exec>
<property name="TagVersion" value="v${TagAppVersion}(${TagAppBuild})"/>
<exec executable="git" failOnError="true">
<arg line="commit"/>
<arg line="-a"/>
<arg line="-m 'version ${TagVersion}'"/>
</exec>
<exec executable="git" failOnError="true">
<arg line="tag"/>
<arg line="-a '${TagVersion}'"/>
<arg line="-m 'tagging version ${TagVersion}'"/>
</exec>
<exec executable="git" failOnError="true">
<arg line="push"/>
</exec>
</target>
<!-- ####################################### -->
<!-- GIT PUSH TAG -->
<!-- ####################################### -->
<target name="pushtag">
<exec executable="git" failOnError="true">
<arg line="push"/>
<arg line="origin --tags"/>
</exec>
</target>
<!-- ####################################### -->
<!-- CREATE CHANGELOG FROM GIT COMMENTS -->
<!-- ####################################### -->
<target name="changelog" description="">
<!-- Recupera il nome dell'ultimo tag -->
<exec executable="git" outputproperty="git.last.tag" failOnError="no">
<arg value="describe"/>
<arg line="--abbrev=0"/>
<arg line="--tags"/>
</exec>
<condition property="git.from.to" value="${git.last.tag}..HEAD" else=" ">
<and>
<isset property="git.last.tag"/>
<not><equals arg1="${git.last.tag}" arg2="fatal: No names found, cannot describe anything."/></not>
</and>
</condition>
<condition property="git.last.tag.name" value="${git.last.tag}" else="1.0.0">
<and>
<isset property="git.last.tag"/>
<not><equals arg1="${git.last.tag}" arg2="fatal: No names found, cannot describe anything."/></not>
</and>
</condition>
<!-- Recupera dal plist del progetto l'ultima versione -->
<exec executable="/usr/libexec/PlistBuddy" outputproperty="CFAppVersion" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Print :CFBundleShortVersionString"/>
<arg value="${app.plist}"/>
</exec>
<exec executable="/usr/libexec/PlistBuddy" outputproperty="CFAppBuild" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Print :CFBundleVersion"/>
<arg value="${app.plist}"/>
</exec>
<!-- Incrementa la versione di uno -->
<increase.number value="${CFAppBuild}" property="CFAppBuildPlus"/>
<!-- Definisce il nuovo tag -->
<property name="NewTagName" value="v${CFAppVersion}(${CFAppBuildPlus})"/>
<exec executable="git" outputproperty="git.changelog" failOnError="true">
<arg value="log"/>
<arg line="${git.from.to}"/>
<arg line="--grep='^\[add\]' --grep='^\[chg\]' --grep='^\[fix\]'"/>
<arg line="--pretty=format:'%s (%an/%h)'"/>
<!-- <arg line="-ancestry-path 270ba53..c216c42"/> -->
</exec>
<!-- Definisce il changelog -->
<property name="app.changelog" value="

Changelog da ${git.last.tag.name} a ${NewTagName}:
${git.changelog}"/>
<!-- Stampa il changelog -->
<echo message="${app.changelog}" />
</target>
<!-- ####################################### -->
<!-- BITBUCKET ADD VERSION -->
<!-- ####################################### -->
<target name="repo-add-version" description="">
<exec executable="curl" failOnError="true">
<arg line="-u ${app.repo.user}"/>
<arg line="${app.repo.api}/issues/versions/"/>
<arg line="-F name='${NewTagName}'"/>
</exec>
</target>
<!-- ####################################### -->
<!-- TESTFLIGHT UPLOAD -->
<!-- ####################################### -->
<target name="testflight" description="">
<exec executable="curl" failOnError="true">
<arg line="https://testflightapp.com/api/builds.json"/>
<arg line="--verbose --progress-bar"/>
<arg line="--fail"/> <!-- in questo modo se non http 200 ritorna un exit code diverso da 0 e fallisce il target -->
<arg line="-F file=@"${basedir}/build/${app.name}.ipa""/>
<arg line="-F dsym=@"${basedir}/build/${app.name}.app.dSYM.zip""/>
<arg line="-F api_token='${testflight.apitoken}'"/>
<arg line="-F team_token='${testflight.teamtoken}'"/>
<arg line="-F notes='${testflight.notes}${app.changelog}'"/>
<arg line="-F notify=True"/>
<arg line="-F distribution_lists='${testflight.list}'"/>
</exec>
</target>
<!-- ####################################### -->
<!-- CUCUMBER TESTS -->
<!-- ####################################### -->
<target name="cucumber">
<exec executable="cucumber" failOnError="true">
<arg line="-f junit --out build-cucumber"/>
</exec>
</target>
<!-- ####################################### -->
<!-- UIAutomation TEST -->
<!-- ####################################### -->
<target name="uitest" description="">
<delete dir="${basedir}/${app.dir.uatest}"/>
<mkdir dir="${basedir}/${app.dir.uatest}"/>
<antcall target="debug"/>
<exec executable="instruments" failOnError="true">
<arg line="-t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"/>
<arg line=""${basedir}/build/Debug-iphonesimulator/${app.name}.app""/>
<arg line="-e UIASCRIPT "${basedir}/${app.dir.scripts}/build_uitest.js""/>
<arg line="-e UIARESULTSPATH "${basedir}/${app.dir.uatest}""/>
</exec>
</target>
<target name="compile" description="">
<exec executable="${script.command.build}" failOnError="true">
<arg line="-verbose -workspace ${compile.workspace} -scheme ${compile.scheme} -configuration ${compile.configuration} -sdk ${compile.sdk}"/>
<arg value="clean"/>
<arg value="build"/>
<arg value="CONFIGURATION_BUILD_DIR=${basedir}/build"/>
</exec>
</target>
<target name="analyze" description="">
<exec executable="scan-build" failOnError="true">
<arg line="-v -o ${app.dir.analyze}"/>
<arg line="xcodebuild -verbose -workspace ${app.workspace} -scheme ${app.scheme} -configuration Release -sdk iphonesimulator"/>
</exec>
</target>
<target name="oclint" description="">
<mkdir dir="${app.dir.oclint}"/>
<delete file="xcodebuild.log"/>
<delete file="compile_commands.json"/>
<exec executable="bash" failOnError="true">
<arg value="-c"/>
<arg value="xcodebuild -verbose -workspace ${app.workspace} -scheme ${app.scheme} -configuration Debug -sdk iphonesimulator | tee xcodebuild.log"/>
</exec>
<exec executable="oclint-xcodebuild" failOnError="true"/>
<exec executable="oclint-json-compilation-database" failOnError="true">
<arg line="-v"/>
<arg line="-- -html -stats -o=${app.file.oclint}"/>
</exec>
</target>
<!-- ####################################### -->
<!-- Appledoc -->
<!-- ####################################### -->
<target name="doc" description="">
<exec executable="/usr/libexec/PlistBuddy" outputproperty="CurrentVersion" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value ="Print :CFBundleShortVersionString"/>
<arg value="${app.plist}"/>
</exec>
<echo message="Fetched the last version in the plist: ${CurrentVersion}" />
<exec executable="appledoc" failOnError="true">
<arg line="--print-settings"/>
<arg line="--project-name ${app.name}"/>
<arg line="--project-version ${CurrentVersion}"/>
<arg line="--project-company "${app.company}""/>
<arg line="--company-id ${app.company.domain}"/>
<arg line="--docset-desc vediamo"/>
<arg line="--create-html"/> <!-- genera anche html -->
<arg line="--logformat xcode"/> <!-- output in formato compatibile con xcode -->
<arg line="--no-install-docset"/> <!-- non installa il docset anche se generato -->
<arg line="--no-create-docset"/> <!-- non crea il docset -->
<arg line="--no-repeat-first-par"/>
<arg line="--keep-undocumented-objects"/> <!-- include nella documentazione anche le classi senza doc specifica -->
<arg line="--keep-undocumented-members"/> <!-- include nella documentazione anche i memebri senza doc specifica -->
<arg line="--keep-merged-sections"/>
<arg line="--keep-intermediate-files"/> <!-- mantiene i file html nella root -->
<arg line="--index-desc "${app.file.readme}""/> <!-- include in file readme (markdown) nell index della doc -->
<arg line="--output ${app.dir.doc}"/>
<arg line="`find ${app.dir.src} -name 'QST*.h'`"/>
</exec>
</target>
<!-- ####################################### -->
<!--
Per eseguire i test a linea di comando è necessario:
1. Creare un nuovo target "Cocoa Touch Unit Testing Bundle" con nome $AppTests
2. Creare (se non esiste) uno schema $AppTests
3. Build Phases, aggiunre il progetto normale come dipendenza nel tab "Target Dependencies"
3. Edit Schema tab "Build" spuntare il flag "Run"
4. Build settings, impostare il flag "Test After Build" a YES (TEST_AFTER_BUILD)
5. Build settings, impostare il flag "Build Active Architeture Only" a NO (ONLY_ACTIVE_ARCH), anche su tutti i progetti dipendenti
6. Build settings, se c'è rimuovere il valore nel parametro "Test Host"
-->
<!-- ####################################### -->
<target name="test" description="test the source">
<antcall target="compile">
<param name="compile.workspace" value="${app.workspace}"/>
<param name="compile.scheme" value="${app.scheme.tests}"/>
<param name="compile.configuration" value="Debug"/>
<param name="compile.sdk" value="iphonesimulator"/>
</antcall>
</target>
<!-- ####################################### -->
<!--
Esegue i test ed esporta il risultato in formato JUnit compatibile
NOTE: la cartella di esportazione è definita del file ocunit2junit.rb
-->
<!-- ####################################### -->
<target name="testreport" description="test the source">
<exec executable="bash" failOnError="true">
<arg value="-c"/>
<arg value="xcodebuild -workspace ${app.workspace} -scheme ${app.scheme.tests} -configuration Debug -sdk iphonesimulator clean build | ${basedir}/${app.dir.scripts}/ocunit2junit.rb"/>
</exec>
</target>
<!-- ####################################### -->
<!--
Per attivare il coverage dei test è necessario:
1. Sul target di test, impostare YES il flag "Generate Test Coverage File" (GCC_GENERATE_TEST_COVERAGE_FILES)
2. Sul target di test, impostare YES il flag "Instrument Program Flow" (GCC_INSTRUMENT_PROGRAM_FLOW_ARCS)
-->
<!-- ####################################### -->
<target name="testcoverage">
<delete dir="${basedir}/${app.dir.coverage}"/>
<antcall target="test"/>
<exec executable="osascript" failOnError="true">
<arg value="./${app.dir.scripts}/CodeCoverage.scpt"/>
<!-- non usare " per i percorsi altrimenti non funzica -->
<arg value="${basedir}/build/${app.target}.build/Debug-iphonesimulator/${app.target.test}.build/Objects-normal/i386"/>
<arg value="${basedir}/${app.dir.coverage}"/>
</exec>
</target>
<target name="ipa" description="">
<exec executable="xcrun" failOnError="true">
<arg line="-sdk iphoneos PackageApplication"/>
<arg line="-v "${basedir}/build/${app.name}.app""/>
<arg line="-o "${basedir}/build/${app.name}.ipa""/>
<arg line="--embed ${provisioning.file}"/>
</exec>
</target>
<!-- ####################################### -->
<!-- PLIST Version - Modifica il plist del progetto
incrementando CFBundleVersion di uno -->
<!-- ####################################### -->
<target name="plist" description="">
<exec executable="/usr/libexec/PlistBuddy" outputproperty="CurrentVersion" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Print :CFBundleVersion"/>
<arg value="${app.plist}"/>
</exec>
<echo message="Fetched the last version in the plist: ${CurrentVersion}" />
<increase.number value="${CurrentVersion}" property="result"/>
<exec executable="/usr/libexec/PlistBuddy" outputproperty="PListOutput" errorproperty="PListError" failOnError="true">
<arg value="-c"/>
<arg value="Set :CFBundleVersion ${result}" />
<arg value="${app.plist}"/>
</exec>
<echo message="Output: ${PListOutput}"/>
<echo message="Errors: ${PListError}"/>
<echo message="Old version number: ${CurrentVersion} New Version Number: ${result}" />
</target>
</project>