gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
9af121c95e804b81d96904b515e22748e2159c4d
[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="metrics.wsl.file" value="src-wsl/metrics.wsl" />
41 <property name="metrics.extension" value=".met" />
43 <property name="tests.dir" value="tests" />
45 <property name="log.dir" value="logs" />
46 <property name="log.file.transformations" value="${log.dir}/transformations" />
47 <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
48 <property name="log.file.tests.m" value="${log.dir}/tests-mj" />
49 <property name="log.file.tests.t" value="${log.dir}/tests-wsl" />
51 <description>
52 Builder script for mjc2wsl and related tools, runs test
53 on given samples.
55 Also gives options to chain the tools on individual files.
56 </description>
58 <patternset id="non.transformed.sources">
59 <include name="**/*.wsl"/>
60 <exclude name="**/*${transf.wsl.ext}"/>
61 </patternset>
63 <patternset id="transformed.sources">
64 <include name="**/*${transf.wsl.ext}"/>
65 </patternset>
67 <!-- general tasks -->
69 <target name="init" depends="init-time">
70 <mkdir dir="${mjc2wsl.class.dir}"/>
71 <mkdir dir="${compiler.class.dir}"/>
72 <mkdir dir="${samples.temp.dir}"/>
73 <mkdir dir="${log.dir}"/>
74 <copy todir="${samples.temp.dir}">
75 <fileset dir="${samples.main.dir}">
76 <include name="*.mj"/>
77 </fileset>
78 </copy>
79 </target>
81 <target name="init-time">
82 <tstamp>
83 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
84 </tstamp>
85 </target>
87 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
88 description="build the tools, run them on the samples to check">
90 </target>
92 <target name="clean" description="clean up all the generated content">
93 <delete includeemptydirs="true">
94 <fileset dir="${mjc2wsl.class.dir}"/>
95 <fileset dir="${compiler.class.dir}"/>
96 <fileset dir="${samples.temp.dir}"/>
97 <fileset dir="${log.dir}"/>
98 </delete>
99 </target>
101 <!-- version tasks
102 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
104 <!-- this target is only run if the 'version' property is undefined -->
106 <target name="update-version-string" unless="version">
107 <!-- get a new version string using git describe if possible -->
108 <echo message="Updating version string..."/>
109 <exec executable="git" outputproperty="version"
110 failifexecutionfails="false">
111 <arg value="describe"/>
112 </exec>
113 <antcall target="-store-version-string"/>
114 <!-- ensure version is defined even if git was not available -->
115 <property file="${res.dir}/version.properties"/>
116 </target>
118 <target name="-store-version-string" if="version">
119 <!-- store the new version string in the correct property file -->
120 <echo message="version=${version}"/>
121 <propertyfile file="${res.dir}/version.properties">
122 <entry key="version" value="${version}"/>
123 </propertyfile>
124 <exec executable="git" failifexecutionfails="false">
125 <arg value="update-index"/>
126 <arg value="--assume-unchanged"/>
127 <arg value="${res.dir}/version.properties"/>
128 </exec>
129 </target>
131 <!-- mjc2wsl related tasks -->
133 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
134 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
135 </target>
137 <target name="mjc2wsl">
138 <echo message="${filename}" />
139 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
140 <arg line="${mjc2wsl.options}" />
141 <arg value="${filename}" />
142 </java>
143 </target>
145 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
146 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
147 <echo>Used options:${mjc2wsl.options}</echo>
148 <foreach param="filename" target="mjc2wsl" parallel="true" maxthreads="${global.max.threads}">
149 <path>
150 <fileset dir='${samples.temp.dir}'>
151 <include name="*.obj"/>
152 </fileset>
153 </path>
154 </foreach>
155 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
156 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
157 </target>
159 <target name="mjc2wsl-samples1" depends="build">
160 <!-- simplistic version when antlib (foreach) is not available -->
161 <antcall target="mjc2wsl">
162 <param name="filename" value="samples-temp/sample0.obj" />
163 </antcall>
164 </target>
167 <!-- MicroJava related tasks -->
170 <target name="mj-build" depends="init" description="build the mj compiler">
171 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
172 </target>
174 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
175 <echo message="${filename}" />
176 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
177 <arg value="${filename}" />
178 </java>
179 </target>
181 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
182 <foreach param="filename" target="mj-compile" parallel="true" maxthreads="${global.max.threads}">
183 <path>
184 <fileset dir='${samples.temp.dir}'>
185 <include name="*.mj"/>
186 </fileset>
187 </path>
188 </foreach>
189 </target>
191 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
192 <echo message="${filename}" />
193 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
194 classname="${compiler.classname.decoder}"
195 output="${filename}.decoded" >
196 <arg value="${filename}" />
197 </java>
198 </target>
200 <target name="mj-decode-samples" description="decode all of the obj files in ${samples.temp.dir}">
201 <foreach param="filename" target="mj-decode">
202 <path>
203 <fileset dir='${samples.temp.dir}'>
204 <include name="*.obj"/>
205 </fileset>
206 </path>
207 </foreach>
208 </target>
210 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
211 <echo message="${filename}" />
212 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
213 <arg value="${filename}" />
214 </java>
215 </target>
217 <target name="mj-samples1" depends="mj-build">
218 <!-- simplistic version when antlib (foreach) is not available -->
219 <antcall target="mj-compile">
220 <param name="filename" value="samples-temp/sample.mj" />
221 </antcall>
222 <antcall target="mj-compile">
223 <param name="filename" value="samples-temp/sample1.mj" />
224 </antcall>
225 <antcall target="mj-compile">
226 <param name="filename" value="samples-temp/sample0.mj" />
227 </antcall>
228 </target>
231 <!-- wsl related tasks -->
233 <target name="wsl-run" >
234 <property name="args" value=""/>
235 <property name="wslrun.workdir" value=""/>
236 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}"
237 dir="${wslrun.workdir}" >
238 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
239 <env key="FermaT" path="${fermat.dir}" />
240 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
241 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
242 <arg line="${filename} ${args}"/>
243 </exec>
244 </target>
246 <target name="wsl-transf"
247 description="transform (simplify) a single wsl file generated by mjc2wsl">
249 <antcall target="wsl-run">
250 <param name="filename" value="${transf.wsl.file}" />
251 <param name="args" value="${transf.filename}" />
252 </antcall>
253 </target>
255 <target name="wsl-transf-samples" depends="init"
256 description="transform (simplify) the wsl files generated by mjc2wsl" >
257 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
258 <foreach param="transf.filename" target="wsl-transf" parallel="true" maxthreads="${global.max.threads}">
259 <path>
260 <fileset dir='${samples.temp.dir}'>
261 <patternset refid="non.transformed.sources"/>
262 </fileset>
263 </path>
264 </foreach>
265 <record name="${log.file.transformations}${time}.txt" action="stop" />
266 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
267 </target>
269 <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
270 description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
271 <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
272 <antcall target="wsl-run">
273 <param name="filename" value="${transf.wsl.file}" />
274 </antcall>
275 <record name="${log.file.transformations}${time}i.txt" action="stop" />
276 <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
277 </target>
279 <target name="make-transf-ini-samples">
280 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
281 <patternset refid="non.transformed.sources"/>
282 </fileset>
283 <pathconvert pathsep="${line.separator}"
284 property="generated-wsl-files" refid="generated-wsl-fileset" />
286 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
287 </target>
289 <!-- Testing tasks -->
291 <target name="manual-test-run"
292 description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
293 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
294 <antcall target="mj-run">
295 <param name="filename" value="${file.dir}/${file.name}.obj" />
296 <param name="inputstring" value="${inputstring}" />
297 </antcall>
298 <record name="${file.dir}/${file.name}.out1" action="stop" />
299 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
300 <antcall target="wsl-run">
301 <param name="filename" value="${file.dir}/${file.name}.wsl" />
302 <param name="inputstring" value="${inputstring}" />
303 </antcall>
304 <record name="${file.dir}/${file.name}.out2" action="stop" />
305 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
306 <antcall target="wsl-run">
307 <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
308 <param name="inputstring" value="${inputstring}" />
309 </antcall>
310 <record name="${file.dir}/${file.name}.out3" action="stop" />
311 </target>
313 <target name="manual-test-run-samples-dir"
314 description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
315 <antcall target="manual-test-run">
316 <param name="file.dir" value="${samples.temp.dir}"/>
317 </antcall>
318 </target>
320 <target name="init-compare">
321 <mkdir dir="${samples.temp.dir}/outputs"/>
322 </target>
324 <target name="test-m-w">
326 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
328 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
329 classname="${compiler.classname.interpreter}"
330 input="${inputfile}"
331 error="${samples.temp.dir}/outputs/${file.out}.errmj"
332 output="${samples.temp.dir}/outputs/${file.out}.outmj">
333 <arg value="${file.dir}/${file.name}.obj" />
334 </java>
336 <exec executable="${fermat.dir}/bin/wsl"
337 input="${inputfile}"
338 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
339 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
340 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
341 <env key="FermaT" path="${fermat.dir}" />
342 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
343 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
344 <arg value="${file.dir}/${file.name}.wsl"/>
345 </exec>
347 <exec executable="perl" resultproperty="ook">
348 <arg value="lib/compare-m-w.pl"/>
349 <arg value="${file.dir}/outputs"/>
350 <arg value="${file.out}"/>
351 </exec>
353 </target>
355 <target name="test-w-wt">
357 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
359 <exec executable="${fermat.dir}/bin/wsl"
360 input="${inputfile}"
361 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
362 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
363 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
364 <env key="FermaT" path="${fermat.dir}" />
365 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
366 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
367 <arg value="${file.dir}/${file.name}.wsl"/>
368 </exec>
370 <exec executable="${fermat.dir}/bin/wsl"
371 input="${inputfile}"
372 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
373 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
374 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
375 <env key="FermaT" path="${fermat.dir}" />
376 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
377 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
378 <arg value="${file.dir}/${file.name}${transf.wsl.ext}"/>
379 </exec>
381 <exec executable="perl">
382 <arg value="lib/compare-w-wt.pl"/>
383 <arg value="${file.dir}/outputs"/>
384 <arg value="${file.out}"/>
385 </exec>
386 </target>
388 <target name="test-fn">
389 <basename property="file.name" file="${filename}" suffix=".obj"/>
390 <dirname property="file.dir" file="${filename}"/>
391 <foreach param="inputfile" target="test-m-w" inheritall="true">
392 <path>
393 <fileset dir='${tests.dir}'>
394 <include name="${file.name}*.txt"/>
395 </fileset>
396 </path>
397 </foreach>
398 </target>
400 <target name="test-fn-t">
401 <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
402 <dirname property="file.dir" file="${filename}"/>
403 <foreach param="inputfile" target="test-w-wt" inheritall="true">
404 <path>
405 <fileset dir='${tests.dir}'>
406 <include name="${file.name}*.txt"/>
407 </fileset>
408 </path>
409 </foreach>
410 </target>
412 <target name="test-all-m" depends="init-compare,init-time"
413 description="Run all the tests from the test directory to compare MJ and WSL" >
414 <record name="${log.file.tests.m}${time}.txt" emacsmode="true" />
415 <foreach param="filename" target="test-fn" inheritall="true">
416 <path>
417 <fileset dir='${samples.temp.dir}'>
418 <include name="*.obj"/>
419 </fileset>
420 </path>
421 </foreach>
422 <record name="${log.file.tests.m}${time}.txt" action="stop" />
423 <move file="${log.file.tests.m}.txt" tofile="${log.file.tests.m}-previous.txt" failonerror="false"/>
424 <copy file="${log.file.tests.m}${time}.txt" tofile="${log.file.tests.m}.txt"/>
425 </target>
427 <target name="test-all-t" depends="init-compare,init-time"
428 description="Run all the tests from the test directory to compare WSL and transformations" >
429 <record name="${log.file.tests.t}${time}.txt" emacsmode="true" />
430 <foreach param="filename" target="test-fn-t">
431 <path>
432 <fileset dir='${samples.temp.dir}'>
433 <include name="*${transf.wsl.ext}"/>
434 </fileset>
435 </path>
436 </foreach>
437 <record name="${log.file.tests.t}${time}.txt" action="stop" />
438 <move file="${log.file.tests.t}.txt" tofile="${log.file.tests.t}-previous.txt" failonerror="false"/>
439 <copy file="${log.file.tests.t}${time}.txt" tofile="${log.file.tests.t}.txt"/>
440 </target>
442 <target name="q-test">
443 <!-- for quick tests -->
444 <antcall target="test-fn">
445 <param name="file.name" value="Rek1"/>
446 <param name="file.dir" value="${samples.temp.dir}"/>
447 </antcall>
448 </target>
450 <!-- metrics -->
452 <target name="metrics-compare-wsl">
453 <basename property="metrics.temp.name" file="${metrics.run.filename}" suffix="${transf.wsl.ext}"/>
454 <dirname property="metrics.temp.dir" file="${metrics.run.filename}"/>
455 <antcall target="wsl-run">
456 <param name="filename" value="${metrics.wsl.file}" />
457 <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}" />
459 </antcall>
461 <!--
462 <echo>-o ${metrics.temp.name}.met -c ${metrics.temp.name}.wsl ${metrics.temp.name}${transf.wsl.ext}</echo>
463 -->
464 </target>
466 <target name="metrics-samples-compare-wsl" depends="init"
467 description="metrics on transformed wsl files (csv file)" >
469 <antcall target="wsl-run">
470 <param name="filename" value="${metrics.wsl.file}" />
471 <param name="args" value="-o ${samples.temp.dir}/0000-header${metrics.extension} -HC" />
473 </antcall>
475 <foreach param="metrics.run.filename" target="metrics-compare-wsl" parallel="true" maxthreads="${global.max.threads}">
476 <path>
477 <fileset dir='${samples.temp.dir}'>
478 <patternset refid="transformed.sources"/>
479 </fileset>
480 </path>
481 </foreach>
483 <concat destfile="${samples.temp.dir}/metrics-wsl-compare.csv">
484 <fileset dir="${samples.temp.dir}" includes="*${metrics.extension}"/>
485 </concat>
486 </target>
488 <!-- output serveral versions of files -->
490 <target name="output-all-versions"
491 description="generate variations on the translations in the 'local' folder and tar them">
492 <antcall>
493 <target name="mj-samples"/>
494 <target name="mjc2wsl-samples"/>
495 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
496 <param name="mjc2wsl.options" value=""/>
497 </antcall>
498 <antcall>
499 <target name="mj-samples"/>
500 <target name="mjc2wsl-samples"/>
501 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
502 <param name="mjc2wsl.options" value="--genInlinePrint"/>
503 </antcall>
504 <antcall>
505 <target name="mj-samples"/>
506 <target name="mjc2wsl-samples"/>
507 <param name="samples.temp.dir" value="local/out/popPush-inline"/>
508 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
509 </antcall>
510 <antcall>
511 <target name="mj-samples"/>
512 <target name="mjc2wsl-samples"/>
513 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
514 <param name="mjc2wsl.options" value="--genPopPush"/>
515 </antcall>
516 <antcall>
517 <target name="mj-samples"/>
518 <target name="mjc2wsl-samples"/>
519 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
520 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
521 </antcall>
522 <tar basedir="local/out" compression="gzip"
523 destfile="local/mjc2wsl-samples.tgz"
524 includes="*/*.wsl"/>
525 </target>
528 <!-- output a comparison Latex file and compile it -->
530 <target name="output-comparison-pdf-single">
531 <basename property="file.name" file="${filename}" suffix=".mj"/>
532 <echo append='true' file="${samples.temp.dir}/tex/comparison.tex">
533 \section{${file.name}}
534 \begin{paracol}{4}
535 \lstinputlisting[style=mj]{../${file.name}.mj}
536 \switchcolumn
537 \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
538 \switchcolumn
539 \lstinputlisting[style=wsl,lastline=200]{../${file.name}.wsl}
540 \switchcolumn
541 \lstinputlisting[style=wslt,lastline=200]{../${file.name}${transf.wsl.ext}}
542 \end{paracol}
543 </echo>
544 </target>
546 <target name="output-comparison-pdf"
547 description="Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
549 <copy file="lib/tex/comparison-start.tex" overwrite="true"
550 tofile="${samples.temp.dir}/tex/comparison.tex"/>
551 <foreach param="filename" target="output-comparison-pdf-single" inheritall="true">
552 <path>
553 <fileset dir='${samples.temp.dir}'>
554 <include name="*.mj"/>
555 </fileset>
556 </path>
557 </foreach>
558 <concat destfile="${samples.temp.dir}/tex/comparison.tex" append="true">
559 <filelist dir="lib/tex" files="comparison-end.tex"/>
560 </concat>
561 <antcall target="output-comparison-compile"/>
562 </target>
564 <target name="output-comparison-compile">
565 <exec command="pdflatex comparison.tex"
566 dir="${samples.temp.dir}/tex"/>
567 </target>
569 <!-- jedit specific flags; needs to be the first or the last 10 lines
570 :noTabs=true:
571 -->
572 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner