gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Ant - add logging of transformed program testing
[mjc2wsl.git] / build.xml
1 <project name="mjc2wsl" default="all">
2 <property file="custom.properties"/>
3 <property environment="env"/>
5 <condition property="fermat.dir" value="C:\fermat3">
6 <os family="windows" />
7 </condition>
9 <condition property="fermat.dir" value="${user.home}/fermat3">
10 <not><os family="windows" /></not>
11 </condition>
14 <property name="java.encoding" value="utf-8" />
15 <taskdef resource="net/sf/antcontrib/antlib.xml"/>
17 <!-- when using multiple threads there is a problem with logging!-->
18 <property name="global.max.threads" value="1" />
20 <property name="mjc2wsl.class.dir" value="bin" />
21 <property name="mjc2wsl.src.dir" value="src" />
22 <property name="mjc2wsl.options" value="" />
24 <property name="res.dir" value="res" />
26 <property name="compiler.class.jar" value="lib/mj.jar" />
27 <property name="compiler.class.dir" value="lib/compiler-bin" />
28 <property name="compiler.src.dir" value="lib/compiler-src" />
29 <property name="compiler.classname.compiler" value="MJ.Compiler" />
30 <property name="compiler.classname.interpreter" value="MJ.Run" />
31 <property name="compiler.classname.decoder" value="MJ.Decode" />
33 <property name="samples.main.dir" value="samples" />
34 <property name="samples.temp.dir" value="temp" />
36 <property name="transf.wsl.file" value="src-wsl/transf-min.wsl" />
37 <property name="transf.wsl.ini" value="transf.ini" />
38 <property name="transf.wsl.ext" value="_t.wsl" />
40 <property name="tests.dir" value="tests" />
42 <property name="log.dir" value="logs" />
43 <property name="log.file.transformations" value="${log.dir}/transformations" />
44 <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
45 <property name="log.file.tests.m" value="${log.dir}/tests-mj" />
46 <property name="log.file.tests.t" value="${log.dir}/tests-wsl" />
48 <description>
49 Builder script for mjc2wsl and related tools, runs test
50 on given samples.
52 Also gives options to chain the tools on individual files.
53 </description>
55 <patternset id="non.transformed.sources">
56 <include name="**/*.wsl"/>
57 <exclude name="**/*${transf.wsl.ext}"/>
58 </patternset>
60 <!-- general tasks -->
62 <target name="init" depends="init-time">
63 <mkdir dir="${mjc2wsl.class.dir}"/>
64 <mkdir dir="${compiler.class.dir}"/>
65 <mkdir dir="${samples.temp.dir}"/>
66 <mkdir dir="${log.dir}"/>
67 <copy todir="${samples.temp.dir}">
68 <fileset dir="${samples.main.dir}">
69 <include name="*.mj"/>
70 </fileset>
71 </copy>
72 </target>
74 <target name="init-time">
75 <tstamp>
76 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
77 </tstamp>
78 </target>
80 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
81 description="build the tools, run them on the samples to check">
83 </target>
85 <target name="clean" description="clean up all the generated content">
86 <delete includeemptydirs="true">
87 <fileset dir="${mjc2wsl.class.dir}"/>
88 <fileset dir="${compiler.class.dir}"/>
89 <fileset dir="${samples.temp.dir}"/>
90 <fileset dir="${log.dir}"/>
91 </delete>
92 </target>
94 <!-- version tasks
95 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
97 <!-- this target is only run if the 'version' property is undefined -->
99 <target name="update-version-string" unless="version">
100 <!-- get a new version string using git describe if possible -->
101 <echo message="Updating version string..."/>
102 <exec executable="git" outputproperty="version"
103 failifexecutionfails="false">
104 <arg value="describe"/>
105 </exec>
106 <antcall target="-store-version-string"/>
107 <!-- ensure version is defined even if git was not available -->
108 <property file="${res.dir}/version.properties"/>
109 </target>
111 <target name="-store-version-string" if="version">
112 <!-- store the new version string in the correct property file -->
113 <echo message="version=${version}"/>
114 <propertyfile file="${res.dir}/version.properties">
115 <entry key="version" value="${version}"/>
116 </propertyfile>
117 <exec executable="git" failifexecutionfails="false">
118 <arg value="update-index"/>
119 <arg value="--assume-unchanged"/>
120 <arg value="${res.dir}/version.properties"/>
121 </exec>
122 </target>
124 <!-- mjc2wsl related tasks -->
126 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
127 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
128 </target>
130 <target name="mjc2wsl">
131 <echo message="${filename}" />
132 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
133 <arg line="${mjc2wsl.options}" />
134 <arg value="${filename}" />
135 </java>
136 </target>
138 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
139 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
140 <echo>Used options:${mjc2wsl.options}</echo>
141 <foreach param="filename" target="mjc2wsl" parallel="true" maxthreads="${global.max.threads}">
142 <path>
143 <fileset dir='${samples.temp.dir}'>
144 <include name="*.obj"/>
145 </fileset>
146 </path>
147 </foreach>
148 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
149 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
150 </target>
152 <target name="mjc2wsl-samples1" depends="build">
153 <!-- simplistic version when antlib (foreach) is not available -->
154 <antcall target="mjc2wsl">
155 <param name="filename" value="samples-temp/sample0.obj" />
156 </antcall>
157 </target>
160 <!-- MicroJava related tasks -->
163 <target name="mj-build" depends="init" description="build the mj compiler">
164 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
165 </target>
167 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
168 <echo message="${filename}" />
169 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
170 <arg value="${filename}" />
171 </java>
172 </target>
174 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
175 <foreach param="filename" target="mj-compile" parallel="true" maxthreads="${global.max.threads}">
176 <path>
177 <fileset dir='${samples.temp.dir}'>
178 <include name="*.mj"/>
179 </fileset>
180 </path>
181 </foreach>
182 </target>
184 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
185 <echo message="${filename}" />
186 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
187 classname="${compiler.classname.decoder}"
188 output="${filename}.decoded" >
189 <arg value="${filename}" />
190 </java>
191 </target>
193 <target name="mj-decode-samples" description="decode all of the obj files in ${samples.temp.dir}">
194 <foreach param="filename" target="mj-decode">
195 <path>
196 <fileset dir='${samples.temp.dir}'>
197 <include name="*.obj"/>
198 </fileset>
199 </path>
200 </foreach>
201 </target>
203 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
204 <echo message="${filename}" />
205 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
206 <arg value="${filename}" />
207 </java>
208 </target>
210 <target name="mj-samples1" depends="mj-build">
211 <!-- simplistic version when antlib (foreach) is not available -->
212 <antcall target="mj-compile">
213 <param name="filename" value="samples-temp/sample.mj" />
214 </antcall>
215 <antcall target="mj-compile">
216 <param name="filename" value="samples-temp/sample1.mj" />
217 </antcall>
218 <antcall target="mj-compile">
219 <param name="filename" value="samples-temp/sample0.mj" />
220 </antcall>
221 </target>
224 <!-- wsl related tasks -->
226 <target name="wsl-run" >
227 <property name="args" value=""/>
228 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
229 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
230 <env key="FermaT" path="${fermat.dir}" />
231 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
232 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
233 <arg line="${filename} ${args}"/>
234 </exec>
235 </target>
237 <target name="wsl-transf"
238 description="transform (simplify) a single wsl file generated by mjc2wsl">
240 <antcall target="wsl-run">
241 <param name="filename" value="${transf.wsl.file}" />
242 <param name="args" value="${transf.filename}" />
243 </antcall>
244 </target>
246 <target name="wsl-transf-samples" depends="init"
247 description="transform (simplify) the wsl files generated by mjc2wsl" >
248 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
249 <foreach param="transf.filename" target="wsl-transf" parallel="true" maxthreads="${global.max.threads}">
250 <path>
251 <fileset dir='${samples.temp.dir}'>
252 <patternset refid="non.transformed.sources"/>
253 </fileset>
254 </path>
255 </foreach>
256 <record name="${log.file.transformations}${time}.txt" action="stop" />
257 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
258 </target>
260 <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
261 description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
262 <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
263 <antcall target="wsl-run">
264 <param name="filename" value="${transf.wsl.file}" />
265 </antcall>
266 <record name="${log.file.transformations}${time}i.txt" action="stop" />
267 <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
268 </target>
270 <target name="make-transf-ini-samples">
271 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
272 <patternset refid="non.transformed.sources"/>
273 </fileset>
274 <pathconvert pathsep="${line.separator}"
275 property="generated-wsl-files" refid="generated-wsl-fileset" />
277 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
278 </target>
280 <!-- Testing tasks -->
282 <target name="manual-test-run"
283 description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
284 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
285 <antcall target="mj-run">
286 <param name="filename" value="${file.dir}/${file.name}.obj" />
287 <param name="inputstring" value="${inputstring}" />
288 </antcall>
289 <record name="${file.dir}/${file.name}.out1" action="stop" />
290 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
291 <antcall target="wsl-run">
292 <param name="filename" value="${file.dir}/${file.name}.wsl" />
293 <param name="inputstring" value="${inputstring}" />
294 </antcall>
295 <record name="${file.dir}/${file.name}.out2" action="stop" />
296 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
297 <antcall target="wsl-run">
298 <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
299 <param name="inputstring" value="${inputstring}" />
300 </antcall>
301 <record name="${file.dir}/${file.name}.out3" action="stop" />
302 </target>
304 <target name="manual-test-run-samples-dir"
305 description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
306 <antcall target="manual-test-run">
307 <param name="file.dir" value="${samples.temp.dir}"/>
308 </antcall>
309 </target>
311 <target name="init-compare">
312 <mkdir dir="${samples.temp.dir}/outputs"/>
313 </target>
315 <target name="test-m-w">
317 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
319 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
320 classname="${compiler.classname.interpreter}"
321 input="${inputfile}"
322 error="${samples.temp.dir}/outputs/${file.out}.errmj"
323 output="${samples.temp.dir}/outputs/${file.out}.outmj">
324 <arg value="${file.dir}/${file.name}.obj" />
325 </java>
327 <exec executable="${fermat.dir}/bin/wsl"
328 input="${inputfile}"
329 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
330 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
331 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
332 <env key="FermaT" path="${fermat.dir}" />
333 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
334 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
335 <arg value="${file.dir}/${file.name}.wsl"/>
336 </exec>
338 <exec executable="perl" resultproperty="ook">
339 <arg value="lib/compare-m-w.pl"/>
340 <arg value="${file.dir}/outputs"/>
341 <arg value="${file.out}"/>
342 </exec>
344 </target>
346 <target name="test-w-wt">
348 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
350 <exec executable="${fermat.dir}/bin/wsl"
351 input="${inputfile}"
352 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
353 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
354 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
355 <env key="FermaT" path="${fermat.dir}" />
356 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
357 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
358 <arg value="${file.dir}/${file.name}.wsl"/>
359 </exec>
361 <exec executable="${fermat.dir}/bin/wsl"
362 input="${inputfile}"
363 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
364 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
365 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
366 <env key="FermaT" path="${fermat.dir}" />
367 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
368 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
369 <arg value="${file.dir}/${file.name}${transf.wsl.ext}"/>
370 </exec>
372 <exec executable="perl">
373 <arg value="lib/compare-w-wt.pl"/>
374 <arg value="${file.dir}/outputs"/>
375 <arg value="${file.out}"/>
376 </exec>
377 </target>
379 <target name="test-fn">
380 <basename property="file.name" file="${filename}" suffix=".obj"/>
381 <dirname property="file.dir" file="${filename}"/>
382 <foreach param="inputfile" target="test-m-w" inheritall="true">
383 <path>
384 <fileset dir='${tests.dir}'>
385 <include name="${file.name}*.txt"/>
386 </fileset>
387 </path>
388 </foreach>
389 </target>
391 <target name="test-fn-t">
392 <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
393 <dirname property="file.dir" file="${filename}"/>
394 <foreach param="inputfile" target="test-w-wt" inheritall="true">
395 <path>
396 <fileset dir='${tests.dir}'>
397 <include name="${file.name}*.txt"/>
398 </fileset>
399 </path>
400 </foreach>
401 </target>
403 <target name="test-all-m" depends="init-compare,init-time"
404 description="Run all the tests from the test directory to compare MJ and WSL" >
405 <record name="${log.file.tests.m}${time}.txt" emacsmode="true" />
406 <foreach param="filename" target="test-fn" inheritall="true">
407 <path>
408 <fileset dir='${samples.temp.dir}'>
409 <include name="*.obj"/>
410 </fileset>
411 </path>
412 </foreach>
413 <record name="${log.file.tests.m}${time}.txt" action="stop" />
414 <move file="${log.file.tests.m}.txt" tofile="${log.file.tests.m}-previous.txt" failonerror="false"/>
415 <copy file="${log.file.tests.m}${time}.txt" tofile="${log.file.tests.m}.txt"/>
416 </target>
418 <target name="test-all-t" depends="init-compare,init-time"
419 description="Run all the tests from the test directory to compare WSL and transformations" >
420 <record name="${log.file.tests.t}${time}.txt" emacsmode="true" />
421 <foreach param="filename" target="test-fn-t">
422 <path>
423 <fileset dir='${samples.temp.dir}'>
424 <include name="*${transf.wsl.ext}"/>
425 </fileset>
426 </path>
427 </foreach>
428 <record name="${log.file.tests.t}${time}.txt" action="stop" />
429 <move file="${log.file.tests.t}.txt" tofile="${log.file.tests.t}-previous.txt" failonerror="false"/>
430 <copy file="${log.file.tests.t}${time}.txt" tofile="${log.file.tests.t}.txt"/>
431 </target>
433 <target name="q-test">
434 <!-- for quick tests -->
435 <antcall target="test-fn">
436 <param name="file.name" value="Rek1"/>
437 <param name="file.dir" value="${samples.temp.dir}"/>
438 </antcall>
439 </target>
441 <!-- output serveral versions of files -->
443 <target name="output-all-versions"
444 description="generate variations on the translations in the 'local' folder and tar them">
445 <antcall>
446 <target name="mj-samples"/>
447 <target name="mjc2wsl-samples"/>
448 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
449 <param name="mjc2wsl.options" value=""/>
450 </antcall>
451 <antcall>
452 <target name="mj-samples"/>
453 <target name="mjc2wsl-samples"/>
454 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
455 <param name="mjc2wsl.options" value="--genInlinePrint"/>
456 </antcall>
457 <antcall>
458 <target name="mj-samples"/>
459 <target name="mjc2wsl-samples"/>
460 <param name="samples.temp.dir" value="local/out/popPush-inline"/>
461 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
462 </antcall>
463 <antcall>
464 <target name="mj-samples"/>
465 <target name="mjc2wsl-samples"/>
466 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
467 <param name="mjc2wsl.options" value="--genPopPush"/>
468 </antcall>
469 <antcall>
470 <target name="mj-samples"/>
471 <target name="mjc2wsl-samples"/>
472 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
473 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
474 </antcall>
475 <tar basedir="local/out" compression="gzip"
476 destfile="local/mjc2wsl-samples.tgz"
477 includes="*/*.wsl"/>
478 </target>
481 <!-- output a comparison Latex file and compile it -->
483 <target name="output-comparison-pdf-single">
484 <basename property="file.name" file="${filename}" suffix=".obj"/>
485 <echo append='true' file="${samples.temp.dir}/tex/comparison.tex">
486 \section{${file.name}}
487 \begin{paracol}{4}
488 \lstinputlisting[style=mj]{../${file.name}.mj}
489 \switchcolumn
490 \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
491 \switchcolumn
492 \lstinputlisting[style=wsl,lastline=200]{../${file.name}.wsl}
493 \switchcolumn
494 \lstinputlisting[style=wslt,lastline=200]{../${file.name}${transf.wsl.ext}}
495 \end{paracol}
496 </echo>
497 </target>
499 <target name="output-comparison-pdf"
500 description="Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
502 <copy file="lib/tex/comparison-start.tex" overwrite="true"
503 tofile="${samples.temp.dir}/tex/comparison.tex"/>
504 <foreach param="filename" target="output-comparison-pdf-single" inheritall="true">
505 <path>
506 <fileset dir='${samples.temp.dir}'>
507 <include name="*.obj"/>
508 </fileset>
509 </path>
510 </foreach>
511 <concat destfile="${samples.temp.dir}/tex/comparison.tex" append="true">
512 <filelist dir="lib/tex" files="comparison-end.tex"/>
513 </concat>
514 <antcall target="output-comparison-compile"/>
515 </target>
517 <target name="output-comparison-compile">
518 <exec command="pdflatex comparison.tex"
519 dir="${samples.temp.dir}/tex"/>
520 </target>
522 <!-- jedit specific flags; needs to be the first or the last 10 lines
523 :noTabs=true:
524 -->
525 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner