[go: up one dir, main page]

Menu

[cfa9b7]: / build.xml  Maximize  Restore  History

Download this file

430 lines (376 with data), 18.0 kB

  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
<project name = "R Package builder" default = "all" basedir=".">
<property environment = "env" />
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd" />
</tstamp>
<condition property="hostname" value="${env.COMPUTERNAME}" else="${env.HOSTNAME}" >
<os family="windows" />
</condition>
<property name = "user.property.file" value="${hostname}.properties" />
<echo message="Inferring your personal property file: ${user.property.file}" />
<echo message="Inferring your personal property file: ${user.property.file}" />
<available file="${basedir}/${user.property.file}" type="file" property="user.property.found" value="true" />
<condition property="message.property.file"
value="${user.property.file},default.properties"
else="default.properties" >
<equals arg1="${user.property.found}" arg2="true"/>
</condition>
<condition property="foo.message.001" value="found" else="not found" >
<equals arg1="${user.property.found}" arg2="true"/>
</condition>
<echo message="The personal ${user.property.file} is ${foo.message.001}." />
<echo message="The build process will use: ${message.property.file} " />
<property file="${basedir}/${user.property.file}" />
<property file="${basedir}/default.properties" />
<property name="package.version" value="${major.version}.${minor.version}"/>
<property name="build.number" value="${env.BUILD_NUMBER}"/>
<fail message="package.src.dir is not set! Please set package.src.dir to the relative path of package source directory" >
<condition>
<not>
<isset property="package.src.dir" />
</not>
</condition>
</fail>
<loadresource property="package.name" >
<file file="${basedir}/${package.src.dir}/DESCRIPTION"/>
<filterchain>
<!-- ensure delimOutput is set to empty, or \n will be appended to the string -->
<tokenfilter delimOutput="">
<containsregex pattern="^Package:\s*(.*)\s*$" replace="\1"/>
</tokenfilter>
</filterchain>
</loadresource>
<property name="artefact.basename" value="${package.name}_${package.version}" />
<property name="build.dir" value="${basedir}/.__workingspace"/>
<property name="artefact.dir" value="${basedir}/.__artefacts" />
<property name = "artifacts" value="${artefact.basename}.zip,${artefact.basename}*.tar.gz"/>
<property name="sweave.doc.path" value="${package.src.dir}/vignettes" />
<property name="sweave.doc.name" value="${package.name}.Rnw" />
<property name="PATH" value="${r.home}/bin;${rtools.home}/bin;${miktex.home}/bin"/>
<!-- path can be overridden in the property files -->
<!--condition property = "path" value = "${env.Path}" else = "${env.PATH}" >
<os family="windows" />
</condition>
<property name = "local.lib" value = "${local.lib}" />
<echo message = "PATH setting: ${path} " /-->
<!-- target.os.arch can be overridden in property files -->
<condition property="target.os.arch" value="x86" else="x64" >
<os arch="x86" />
</condition>
<echo message = "Arch : ${target.os.arch} " />
<available file="${r.home}/bin/x64" type="dir" property="r.64.bit.installed" value="true" />
<!-- build.with.64.bit.r can also be forced in property files -->
<condition property="build.with.64.bit.r" value="true" else="false" >
<and>
<equals arg1="${target.os.arch}" arg2="x64" />
<!--equals arg1="${force.run.with.64.bit.r}" arg2="true" /-->
<equals arg1="${r.64.bit.installed}" arg2="true" />
</and>
</condition>
<condition property="r.arch.dep.path" value="/x64/" else="/" >
<equals arg1="${build.with.64.bit.r}" arg2="true" />
</condition>
<condition property="build.options.vignettes" value="" else="--no-build-vignettes" >
<equals arg1="${build.vignette}" arg2="true" />
</condition>
<target name="clean">
<delete dir ="${local.lib}" failonerror = "true"/>
<mkdir dir ="${local.lib}" />
<!-- Remove man dir-->
<delete dir ="${package.name}/man" failonerror = "false"/>
<delete dir="${build.dir}"/>
<delete dir="${artefact.dir}"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${artefact.dir}"/>
<copy todir="${build.dir}" overwrite="true">
<fileset dir="${basedir}">
<exclude name=".*/**"/>
<exclude name="build.xml"/>
<exclude name="**/.svn/**"/>
<exclude name="**/.*"/>
</fileset>
</copy>
</target>
<target name ="buildEnv" depends="clean">
<exec executable = "${r.home}/bin${r.arch.dep.path}Rscript" dir="${build.dir}" failonerror = "true">
<env key = "R_LIBS" value="${local.lib}"/>
<!--env key = "PATH" value="${PATH}"/-->
<arg value = "--vanilla"/>
<arg value = "--quiet"/>
<arg value = "--slave"/>
<arg value = "--file=buildEnv.R" />
<arg value = "--args"/>
<arg value = "${package.name}"/>
<arg value = "${output.folder}"/>
</exec>
</target>
<target name="collect.artefacts">
<copy todir="${artefact.dir}" overwrite="true">
<fileset dir="${build.dir}" includes="${artifacts},*.tar.gz,*.zip,*.html,*.xml" excludes="build*.xml"/>
</copy>
</target>
<condition property="package.has.vignette.source.file.and.need.build.vignette" value="true">
<and>
<equals arg1="${build.vignette}" arg2="true"/>
<resourcecount when="gt" count="0" >
<fileset dir="${basedir}/${package.src.dir}" >
<include name="vignettes/*.Rnw"/>
</fileset>
</resourcecount>
</and>
</condition>
<target name="collect.vignette" if="package.has.vignette.source.file.and.need.build.vignette">
<copy todir="${artefact.dir}" overwrite="true">
<fileset dir="${local.lib}/${package.name}/doc" includes="*.pdf" />
</copy>
</target>
<target name="collect" depends='unitTests,collect.artefacts,collect.vignette' >
<echo message="Build Success, artefacts collected to ${artefact.dir}"/>
</target>
<condition property="tag.svn.version" value=" (SVN ver. ${env.SVN_REVISION})" else="">
<and>
<isset property="env.SVN_REVISION" />
<equals arg1="${add.svn.tag}" arg2="true"/>
</and>
</condition>
<property name="windows.line.separator" value="&#13;&#10;"/>
<property name="unix.line.separator" value="&#10;"/>
<target name ="updateDescFile" depends='buildEnv'>
<copy file="${basedir}/${package.src.dir}/DESCRIPTION"
tofile="${build.dir}/${package.src.dir}/DESCRIPTION" overwrite="true" >
<filterchain>
<replaceregex pattern="^(Version:)(.*)$" replace="\1 ${package.version}" flags="m"/>
<replaceregex pattern="^(Date:)(.*)$" replace="\1 ${TODAY}" flags="m"/>
<!-- Provide the Jenkins build number in the DESCRIPTION file -->
<replaceregex pattern="^(Build-Number:)(.*)$" replace="\1 ${build.number}" flags="m"/>
</filterchain>
</copy>
<!-- Description can have multiple line with ^\s+ as continuation of line -->
<loadresource property="foo.tmp.002" >
<file file="${build.dir}/${package.src.dir}/DESCRIPTION" />
<filterchain>
<tokenfilter>
<filetokenizer/>
<!-- \s can be space or tab -->
<replaceregex pattern="${windows.line.separator}(\s)"
replace="___WINDOWSLINECONTINUATION{\1}___" flags="sg"/>
<!-- make sure windows line sep is before unix line sep -->
<replaceregex pattern="${unix.line.separator}(\s)"
replace="___UNIXLINECONTINUATION{\1}___" flags="sg"/>
</tokenfilter>
<tokenfilter>
<replaceregex pattern="^(Description:)(.*)$"
replace="\1\2${tag.svn.version}" flags="m"/>
</tokenfilter>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="___UNIXLINECONTINUATION\{(.)\}___"
replace="${unix.line.separator}\1" flags="sg"/>
<replaceregex pattern="___WINDOWSLINECONTINUATION\{(\s)\}___"
replace="${windows.line.separator}\1" flags="sg"/>
</tokenfilter>
</filterchain>
</loadresource>
<echo message="${foo.tmp.002}" file="${build.dir}/${package.src.dir}/DESCRIPTION"/>
<echo message=" Description updated " />
</target>
<condition property='force.docgen.flag' value='true' >
<and>
<isset property='force.docgen' />
<equals arg1="${force.docgen}" arg2="true" />
</and>
</condition>
<target name='roxygen' depends='clean,updateDescFile,buildEnv' if='force.docgen.flag'>
<echo message="Rd documents being generated." />
<exec executable="${r.home}/bin${r.arch.dep.path}Rscript" dir="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg value ="${rdgen.script}" />
<arg value ="${package.src.dir}" />
</exec>
<echo message="Rd documents generated." />
</target>
<condition property="resave.data.option" value="--resave-data=${resave.data}"
else="--resave-data=no" >
<isset property="resave.data" />
</condition>
<!-- build the tar.gz file -->
<target name ="build" depends='clean,updateDescFile,roxygen'>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD build ${resave.data.option} ${build.options.vignettes} ${package.src.dir}'/>
</exec>
</target>
<condition property="data.compress.option" value="--data-compress=${data.compress}"
else="--data-compress=none" >
<isset property="data.compress" />
</condition>
<!-- for developer writing and check vignette docs only -->
<target name ="build.vignette.only" >
<copy todir="${build.dir}" overwrite="true">
<fileset dir="${basedir}">
<include name="**/vignettes/**"/>
<exclude name=".*/**"/>
<exclude name="build.xml"/>
<exclude name="**/.svn/**"/>
<exclude name="**/.*"/>
</fileset>
</copy>
<!-- The following R started in .__rlibs, we need to clean it first -->
<delete dir="${local.lib}/${package.name}" />
<mkdir dir="${r.local.libs.user}"/>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD build ${resave.data.option} ${package.src.dir}'/>
</exec>
<echo message="${artefact.basename}.tar.gz"/>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD INSTALL --build ${data.compress.option} ${artefact.basename}.tar.gz'/>
</exec>
</target>
<!-- create sweaved.tex.doc and sweaved.output.doc if not given -->
<loadresource property="sweaved.tex.doc">
<propertyresource name="sweave.doc.name"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="^(.*)\..*$" replace="\1.tex"/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="sweaved.output.doc">
<propertyresource name="sweave.doc.name"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="^(.*)\..*$" replace="\1.pdf"/>
</tokenfilter>
</filterchain>
</loadresource>
<!-- create tex and code chunk for debugging purpose -->
<target name="sweave">
<copy todir="${build.dir}" overwrite="true">
<fileset dir="${basedir}">
<include name="${sweave.doc.path}/**"/>
<exclude name=".*/**"/>
<exclude name="build.xml"/>
<exclude name="**/.svn/**"/>
<exclude name="**/.*"/>
</fileset>
</copy>
<!-- need Sweave.sty -->
<copy todir="${build.dir}">
<fileset dir="${r.home}/share/texmf/tex/latex">
<include name="*.sty"/>
</fileset>
</copy>
<!-- The following R started in .__rlibs, we need to clean it first -->
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD Stangle ${sweave.doc.path}/${sweave.doc.name}'/>
</exec>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD Sweave ${sweave.doc.path}/${sweave.doc.name}'/>
</exec>
</target>
<!-- yet another debug purpose -->
<target name="latex">
<exec executable="${miktex.home}/bin/pdflatex.exe" dir="${build.dir}" failonerror = "true">
<arg line ='${sweaved.tex.doc}'/>
</exec>
</target>
<target name="tex" depends="sweave,latex">
<copy todir="${artefact.dir}" overwrite="true" >
<fileset dir="${build.dir}" includes="${sweaved.output.doc}"/>
</copy>
</target>
<target name ="vignette" depends='build.vignette.only,collect.vignette'>
<echo message=" Vignette generated " />
</target>
<!-- deploy to library path in ${deploy.lib.path} -->
<condition property="deploy.lib.option" value='--library="${deploy.lib.path}"' else="">
<and>
<isset property="deploy.lib.path" />
<available file="${deploy.lib.path}" type="dir"/>
</and>
</condition>
<target name='deploy.only'>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${artefact.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="PATH" value="${PATH}"/>
<env key="R_LIBS" value="${local.lib}"/>
<arg line="CMD"/>
<arg line="INSTALL"/>
<arg line="${data.compress.option}"/>
<arg line="${deploy.lib.option}"/>
<arg line="${artefact.basename}.zip"/>
</exec>
</target>
<target name="all" depends='unitTests,collect.artefacts,collect.vignette,deploy.only' >
<echo message="Build Success, artefacts collected to ${artefact.dir}"/>
<condition property="deploy.lib.message" value='artefact is installed to ${deploy.lib.path}'
else="artefact is installed to R default library path">
<and>
<isset property="deploy.lib.path" />
<available file="${deploy.lib.path}" type="dir"/>
</and>
</condition>
<echo message="${deploy.lib.message}"/>
</target>
<target name = 'deploy' depends='buildzip,collect.artefacts,collect.vignette,deploy.only'>
<echo message='Package ${package.name} Installed successfully.'/>
</target>
<condition property="multiarch.option" value="--force-biarch" else="--no-multiarch">
<and>
<os family="windows" />
<equals arg1="${build.with.64.bit.r}" arg2="true" />
<equals arg1="${force.multiarch}" arg2="true" />
</and>
</condition>
<condition property="byte.compile.option" value="--byte-compile" else="">
<equals arg1="${byte.compile}" arg2="true" />
</condition>
<!-- ensure vignette are built -->
<target name ='buildzip' depends='build'>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line="CMD"/>
<arg line="INSTALL"/>
<arg line="--build"/>
<arg line="${artefact.basename}.tar.gz"/>
</exec>
</target>
<!-- we always assume build on windows -->
<target name ='unitTests' depends='buildzip' unless="skip.unit.tests">
<exec executable = "${r.home}/bin${r.arch.dep.path}Rscript" dir="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='${test.script}'/>
<arg line ='${build.dir}/${artefact.basename}.tar.gz'/>
</exec>
</target>
<target name ="rcheck" depends='clean,roxygen, unitTests'>
<exec executable="${r.home}/bin${r.arch.dep.path}R" dir ="${build.dir}" failonerror = "true">
<env key="R_HOME" value="${r.home}"/>
<env key="R_LIBS" value="${local.lib}"/>
<env key="PATH" value="${PATH}"/>
<arg line ='CMD check ${package.src.dir}'/>
</exec>
</target>
</project>