-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
632 lines (502 loc) · 19 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?xml version="1.0"?>
<project
name="YeSQL"
description="A PHP project"
default="longhelp">
<!--
This is the Phing build file for YeSQL.
Phing is a build tool. Learn more about it at http://phing.info.
Copyright (c) 2010, mbutcher.
-->
<target name="help" description="Print short help message.">
<echo>
#############
# Basic Usage #
#############
Use Phing to manage this project.
To list all of the available commands, do:
phing -l
To build a release, type:
phing build -Dversion=1.0.0
Leaving -Dversion off will result in a "snapshot" release.
To learn about more options, type
phing longhelp
</echo>
</target>
<target name="longhelp" description="Information on the build system.">
<echo>
############
# THE BASICS #
############
To build YeSQL, run:
phing build
This will create a complete distribution of the project in /dist, with the build files in /bin/build. Documentation will be generated if the appropriate target is configured.
A versioned release can be built with:
phing build -Dversion=2.1.1alpha1
To see all available build targets, run this command:
phing -l
Check Configuration
===================
To check how your project is configured, use the 'info' target:
phing info
This will print details about the project.
Syntax Check
============
To check the syntax of all of your PHP source code, run this:
phing lint
It will generate a report on any files that fail to parse correctly.
Generating Documentation
========================
To generate docs, do:
phing doc
Documentation will be stored in doc/. You can start with doc/index.html.
Running Unit Tests
==================
To run any configured tests, do:
phing test
The above will generate HTML test results which will be placed in test/reports/. If you wish to run the test and print the results directly the the command line (fast tests), you should run 'phing ftest' instead.
phing ftest
Code Coverage Reports
=====================
To run coverage analysis, do:
phing coverage
This will create HTML pages describing code coverage. The coverage analysis will be available in test/coverage
###################
# OPTIONAL FEATURES #
###################
Phar Packages
=============
This script can produce Phar packages on systems with PHP 5.3:
phing pharBuild
TextMate Integration
====================
If you are a TextMate user, you can install the Phing TextMate bundle
(http://github.com/technosophos/phing-tmbundle) to get some special TextMate features.
Special TextMate keybindings:
CMD-U: Run any target in the build file
CMD-SHIFT-I: Run the tmtest unit test target
CMD-SHIFT-U: Run the tmtarget target, which you can configure to do whatever you want
Pear Channel Support
====================
This script will generate PEAR-compatible packages, provided you configure your settings correctly.
If you use Pirum (http://pirum-project.org) to manage your PEAR channel, you can use the
Phing-Pirum package (http://github.com/technosophos/Phing-Pirum) to build or manage the channel from
these scripts. You need to edit the Pirum configuration in build.xml, though.
Pyrus Support
=============
We are experimenting with supporting Pyrus, the next generation PEAR client. Pyrus can build
packages much more effectively, and supports a wide range of useful commands. Currently, we are
working on two targets:
phing pyrusMake
phing pyrusPackage
========
To print this message, do:
phing longhelp
</echo>
</target>
<property file="project.properties"/>
<!-- IMPORTANT: Project settings. -->
<property name="project.name" value="${phing.project.name}"/>
<property name="project.homepage" value="http://github.com/technosophos/metaphing"/>
<property name="project.summary" value="A PHP project"/>
<property name="project.description">
This is a useful PHP project.
</property>
<property name="project.license" value="MIT License"/>
<property name="project.php.version" value="5.1.0"/>
<property name="project.lead" value="mbutcher"/>
<property name="project.lead.email" value="someone@example.com"/>
<!-- PEAR-specific settings -->
<property name="pear.version" value="1.4.6"/>
<property name="pear.channel" value="pear.myserver.net"/>
<!-- PhpDocumentor-specific settings. -->
<!-- Documentation style used by PHPDocumentor -->
<property name="phpdoc.style" value="HTML:frames:earthli"/>
<property name="doxygen.config" value="./config.doxy"/>
<!--
If you are using Pirum to manage PEAR channels, install Phing-Pirum
and uncomment this section:
* Includepath only if you didn't install Phing-Pirum from http://pear.querypath.org
* Two taskdefs for Phing Pirum tasks
* A property, pearchannel, setting the location of your PEAR channel.
-->
<!--
<includepath classpath="../Phing-Pirum/src"/>
<taskdef classname="PhingPirum.Task.PirumBuildTask" name="pirumbuild"/>
<taskdef classname="PhingPirum.Task.PirumAddTask" name="pirumadd"/>
<property name="pearchannel" value="../pear.querypath.org/pear"/>
-->
<includepath classpath="../PhingDoxygen/src"/>
<taskdef classname="PhingDoxygen.Task.DoxygenTask" name="doxygen"/>
<!-- Pyrus tasks. -->
<includepath classpath="/Users/mbutcher/Code"/> <!-- Pyrus is here. -->
<includepath classpath="../PhingPyrus/src"/>
<taskdef classname="PhingPyrus.Task.PyrusMakeTask" name="pyrusmake"/>
<taskdef classname="PhingPyrus.Task.PyrusPackageTask" name="pyruspackage"/>
<taskdef classname="PhingPyrus.Task.PyrusHelpTask" name="pyrushelp"/>
<taskdef classname="PhingPyrus.Task.PyrusExecTask" name="pyrusexec"/>
<!-- Directory locations -->
<property name="srcdir" value="${project.basedir}/src"/>
<property name="testdir" value="${project.basedir}/test"/>
<property name="builddir" value="${project.basedir}/bin/build"/>
<property name="docsdir" value="${project.basedir}/doc/api"/>
<property name="packagedir" value="${project.basedir}/dist"/>
<property name="datadir" value="${project.basedir}/data"/>
<property name="exampledir" value="${project.basedir}/examples"/>
<property name="tutorialdir" value="${project.basedir}/tutorials"/>
<!-- If you are writing Phar files, use this for Phar stubs: -->
<property name="phardir" value="${project.basedir}/phar"/>
<!-- ====================================================================
PHING FILE SETS
==================================================================== -->
<!-- Files that must be included in the release -->
<fileset id="licensefiles" dir=".">
<include name="README.md"/>
<include name="INSTALL"/>
<include name="COPYING-MIT.txt"/>
<include name="CREDITS"/>
<include name="README.pear"/>
<include name="RELEASE"/>
<include name="API"/>
</fileset>
<!-- Files to be treated as source code -->
<fileset id="sourcecode" dir="${srcdir}">
<include name="**/*" />
</fileset>
<!-- Unit tests and auxilliary files -->
<fileset id="unittests" dir="${testdir}/Tests">
<include name="**/*Test.php" />
</fileset>
<!-- Examples -->
<fileset id="examplecode" dir="${exampledir}">
<include name="**/*" />
</fileset>
<!-- DocBook Tutorials imported into PhpDocumentor -->
<fileset id="tutorials" dir="${tutorialdir}">
<include name="**/*" />
</fileset>
<!-- Documentation -->
<fileset id="docs" dir="${docsdir}">
<include name="**/*" />
</fileset>
<!-- Data -->
<fileset id="data" dir="${datadir}">
<include name="**/*" />
</fileset>
<!-- ====================================================================
PHING TARGETS
==================================================================== -->
<!-- TARGET
Print useful information and exit.
-->
<target name="info" description="Print information about this project" depends="setup">
<echo>
Project name: ${project.name}
By ${project.lead} (${project.lead.email})
Summary: ${project.summary}
Description: ${project.description}
Source code: ${srcdir}
Complete packages: ${packagedir}
Version string pattern: ${project.name}-dev${DSTAMP}
Edit project.properties (or build.xml) to set the above.
</echo>
</target>
<!-- TARGET
The primary build target.
Runs the following:
* lint
* setup
* prebuild
* docBuild
* fullBuild
-->
<target name="build" depends="lint, setup, prebuild, docBuild, fullBuild"
description="Generate docs, and full build and then creates packages."
>
<!-- Main build target. Calls all dependencies and exits. -->
</target>
<!-- TARGET
Target that should be run always.
-->
<target name="setup" description="Run required configuration for any build.">
<tstamp/>
<!--
Default version.
Note that this is designed to appear to match the PEAR conventions. However,
it uses a date stamp instead of an incrementing integer, making this more suitable
for daily snapshots.
-->
<property name="version" value="dev${DSTAMP}"/>
</target>
<!-- TARGET
Tasks to do before any build.
-->
<target name="prebuild" description="Prepare for building. No need to call directly.">
<mkdir dir="./dist"/>
</target>
<!-- TARGET
Build the full package.
We do this by copying all important components into ${builddir} and then
packaging them all up. Along the way, we create a package.xml file. With a little
tweaking, you can use the distributed package as a PEAR package.
-->
<target name="fullBuild" description="Full ${project.name} build, including docs."
depends="setup,prebuild">
<property name="releasedir" value="${builddir}/${project.name}-${version}" override="true"/>
<delete dir="${releasedir}" />
<!-- Make all necessary directories. -->
<mkdir dir="${releasedir}"/>
<mkdir dir="${releasedir}/data"/>
<mkdir dir="${releasedir}/doc"/>
<mkdir dir="${releasedir}/examples"/>
<mkdir dir="${releasedir}/scripts"/>
<mkdir dir="${releasedir}/src"/>
<mkdir dir="${releasedir}/test"/>
<!-- mkdir dir="${releasedir}/tutorials"/ -->
<!-- Copy license files. -->
<copy todir="${releasedir}">
<filterchain>
<replacetokens begintoken="%" endtoken="%">
<token key="UNSTABLE" value="${version}"/>
<token key="PROJECT" value="${project.name}"/>
<token key="SUMMARY" value="${project.summary}"/>
<token key="DESCRIPTION" value="${project.description}"/>
</replacetokens>
</filterchain>
<fileset refid="licensefiles"/>
</copy>
<!-- Pyrus wants README, not README.pear -->
<copy file="${releasedir}/README.pear" tofile="${releasedir}/README"/>
<!-- Create API and RELEASE files -->
<copy file="${releasedir}/API" tofile="${releasedir}/API-${version}"/>
<copy file="${releasedir}/RELEASE" tofile="${releasedir}/RELEASE-${version}"/>
<!-- Copy source code, doing token replacement on version. -->
<copy todir="${releasedir}/src">
<filterchain>
<replacetokens begintoken="%" endtoken="%">
<token key="UNSTABLE" value="${version}"/>
</replacetokens>
</filterchain>
<fileset refid="sourcecode"/>
</copy>
<!-- Copy examples. -->
<copy todir="${releasedir}/examples">
<fileset refid="examplecode"/>
</copy>
<!-- Copy tests. -->
<copy todir="${releasedir}/tests">
<fileset refid="unittests"/>
</copy>
<!-- Copy tutorials -->
<!--
<copy todir="${releasedir}/tutorials">
<fileset refid="tutorials"/>
</copy>
-->
<!-- Copy documentation -->
<copy todir="${releasedir}/doc">
<fileset refid="docs"/>
</copy>
<!-- Copy data dir -->
<copy todir="${releasedir}/data">
<fileset refid="data"/>
</copy>
<!-- Use Pyrus to create a package. -->
<pyrusmake dir="${releasedir}" packagename="${project.name}" channel="${pear.channel}"/>
<pyruspackage packagexml="${releasedir}/package.xml"/>
<!-- Add the package to the PEAR channel. -->
<move file="./${project.name}-${version}.tgz" tofile="${packagedir}/${project.name}-${version}.tgz"/>
<pirumadd targetdir="${pearchannel}" packagefile="${packagedir}/${project.name}-${version}.tgz"/>
</target>
<!-- TARGET
Check syntax of all source code files.
-->
<target name="lint" description="Check syntax of source.">
<phplint>
<fileset refid="sourcecode" />
</phplint>
</target>
<!-- TARGET
Build documentation.
Run PhpDocumentor to generate the documentation for a site.
-->
<target name="doc" depends="lint,setup" description="Generate API docs.">
<delete dir="${docsdir}"/>
<doxygen config="${doxygen.config}"/>
<!--
During documentation generation, this will replace the string -UNSTABLE% with
the release version ID. You can use this to generate documents with information
about the release they are part of.
-->
<reflexive>
<fileset refid="docs"/>
<filterchain>
<replacetokens begintoken="-" endtoken="%">
<token key="UNSTABLE" value="${version}"/>
<token key="PROJECT" value="${project.name}"/>
<token key="SUMMARY" value="${project.summary}"/>
<token key="DESCRIPTION" value="${project.description}"/>
</replacetokens>
</filterchain>
</reflexive>
</target>
<!-- TARGET
This is the tmtarget for the TextMate Phing package. This allows you to run
your phing builds from inside of TextMate.
To execute this in TextMate, use CMD-SHIFT-I.
See http://github.com/technosophos/phing-tmbundle
To set this to execute different things, simply change depends= to something else.
-->
<target name="tmtarget" depends="info" description="Target for textmate">
<echo>Executed tmtarget in build.xml.</echo>
</target>
<!-- TARGET
Run a fast test and print the results to the console.
-->
<target name="ftest" description="Run a quick unit test." depends="pretest">
<!-- Fast test. -->
<phpunit>
<formatter type="summary" usefile="no"/>
<batchtest>
<fileset refid="unittests"/>
</batchtest>
</phpunit>
</target>
<!-- TARGET
Run any necessary preliminaries before executing tests.
-->
<target name="pretest" description="tasks done before any unit testing.">
<mkdir dir="test/reports"/>
<mkdir dir="test/reports/html"/>
</target>
<!-- TARGET
Run unit tests with HTML output optimized for display inside of TextMate.
If you have Phing-TMBundle installed (http://github.com/technosophos/phing-tmbundle) then
you can press CMD-SHIFT-I to run these tests.
-->
<target name="tmtest" description="Run test, optimized for TextMate output." depends="pretest">
<phpunit>
<formatter todir="test/reports" type="xml" usefile="yes"/>
<batchtest>
<fileset refid="unittests"/>
</batchtest>
</phpunit>
<phpunitreport
infile="test/reports/testsuites.xml"
format="noframes"
todir="test/reports/html"
/>
</target>
<!-- TARGET
Run a coverage report.
Run a report to determine to what extent your code has been covered by the unit tests.
-->
<target name="coverage" depends="lint" description="Run a coverage analysis.">
<coverage-setup database="./test/db/coverage.db">
<fileset refid="sourcecode"/>
</coverage-setup>
<phpunit codecoverage="true" haltonfailure="true">
<formatter type="plain" todir="test/reports" outfile="coverage.xml"/>
<batchtest>
<fileset dir="test/Tests">
<include name="**/*Test.php"/>
</fileset>
</batchtest>
</phpunit>
<coverage-report outfile="test/reports/coverage.xml">
<report todir="test/coverage"/>
</coverage-report>
</target>
<!-- TARGET
Run a x test and format an HTML report.
This differs from tmtest in that the output for this report is more robust, designed for
detailed viewing, not viewing quickly in a pop-up window.
-->
<target name="test" depends="lint,pretest" description="Run full tests">
<mkdir dir="test/reports/html"/>
<mkdir dir="test/db"/>
<phpunit>
<formatter todir="test/reports" type="xml"/>
<batchtest>
<fileset dir="test/Tests">
<include name="**/*Test.php"/>
</fileset>
</batchtest>
</phpunit>
<phpunitreport
infile="test/reports/testsuites.xml"
format="frames"
todir="test/reports/html"
/>
</target>
<!-- TARGET
Build a documentation-only package.
This just runs the 'doc' target and then packages the output into a tar and a zip file.
-->
<target name="docBuild" description="Build a package containing just docs."
depends="setup,prebuild,doc">
<property name="releasedir" value="${builddir}/${project.name}-${version}-docs"/>
<delete dir="${releasedir}" />
<!-- Make all necessary directories. -->
<mkdir dir="${releasedir}"/>
<!-- Copy license files. -->
<copy todir="${releasedir}">
<fileset refid="licensefiles"/>
</copy>
<!-- Copy documentation -->
<copy todir="${releasedir}/doc">
<fileset refid="docs"/>
</copy>
<!-- Create tgz and zip versions. -->
<tar destfile="${packagedir}/${project.name}-${version}-docs.tgz" compression="gzip">
<fileset dir="${builddir}">
<include name="${project.name}-${version}-docs/**/*"/>
</fileset>
</tar>
<zip destfile="${packagedir}/${project.name}-${version}-docs.zip" basedir="${releasedir}"/>
</target>
<!-- TARGET
Build a Phar package.
For PHP 5.3 and up, this is another way of building a release - a much better way.
This target is not called by the default build.
-->
<target name="pharBuild" depends="setup,prebuild" description="Build a Phar package of this project.">
<property name="releasedir" value="${builddir}/${project.name}-${version}-phar" override="true"/>
<echo>${releasedir}</echo>
<delete dir="${releasedir}" />
<mkdir dir="${releasedir}"/>
<copy todir="${releasedir}">
<filterchain>
<stripphpcomments/>
<stripwhitespace/>
<replacetokens begintoken="%" endtoken="%">
<token key="UNSTABLE" value="${version}"/>
<token key="PHAR_FILENAME" value="${project.name}.phar"/>
</replacetokens>
</filterchain>
<fileset dir="${srcdir}">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${releasedir}">
<fileset refid="licensefiles"/>
</copy>
<pharpackage
destfile="${packagedir}/${project.name}-${version}.phar"
basedir="${releasedir}"
alias="${project.name}.phar">
<!-- stub="${releasedir}/basic_loader.php" -->
<fileset dir="${releasedir}">
<include name="**/**"/>
</fileset>
<metadata>
<element name="version" value="${version}" />
<element name="authors">
<element name="${project.lead}">
<element name="e-mail" value="${project.lead.email}" />
</element>
</element>
</metadata>
</pharpackage>
</target>
</project>