projekti pod git sistemom za održavanje verzija -- projects under
the git version control system
1 <project name=
"mjc2wsl" default=
"all">
3 Builder script for mjc2wsl and related tools, runs tests
7 <!-- use this file for any custom local needs -->
8 <property file=
"custom.properties"/>
9 <property environment=
"env"/>
11 <!-- try and detect the fermat.dir based on the operating system
12 should be set as a custom value in "custom.properties"
13 if it's in a non default location.
15 <condition property=
"fermat.dir" value=
"C:\fermat3">
16 <os family=
"windows" />
19 <condition property=
"fermat.dir" value=
"${user.home}/fermat3">
20 <not><os family=
"windows" /></not>
24 <property name=
"java.encoding" value=
"utf-8" />
25 <taskdef resource=
"net/sf/antcontrib/antlib.xml"/>
28 <!-- **************************************** -->
29 <!-- main variables that can be altered in the
30 properties file or through command line switches.
32 <!-- **************************************** -->
34 <!-- when using multiple threads there is a problem with logging!-->
35 <property name=
"global.max.threads" value=
"1" />
37 <property name=
"mjc2wsl.class.dir" value=
"bin" />
38 <property name=
"mjc2wsl.src.dir" value=
"src" />
39 <property name=
"mjc2wsl.options" value=
"" />
41 <property name=
"res.dir" value=
"res" />
43 <property name=
"compiler.class.jar" value=
"lib/mj.jar" />
44 <property name=
"compiler.class.dir" value=
"lib/compiler-bin" />
45 <property name=
"compiler.src.dir" value=
"lib/compiler-src" />
46 <property name=
"compiler.classname.compiler" value=
"MJ.Compiler" />
47 <property name=
"compiler.classname.interpreter" value=
"MJ.Run" />
48 <property name=
"compiler.classname.decoder" value=
"MJ.Decode" />
50 <property name=
"samples.main.dir" value=
"samples" />
51 <property name=
"samples.temp.dir" value=
"temp" />
53 <property name=
"transf.wsl.file" value=
"src-wsl/transf-min.wsl" />
54 <property name=
"transf.wsl.ini" value=
"transf.ini" />
55 <property name=
"transf.wsl.ext" value=
"_t.wsl" />
57 <property name=
"metrics.wsl.file" value=
"src-wsl/metrics.wsl" />
58 <property name=
"metrics.extension" value=
".met" />
60 <property name=
"tests.dir" value=
"tests" />
62 <property name=
"log.dir" value=
"logs" />
63 <property name=
"log.file.transformations" value=
"${log.dir}/transformations" />
64 <property name=
"log.file.mjc2wsl" value=
"${log.dir}/mjc2wsl" />
65 <property name=
"log.file.tests.m" value=
"${log.dir}/tests-mj" />
66 <property name=
"log.file.tests.t" value=
"${log.dir}/tests-wsl" />
68 <!-- **************************************** -->
70 <!-- **************************************** -->
72 <patternset id=
"non.transformed.sources">
73 <include name=
"**/*.wsl"/>
74 <exclude name=
"**/*${transf.wsl.ext}"/>
77 <patternset id=
"transformed.sources">
78 <include name=
"**/*${transf.wsl.ext}"/>
81 <!-- **************************************** -->
82 <!-- general tasks -->
83 <!-- **************************************** -->
85 <target name=
"init" depends=
"init-time">
86 <mkdir dir=
"${mjc2wsl.class.dir}"/>
87 <mkdir dir=
"${compiler.class.dir}"/>
88 <mkdir dir=
"${samples.temp.dir}"/>
89 <mkdir dir=
"${log.dir}"/>
90 <copy todir=
"${samples.temp.dir}">
91 <fileset dir=
"${samples.main.dir}">
92 <include name=
"*.mj"/>
97 <target name=
"init-time">
99 <format property=
"time" pattern=
"yy-MM-dd--HH-mm-ss"/>
103 <target name=
"all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
104 description=
"build the tools, run them on the samples to check">
108 <target name=
"clean" description=
"clean up all the generated content">
109 <delete includeemptydirs=
"true">
110 <fileset dir=
"${mjc2wsl.class.dir}"/>
111 <fileset dir=
"${compiler.class.dir}"/>
112 <fileset dir=
"${samples.temp.dir}"/>
113 <fileset dir=
"${log.dir}"/>
117 <!-- **************************************** -->
119 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
120 <!-- **************************************** -->
122 <!-- this target is only run if the 'version' property is undefined -->
124 <target name=
"update-version-string" unless=
"version">
125 <!-- get a new version string using git describe if possible -->
126 <echo message=
"Updating version string..."/>
127 <exec executable=
"git" outputproperty=
"version"
128 failifexecutionfails=
"false">
129 <arg value=
"describe"/>
131 <antcall target=
"-store-version-string"/>
132 <!-- ensure version is defined even if git was not available -->
133 <property file=
"${res.dir}/version.properties"/>
136 <target name=
"-store-version-string" if=
"version">
137 <!-- store the new version string in the correct property file -->
138 <echo message=
"version=${version}"/>
139 <propertyfile file=
"${res.dir}/version.properties">
140 <entry key=
"version" value=
"${version}"/>
142 <exec executable=
"git" failifexecutionfails=
"false">
143 <arg value=
"update-index"/>
144 <arg value=
"--assume-unchanged"/>
145 <arg value=
"${res.dir}/version.properties"/>
149 <!-- **************************************** -->
150 <!-- mjc2wsl related tasks -->
151 <!-- **************************************** -->
153 <target name=
"build" depends=
"init,update-version-string" description=
"build the mjc2wsl tool">
154 <javac srcdir=
"${mjc2wsl.src.dir}" destdir=
"${mjc2wsl.class.dir}" includeAntRuntime='no'
/>
157 <target name=
"mjc2wsl">
158 <echo message=
"${filename}" />
159 <java classpath=
"${mjc2wsl.class.dir}:${res.dir}" classname=
"com.quemaster.transformations.mjc2wsl.mjc2wsl">
160 <arg line=
"${mjc2wsl.options}" />
161 <arg value=
"${filename}" />
165 <target name=
"mjc2wsl-samples" depends=
"build,init-time" description=
"run the mjc2wsl tool on the samples">
166 <record name=
"${log.file.mjc2wsl}${time}.txt" emacsmode=
"true" />
167 <echo>Used options:${mjc2wsl.options}
</echo>
168 <foreach param=
"filename" target=
"mjc2wsl" parallel=
"true" maxthreads=
"${global.max.threads}">
170 <fileset dir='${samples.temp.dir}'
>
171 <include name=
"*.obj"/>
175 <record name=
"${log.file.mjc2wsl}${time}.txt" action=
"stop" />
176 <copy file=
"${log.file.mjc2wsl}${time}.txt" tofile=
"${log.file.mjc2wsl}.txt"/>
179 <target name=
"mjc2wsl-samples1" depends=
"build">
180 <!-- simplistic version when antlib (foreach) is not available -->
181 <antcall target=
"mjc2wsl">
182 <param name=
"filename" value=
"samples-temp/sample0.obj" />
187 <!-- **************************************** -->
188 <!-- MicroJava related tasks -->
189 <!-- **************************************** -->
192 <target name=
"mj-build" depends=
"init" description=
"build the mj compiler">
193 <javac srcdir=
"${compiler.src.dir}" destdir=
"${compiler.class.dir}" includeAntRuntime='no'
/>
196 <target name=
"mj-compile" description=
"compile a MJ into obj file; given ${filename}">
197 <echo message=
"${filename}" />
198 <java classpath=
"${compiler.class.dir}:${compiler.class.jar}" classname=
"${compiler.classname.compiler}">
199 <arg value=
"${filename}" />
203 <target name=
"mj-samples" description=
"run the mj compiler on the samples" depends=
"init">
204 <foreach param=
"filename" target=
"mj-compile" parallel=
"true" maxthreads=
"${global.max.threads}">
206 <fileset dir='${samples.temp.dir}'
>
207 <include name=
"*.mj"/>
213 <target name=
"mj-decode" description=
"decode a MJ obj file given in ${filename}">
214 <echo message=
"${filename}" />
215 <java classpath=
"${compiler.class.dir}:${compiler.class.jar}"
216 classname=
"${compiler.classname.decoder}"
217 output=
"${filename}.decoded" >
218 <arg value=
"${filename}" />
222 <target name=
"mj-decode-samples" description=
"decode all of the obj files in ${samples.temp.dir}">
223 <foreach param=
"filename" target=
"mj-decode">
225 <fileset dir='${samples.temp.dir}'
>
226 <include name=
"*.obj"/>
232 <target name=
"mj-run" description=
"run a MJ obj file given in ${filename} with ${inputstring}">
233 <echo message=
"${filename}" />
234 <java classpath=
"${compiler.class.dir}:${compiler.class.jar}" classname=
"${compiler.classname.interpreter}" inputstring=
"${inputstring}">
235 <arg value=
"${filename}" />
239 <target name=
"mj-samples1" depends=
"mj-build">
240 <!-- simplistic version when antlib (foreach) is not available -->
241 <antcall target=
"mj-compile">
242 <param name=
"filename" value=
"samples-temp/sample.mj" />
244 <antcall target=
"mj-compile">
245 <param name=
"filename" value=
"samples-temp/sample1.mj" />
247 <antcall target=
"mj-compile">
248 <param name=
"filename" value=
"samples-temp/sample0.mj" />
253 <!-- **************************************** -->
254 <!-- wsl related tasks -->
255 <!-- **************************************** -->
257 <target name=
"wsl-run" >
258 <property name=
"args" value=
""/>
259 <property name=
"wslrun.workdir" value=
""/>
260 <exec executable=
"${fermat.dir}/bin/wsl" inputstring=
"${inputstring}"
261 dir=
"${wslrun.workdir}" >
262 <env key=
"PATH" path=
"${fermat.dir}/bin:${env.PATH}"/>
263 <env key=
"FermaT" path=
"${fermat.dir}" />
264 <env key=
"SCHEME_LIBRARY_PATH" path=
"${fermat.dir}/slib/" />
265 <env key=
"SCM_INIT_PATH" path=
"${fermat.dir}/scm/Init5e7.scm" />
266 <arg line=
"${filename} ${args}"/>
270 <target name=
"wsl-transf"
271 description=
"transform (simplify) a single wsl file generated by mjc2wsl">
273 <antcall target=
"wsl-run">
274 <param name=
"filename" value=
"${transf.wsl.file}" />
275 <param name=
"args" value=
"${transf.filename}" />
279 <target name=
"wsl-transf-samples" depends=
"init"
280 description=
"transform (simplify) the wsl files generated by mjc2wsl" >
281 <record name=
"${log.file.transformations}${time}.txt" emacsmode=
"true" />
282 <foreach param=
"transf.filename" target=
"wsl-transf" parallel=
"true" maxthreads=
"${global.max.threads}">
284 <fileset dir='${samples.temp.dir}'
>
285 <patternset refid=
"non.transformed.sources"/>
289 <record name=
"${log.file.transformations}${time}.txt" action=
"stop" />
290 <copy file=
"${log.file.transformations}${time}.txt" tofile=
"${log.file.transformations}.txt"/>
293 <target name=
"wsl-transf-samples-ini" depends=
"init-time,make-transf-ini-samples"
294 description=
"transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
295 <record name=
"${log.file.transformations}${time}i.txt" emacsmode=
"true" />
296 <antcall target=
"wsl-run">
297 <param name=
"filename" value=
"${transf.wsl.file}" />
299 <record name=
"${log.file.transformations}${time}i.txt" action=
"stop" />
300 <copy file=
"${log.file.transformations}${time}i.txt" tofile=
"${log.file.transformations}.txt"/>
303 <target name=
"make-transf-ini-samples">
304 <fileset dir=
"${samples.temp.dir}" casesensitive=
"no" id=
"generated-wsl-fileset">
305 <patternset refid=
"non.transformed.sources"/>
307 <pathconvert pathsep=
"${line.separator}"
308 property=
"generated-wsl-files" refid=
"generated-wsl-fileset" />
310 <echo file=
"${transf.wsl.ini}">${generated-wsl-files}
</echo>
314 <!-- **************************************** -->
315 <!-- Testing tasks -->
316 <!-- **************************************** -->
318 <target name=
"manual-test-run"
319 description=
"run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
320 <record name=
"${file.dir}/${file.name}.out1" emacsmode=
"true" />
321 <antcall target=
"mj-run">
322 <param name=
"filename" value=
"${file.dir}/${file.name}.obj" />
323 <param name=
"inputstring" value=
"${inputstring}" />
325 <record name=
"${file.dir}/${file.name}.out1" action=
"stop" />
326 <record name=
"${file.dir}/${file.name}.out2" emacsmode=
"true" />
327 <antcall target=
"wsl-run">
328 <param name=
"filename" value=
"${file.dir}/${file.name}.wsl" />
329 <param name=
"inputstring" value=
"${inputstring}" />
331 <record name=
"${file.dir}/${file.name}.out2" action=
"stop" />
332 <record name=
"${file.dir}/${file.name}.out3" emacsmode=
"true" />
333 <antcall target=
"wsl-run">
334 <param name=
"filename" value=
"${file.dir}/${file.name}${transf.wsl.ext}" />
335 <param name=
"inputstring" value=
"${inputstring}" />
337 <record name=
"${file.dir}/${file.name}.out3" action=
"stop" />
340 <target name=
"manual-test-run-samples-dir"
341 description=
"run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
342 <antcall target=
"manual-test-run">
343 <param name=
"file.dir" value=
"${samples.temp.dir}"/>
347 <target name=
"init-compare">
348 <mkdir dir=
"${samples.temp.dir}/outputs"/>
351 <target name=
"test-m-w">
353 <basename property=
"file.out" file=
"${inputfile}" suffix=
".txt"/>
355 <java classpath=
"${compiler.class.dir}:${compiler.class.jar}"
356 classname=
"${compiler.classname.interpreter}"
358 error=
"${samples.temp.dir}/outputs/${file.out}.errmj"
359 output=
"${samples.temp.dir}/outputs/${file.out}.outmj">
360 <arg value=
"${file.dir}/${file.name}.obj" />
363 <exec executable=
"${fermat.dir}/bin/wsl"
365 error=
"${samples.temp.dir}/outputs/${file.out}.errwsl"
366 output=
"${samples.temp.dir}/outputs/${file.out}.outwsl" >
367 <env key=
"PATH" path=
"${fermat.dir}/bin:${env.PATH}"/>
368 <env key=
"FermaT" path=
"${fermat.dir}" />
369 <env key=
"SCHEME_LIBRARY_PATH" path=
"${fermat.dir}/slib/" />
370 <env key=
"SCM_INIT_PATH" path=
"${fermat.dir}/scm/Init5e7.scm" />
371 <arg value=
"${file.dir}/${file.name}.wsl"/>
374 <exec executable=
"perl" resultproperty=
"ook">
375 <arg value=
"lib/compare-m-w.pl"/>
376 <arg value=
"${file.dir}/outputs"/>
377 <arg value=
"${file.out}"/>
382 <target name=
"test-w-wt">
384 <basename property=
"file.out" file=
"${inputfile}" suffix=
".txt"/>
386 <exec executable=
"${fermat.dir}/bin/wsl"
388 error=
"${samples.temp.dir}/outputs/${file.out}.errwsl"
389 output=
"${samples.temp.dir}/outputs/${file.out}.outwsl" >
390 <env key=
"PATH" path=
"${fermat.dir}/bin:${env.PATH}"/>
391 <env key=
"FermaT" path=
"${fermat.dir}" />
392 <env key=
"SCHEME_LIBRARY_PATH" path=
"${fermat.dir}/slib/" />
393 <env key=
"SCM_INIT_PATH" path=
"${fermat.dir}/scm/Init5e7.scm" />
394 <arg value=
"${file.dir}/${file.name}.wsl"/>
397 <exec executable=
"${fermat.dir}/bin/wsl"
399 error=
"${samples.temp.dir}/outputs/${file.out}.errwslt"
400 output=
"${samples.temp.dir}/outputs/${file.out}.outwslt" >
401 <env key=
"PATH" path=
"${fermat.dir}/bin:${env.PATH}"/>
402 <env key=
"FermaT" path=
"${fermat.dir}" />
403 <env key=
"SCHEME_LIBRARY_PATH" path=
"${fermat.dir}/slib/" />
404 <env key=
"SCM_INIT_PATH" path=
"${fermat.dir}/scm/Init5e7.scm" />
405 <arg value=
"${file.dir}/${file.name}${transf.wsl.ext}"/>
408 <exec executable=
"perl">
409 <arg value=
"lib/compare-w-wt.pl"/>
410 <arg value=
"${file.dir}/outputs"/>
411 <arg value=
"${file.out}"/>
415 <target name=
"test-fn">
416 <basename property=
"file.name" file=
"${filename}" suffix=
".obj"/>
417 <dirname property=
"file.dir" file=
"${filename}"/>
418 <foreach param=
"inputfile" target=
"test-m-w" inheritall=
"true">
420 <fileset dir='${tests.dir}'
>
421 <include name=
"${file.name}*.txt"/>
427 <target name=
"test-fn-t">
428 <basename property=
"file.name" file=
"${filename}" suffix=
"${transf.wsl.ext}"/>
429 <dirname property=
"file.dir" file=
"${filename}"/>
430 <foreach param=
"inputfile" target=
"test-w-wt" inheritall=
"true">
432 <fileset dir='${tests.dir}'
>
433 <include name=
"${file.name}*.txt"/>
439 <target name=
"test-all-m" depends=
"init-compare,init-time"
440 description=
"Run all the tests from the test directory to compare MJ and WSL" >
441 <record name=
"${log.file.tests.m}${time}.txt" emacsmode=
"true" />
442 <foreach param=
"filename" target=
"test-fn" inheritall=
"true">
444 <fileset dir='${samples.temp.dir}'
>
445 <include name=
"*.obj"/>
449 <record name=
"${log.file.tests.m}${time}.txt" action=
"stop" />
450 <move file=
"${log.file.tests.m}.txt" tofile=
"${log.file.tests.m}-previous.txt" failonerror=
"false"/>
451 <copy file=
"${log.file.tests.m}${time}.txt" tofile=
"${log.file.tests.m}.txt"/>
454 <target name=
"test-all-t" depends=
"init-compare,init-time"
455 description=
"Run all the tests from the test directory to compare WSL and transformations" >
456 <record name=
"${log.file.tests.t}${time}.txt" emacsmode=
"true" />
457 <foreach param=
"filename" target=
"test-fn-t">
459 <fileset dir='${samples.temp.dir}'
>
460 <include name=
"*${transf.wsl.ext}"/>
464 <record name=
"${log.file.tests.t}${time}.txt" action=
"stop" />
465 <move file=
"${log.file.tests.t}.txt" tofile=
"${log.file.tests.t}-previous.txt" failonerror=
"false"/>
466 <copy file=
"${log.file.tests.t}${time}.txt" tofile=
"${log.file.tests.t}.txt"/>
469 <target name=
"q-test">
470 <!-- for quick tests -->
471 <antcall target=
"test-fn">
472 <param name=
"file.name" value=
"Rek1"/>
473 <param name=
"file.dir" value=
"${samples.temp.dir}"/>
478 <!-- **************************************** -->
480 <!-- **************************************** -->
482 <target name=
"metrics-compare-wsl">
483 <basename property=
"metrics.temp.name" file=
"${metrics.run.filename}" suffix=
"${transf.wsl.ext}"/>
484 <dirname property=
"metrics.temp.dir" file=
"${metrics.run.filename}"/>
485 <antcall target=
"wsl-run">
486 <param name=
"filename" value=
"${metrics.wsl.file}" />
487 <param name=
"args" value=
"-o ${metrics.temp.dir}/${metrics.temp.name}${metrics.extension} -c ${metrics.temp.dir}/${metrics.temp.name}.wsl ${metrics.temp.dir}/${metrics.temp.name}${transf.wsl.ext}" />
493 <target name=
"metrics-samples-compare-wsl" depends=
"init"
494 description=
"metrics on transformed wsl files (csv file)" >
496 <antcall target=
"wsl-run">
497 <param name=
"filename" value=
"${metrics.wsl.file}" />
498 <param name=
"args" value=
"-o ${samples.temp.dir}/0000-header${metrics.extension} -HC" />
502 <foreach param=
"metrics.run.filename" target=
"metrics-compare-wsl" parallel=
"true" maxthreads=
"${global.max.threads}">
504 <fileset dir='${samples.temp.dir}'
>
505 <patternset refid=
"transformed.sources"/>
510 <concat destfile=
"${samples.temp.dir}/metrics-wsl-compare.csv">
511 <fileset dir=
"${samples.temp.dir}" includes=
"*${metrics.extension}"/>
516 <!-- **************************************** -->
517 <!-- output serveral versions of files -->
518 <!-- **************************************** -->
520 <target name=
"output-all-versions"
521 description=
"generate variations on the translations in the 'local' folder and tar them">
523 <target name=
"mj-samples"/>
524 <target name=
"mjc2wsl-samples"/>
525 <param name=
"samples.temp.dir" value=
"local/out/headTail-proc"/>
526 <param name=
"mjc2wsl.options" value=
""/>
529 <target name=
"mj-samples"/>
530 <target name=
"mjc2wsl-samples"/>
531 <param name=
"samples.temp.dir" value=
"local/out/headTail-inline"/>
532 <param name=
"mjc2wsl.options" value=
"--genInlinePrint"/>
535 <target name=
"mj-samples"/>
536 <target name=
"mjc2wsl-samples"/>
537 <param name=
"samples.temp.dir" value=
"local/out/popPush-inline"/>
538 <param name=
"mjc2wsl.options" value=
"--genPopPush --genInlinePrint"/>
541 <target name=
"mj-samples"/>
542 <target name=
"mjc2wsl-samples"/>
543 <param name=
"samples.temp.dir" value=
"local/out/popPush-proc"/>
544 <param name=
"mjc2wsl.options" value=
"--genPopPush"/>
547 <target name=
"mj-samples"/>
548 <target name=
"mjc2wsl-samples"/>
549 <param name=
"samples.temp.dir" value=
"local/out/popPush-glob"/>
550 <param name=
"mjc2wsl.options" value=
"--genPopPush --genGlobalVars"/>
552 <tar basedir=
"local/out" compression=
"gzip"
553 destfile=
"local/mjc2wsl-samples.tgz"
558 <!-- **************************************** -->
559 <!-- output a comparison Latex file and compile it -->
560 <!-- **************************************** -->
562 <target name=
"output-comparison-pdf-single">
563 <basename property=
"file.name" file=
"${filename}" suffix=
".mj"/>
564 <echo append='true'
file=
"${samples.temp.dir}/tex/comparison.tex">
565 \section{${file.name}}
567 \lstinputlisting[style=mj]{../${file.name}.mj}
569 \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
571 \lstinputlisting[style=wsl,lastline=
200]{../${file.name}.wsl}
573 \lstinputlisting[style=wslt,lastline=
200]{../${file.name}${transf.wsl.ext}}
578 <target name=
"output-comparison-pdf"
579 description=
"Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
581 <copy file=
"lib/tex/comparison-start.tex" overwrite=
"true"
582 tofile=
"${samples.temp.dir}/tex/comparison.tex"/>
583 <foreach param=
"filename" target=
"output-comparison-pdf-single" inheritall=
"true">
585 <fileset dir='${samples.temp.dir}'
>
586 <include name=
"*.mj"/>
590 <concat destfile=
"${samples.temp.dir}/tex/comparison.tex" append=
"true">
591 <filelist dir=
"lib/tex" files=
"comparison-end.tex"/>
593 <antcall target=
"output-comparison-compile"/>
596 <target name=
"output-comparison-compile">
597 <exec command=
"pdflatex comparison.tex"
598 dir=
"${samples.temp.dir}/tex"/>
601 <!-- jedit specific flags; needs to be the first or the last 10 lines