-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
255 lines (209 loc) · 10.6 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Phal Framework" default="dist" basedir=".">
<taskdef classname="tasks.ext.kpMinTask" name="minifyjs" />
<taskdef classname="tasks.ext.ForeachFilesetTask" name="foreachfileset" />
<property name="branch" value="${env.BRANCH}" />
<tstamp>
<format property="builddate" pattern="%Y/%m/%d %T" locale="en_US"/>
</tstamp>
<property name="version" value="${env.VERSION}" override="true" />
<property name="phalpackage" value="Phal-${version}-php${env.PHP_VERSION}"/>
<property name="samplespackage" value="Samples-${version}"/>
<property name="deliverablesdir" value="./deliverables" override="true" />
<resolvepath propertyName="absolute_deliverablesdir" file="${deliverablesdir}"/>
<property name="artifactsdir" value="${deliverablesdir}/artifacts" />
<property name="sourcesdir" value="${deliverablesdir}/sources" />
<property name="phaldir" value="${sourcesdir}/phal" override="true" />
<property name="appdir" value="${sourcesdir}/app" override="true" />
<property name="licensesdir" value="${sourcesdir}/licenses" override="true" />
<resolvepath propertyName="absolute_appdir" file="${appdir}"/>
<resolvepath propertyName="absolute_licensesdir" file="${licensesdir}"/>
<resolvepath propertyName="absolute_samplesdir" file="${samplesdir}"/>
<property name="buildlibsdir" value="./build-libs" override="true" />
<resolvepath propertyName="absolute_buildlibsdir" file="${buildlibsdir}"/>
<property name="phalpackagedir" value="${deliverablesdir}/${phalpackage}" override="true" />
<resolvepath propertyName="absolute_phalpackagedir" file="${phalpackagedir}"/>
<property name="samplespackagedir" value="${deliverablesdir}/${samplespackage}" override="true" />
<resolvepath propertyName="absolute_samplespackagedir" file="${samplespackagedir}"/>
<property name="phaldelivdir" value="${phalpackagedir}/phal" />
<property name="appdelivdir" value="${phalpackagedir}/app" />
<resolvepath propertyName="absolute_phaldelivdir" file="${phaldelivdir}"/>
<property name="phplemondir" value="${phaldelivdir}/util/Parsers" />
<fileset dir="./phal" id="phal">
<include name="**" />
</fileset>
<fileset dir="./app" id="app">
<include name="**" />
</fileset>
<fileset dir="./licenses" id="licenses">
<include name="**" />
</fileset>
<!-- *********************************************************** -->
<!-- COMMON TASKS PREVIOUS TO BUILD -->
<!-- *********************************************************** -->
<target name="prepare">
<echo msg="Preparing directory structure..." />
<delete dir="${deliverablesdir}" includeemptydirs="true" verbose="false" failonerror="true" />
<mkdir dir="${deliverablesdir}" />
<delete dir="${sourcesdir}" includeemptydirs="true" verbose="false" failonerror="true" />
<mkdir dir="${sourcesdir}" />
<echo msg="Copying files to the sources directory..." />
<copy todir="${phaldir}">
<fileset refid="phal" />
</copy>
<copy todir="${appdir}">
<fileset refid="app" />
</copy>
<copy todir="${licensesdir}">
<fileset refid="licenses" />
</copy>
<echo msg="Assigning permissions to source copies..." />
<exec command="find . -type f -print0 |xargs -0 chmod 777" dir="${sourcesdir}" />
<echo msg="Copying phal source to phal deliverable dir..." />
<delete dir="${phalpackagedir}" includeemptydirs="true" verbose="false" failonerror="true" />
<mkdir dir="${phalpackagedir}" />
<!-- copy phal to deliverables directory -->
<copy todir="${phaldelivdir}">
<fileset dir="${phaldir}"/>
</copy>
<!-- copy empty app to deliverables directory -->
<copy todir="${appdelivdir}">
<fileset dir="${appdir}"/>
</copy>
<copy file="${phaldelivdir}/configuration/defaultvalues/settings.ini" tofile="${appdelivdir}/config/settings.ini"/>
<copy file="${phaldelivdir}/configuration/defaultvalues/phal.ini" tofile="${appdelivdir}/phal.ini"/>
<copy file="${phaldelivdir}/phar-stub.php" tofile="${phalpackagedir}/phar-stub.php"/>
<!-- configure settings.ini -->
<reflexive>
<fileset dir="${appdelivdir}/config" >
<include name="settings.ini" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="resources\/forms" replace="app/forms" ignoreCase="true"/>
</replaceregexp>
</filterchain>
</reflexive>
<copy todir="${phaldelivdir}/thrdparty-licenses">
<fileset refid="licenses" />
</copy>
<exec command="find . -type f -print0 |xargs -0 chmod 644" dir="${phaldelivdir}" />
<exec command="find . -type d -print0 |xargs -0 chmod 755" dir="${phaldelivdir}" />
<echo msg="Done!" />
</target>
<!-- *********************************************************** -->
<!-- BUILD PHAL -->
<!-- *********************************************************** -->
<target name="buildphal" depends="prepare">
<echo msg="Minifying javascript and css files..." />
<minifyjs targetDir="${phaldelivdir}"
yuiPath="build-libs/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar">
<fileset dir="${phaldelivdir}">
<include name="**/*.js"/>
<include name="**/*.css"/>
<exclude name="**/jscalendar/lang/calendar-*.js"/>
</fileset>
</minifyjs>
<minifyjs targetDir="${appdelivdir}"
yuiPath="build-libs/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar">
<fileset dir="${appdelivdir}">
<include name="**/*.js"/>
<include name="**/*.css"/>
<exclude name="**/jscalendar/lang/calendar-*.js"/>
</fileset>
</minifyjs>
<echo msg="Compiling REInverseParser and ComponentParser..." />
<delete>
<fileset dir="${phplemondir}">
<include name="*.php" />
</fileset>
</delete>
<exec command="chmod 755 phplemon" dir="${phplemondir}" />
<exec command="chmod 755 phplexer" dir="${phplemondir}" />
<exec command="./phplemon REInverseParser.class.y" dir="${phplemondir}"/>
<exec command="./phplexer REInverseLexer.class.plex" dir="${phplemondir}"/>
<exec command="./phplemon ComponentParser.class.y" dir="${phplemondir}"/>
<exec command="./phplexer ComponentLexer.class.plex" dir="${phplemondir}"/>
<copy file="${phplemondir}/REInverseLexer.class.php" tofile="${phaldelivdir}/requestdispatcher/urlroutingengine/REInverseLexer.class.php" />
<copy file="${phplemondir}/REInverseParser.class.php" tofile="${phaldelivdir}/requestdispatcher/urlroutingengine/REInverseParser.class.php" />
<copy file="${phplemondir}/ComponentLexer.class.php" tofile="${phaldelivdir}/mvc/componentmodel/parser/ComponentLexer.class.php" />
<copy file="${phplemondir}/ComponentParser.class.php" tofile="${phaldelivdir}/mvc/componentmodel/parser/ComponentParser.class.php" />
<reflexive>
<fileset dir="${phalpackagedir}" >
<include name="phal/core/Constants.inc" />
<include name="phal/phal.php" />
<include name="app/templates/index.tpl" />
<include name="README" />
</fileset>
<filterchain>
<replacetokens begintoken="[" endtoken="]">
<token key="version" value="${version}" />
<token key="changelist" value="${env.CHANGELIST}" />
<token key="builddate" value="${builddate}" />
<token key="branch" value="${branch}" />
</replacetokens>
</filterchain>
</reflexive>
<reflexive>
<fileset dir="${phalpackagedir}" >
<include name="app/index.php" />
</fileset>
<filterchain>
<replacetokens begintoken="[" endtoken="]">
<token key="phalphar" value="${phalpackage}.phar" />
</replacetokens>
</filterchain>
</reflexive>
<exec command="perl ${buildlibsdir}/common/generate_docblock_headers.pl ${phaldelivdir} ${buildlibsdir}/common/header_docblock.txt ${version}" dir="." passthru="true"/>
<delete dir="${phaldelivdir}/util/Parsers/" includeemptydirs="true" verbose="true" failonerror="true" />
<exec command="find . -type f -print0 |xargs -0 chmod 644" dir="${phalpackagedir}" />
<exec command="find . -type d -print0 |xargs -0 chmod 755" dir="${phalpackagedir}" />
<echo msg="Done!" />
</target>
<!-- *********************************************************** -->
<!-- PACKAGE ALL DELIVERABLES -->
<!-- *********************************************************** -->
<target name="packageall">
<echo msg="Packaging deliverables..." />
<mkdir dir="${artifactsdir}" />
<tar destfile="${artifactsdir}/${phalpackage}.tgz" basedir="${deliverablesdir}" compression="gzip">
<fileset dir="${deliverablesdir}">
<include name="${phalpackage}" />
</fileset>
</tar>
<pharpackage
basedir="${absolute_phalpackagedir}"
destfile="${artifactsdir}/${phalpackage}.phar"
webstub="${phalpackagedir}"
clistub="${phalpackagedir}"
stub="${phalpackagedir}/phar-stub.php"
alias="${phalpackage}.phar"
>
<fileset dir="${deliverablesdir}">
<include name="${phalpackage}/**" />
</fileset>
<metadata>
<element name="version" value="${version}" />
<element name="authors">
<element name="Antonio Parraga Navarro">
<element name="e-mail" value="[email protected]" />
</element>
</element>
</metadata>
</pharpackage>
<zip destfile="${artifactsdir}/${phalpackage}.zip" basedir="${deliverablesdir}">
<fileset dir="${deliverablesdir}">
<include name="${phalpackage}/**" />
</fileset>
</zip>
<echo msg="Done!" />
</target>
<!-- *********************************************************** -->
<!-- BUILD ALL -->
<!-- *********************************************************** -->
<target name="dist">
<phingcall target="buildphal" />
<phingcall target="packageall" />
<echo msg="Build completed!" />
</target>
</project>