gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - wsl-run add workdir param
[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 <patternset id="transformed.sources">
61 <include name="**/*${transf.wsl.ext}"/>
62 </patternset>
64 <!-- general tasks -->
66 <target name="init" depends="init-time">
67 <mkdir dir="${mjc2wsl.class.dir}"/>
68 <mkdir dir="${compiler.class.dir}"/>
69 <mkdir dir="${samples.temp.dir}"/>
70 <mkdir dir="${log.dir}"/>
71 <copy todir="${samples.temp.dir}">
72 <fileset dir="${samples.main.dir}">
73 <include name="*.mj"/>
74 </fileset>
75 </copy>
76 </target>
78 <target name="init-time">
79 <tstamp>
80 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
81 </tstamp>
82 </target>
84 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
85 description="build the tools, run them on the samples to check">
87 </target>
89 <target name="clean" description="clean up all the generated content">
90 <delete includeemptydirs="true">
91 <fileset dir="${mjc2wsl.class.dir}"/>
92 <fileset dir="${compiler.class.dir}"/>
93 <fileset dir="${samples.temp.dir}"/>
94 <fileset dir="${log.dir}"/>
95 </delete>
96 </target>
98 <!-- version tasks
99 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
101 <!-- this target is only run if the 'version' property is undefined -->
103 <target name="update-version-string" unless="version">
104 <!-- get a new version string using git describe if possible -->
105 <echo message="Updating version string..."/>
106 <exec executable="git" outputproperty="version"
107 failifexecutionfails="false">
108 <arg value="describe"/>
109 </exec>
110 <antcall target="-store-version-string"/>
111 <!-- ensure version is defined even if git was not available -->
112 <property file="${res.dir}/version.properties"/>
113 </target>
115 <target name="-store-version-string" if="version">
116 <!-- store the new version string in the correct property file -->
117 <echo message="version=${version}"/>
118 <propertyfile file="${res.dir}/version.properties">
119 <entry key="version" value="${version}"/>
120 </propertyfile>
121 <exec executable="git" failifexecutionfails="false">
122 <arg value="update-index"/>
123 <arg value="--assume-unchanged"/>
124 <arg value="${res.dir}/version.properties"/>
125 </exec>
126 </target>
128 <!-- mjc2wsl related tasks -->
130 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
131 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
132 </target>
134 <target name="mjc2wsl">
135 <echo message="${filename}" />
136 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
137 <arg line="${mjc2wsl.options}" />
138 <arg value="${filename}" />
139 </java>
140 </target>
142 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
143 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
144 <echo>Used options:${mjc2wsl.options}</echo>
145 <foreach param="filename" target="mjc2wsl" parallel="true" maxthreads="${global.max.threads}">
146 <path>
147 <fileset dir='${samples.temp.dir}'>
148 <include name="*.obj"/>
149 </fileset>
150 </path>
151 </foreach>
152 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
153 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
154 </target>
156 <target name="mjc2wsl-samples1" depends="build">
157 <!-- simplistic version when antlib (foreach) is not available -->
158 <antcall target="mjc2wsl">
159 <param name="filename" value="samples-temp/sample0.obj" />
160 </antcall>
161 </target>
164 <!-- MicroJava related tasks -->
167 <target name="mj-build" depends="init" description="build the mj compiler">
168 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
169 </target>
171 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
172 <echo message="${filename}" />
173 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
174 <arg value="${filename}" />
175 </java>
176 </target>
178 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
179 <foreach param="filename" target="mj-compile" parallel="true" maxthreads="${global.max.threads}">
180 <path>
181 <fileset dir='${samples.temp.dir}'>
182 <include name="*.mj"/>
183 </fileset>
184 </path>
185 </foreach>
186 </target>
188 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
189 <echo message="${filename}" />
190 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
191 classname="${compiler.classname.decoder}"
192 output="${filename}.decoded" >
193 <arg value="${filename}" />
194 </java>
195 </target>
197 <target name="mj-decode-samples" description="decode all of the obj files in ${samples.temp.dir}">
198 <foreach param="filename" target="mj-decode">
199 <path>
200 <fileset dir='${samples.temp.dir}'>
201 <include name="*.obj"/>
202 </fileset>
203 </path>
204 </foreach>
205 </target>
207 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
208 <echo message="${filename}" />
209 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
210 <arg value="${filename}" />
211 </java>
212 </target>
214 <target name="mj-samples1" depends="mj-build">
215 <!-- simplistic version when antlib (foreach) is not available -->
216 <antcall target="mj-compile">
217 <param name="filename" value="samples-temp/sample.mj" />
218 </antcall>
219 <antcall target="mj-compile">
220 <param name="filename" value="samples-temp/sample1.mj" />
221 </antcall>
222 <antcall target="mj-compile">
223 <param name="filename" value="samples-temp/sample0.mj" />
224 </antcall>
225 </target>
228 <!-- wsl related tasks -->
230 <target name="wsl-run" >
231 <property name="args" value=""/>
232 <property name="wslrun.workdir" value=""/>
233 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}"
234 dir="${wslrun.workdir}" >
235 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
236 <env key="FermaT" path="${fermat.dir}" />
237 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
238 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
239 <arg line="${filename} ${args}"/>
240 </exec>
241 </target>
243 <target name="wsl-transf"
244 description="transform (simplify) a single wsl file generated by mjc2wsl">
246 <antcall target="wsl-run">
247 <param name="filename" value="${transf.wsl.file}" />
248 <param name="args" value="${transf.filename}" />
249 </antcall>
250 </target>
252 <target name="wsl-transf-samples" depends="init"
253 description="transform (simplify) the wsl files generated by mjc2wsl" >
254 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
255 <foreach param="transf.filename" target="wsl-transf" parallel="true" maxthreads="${global.max.threads}">
256 <path>
257 <fileset dir='${samples.temp.dir}'>
258 <patternset refid="non.transformed.sources"/>
259 </fileset>
260 </path>
261 </foreach>
262 <record name="${log.file.transformations}${time}.txt" action="stop" />
263 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
264 </target>
266 <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
267 description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
268 <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
269 <antcall target="wsl-run">
270 <param name="filename" value="${transf.wsl.file}" />
271 </antcall>
272 <record name="${log.file.transformations}${time}i.txt" action="stop" />
273 <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
274 </target>
276 <target name="make-transf-ini-samples">
277 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
278 <patternset refid="non.transformed.sources"/>
279 </fileset>
280 <pathconvert pathsep="${line.separator}"
281 property="generated-wsl-files" refid="generated-wsl-fileset" />
283 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
284 </target>
286 <!-- Testing tasks -->
288 <target name="manual-test-run"
289 description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
290 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
291 <antcall target="mj-run">
292 <param name="filename" value="${file.dir}/${file.name}.obj" />
293 <param name="inputstring" value="${inputstring}" />
294 </antcall>
295 <record name="${file.dir}/${file.name}.out1" action="stop" />
296 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
297 <antcall target="wsl-run">
298 <param name="filename" value="${file.dir}/${file.name}.wsl" />
299 <param name="inputstring" value="${inputstring}" />
300 </antcall>
301 <record name="${file.dir}/${file.name}.out2" action="stop" />
302 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
303 <antcall target="wsl-run">
304 <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
305 <param name="inputstring" value="${inputstring}" />
306 </antcall>
307 <record name="${file.dir}/${file.name}.out3" action="stop" />
308 </target>
310 <target name="manual-test-run-samples-dir"
311 description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
312 <antcall target="manual-test-run">
313 <param name="file.dir" value="${samples.temp.dir}"/>
314 </antcall>
315 </target>
317 <target name="init-compare">
318 <mkdir dir="${samples.temp.dir}/outputs"/>
319 </target>
321 <target name="test-m-w">
323 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
325 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
326 classname="${compiler.classname.interpreter}"
327 input="${inputfile}"
328 error="${samples.temp.dir}/outputs/${file.out}.errmj"
329 output="${samples.temp.dir}/outputs/${file.out}.outmj">
330 <arg value="${file.dir}/${file.name}.obj" />
331 </java>
333 <exec executable="${fermat.dir}/bin/wsl"
334 input="${inputfile}"
335 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
336 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
337 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
338 <env key="FermaT" path="${fermat.dir}" />
339 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
340 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
341 <arg value="${file.dir}/${file.name}.wsl"/>
342 </exec>
344 <exec executable="perl" resultproperty="ook">
345 <arg value="lib/compare-m-w.pl"/>
346 <arg value="${file.dir}/outputs"/>
347 <arg value="${file.out}"/>
348 </exec>
350 </target>
352 <target name="test-w-wt">
354 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
356 <exec executable="${fermat.dir}/bin/wsl"
357 input="${inputfile}"
358 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
359 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
360 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
361 <env key="FermaT" path="${fermat.dir}" />
362 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
363 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
364 <arg value="${file.dir}/${file.name}.wsl"/>
365 </exec>
367 <exec executable="${fermat.dir}/bin/wsl"
368 input="${inputfile}"
369 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
370 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
371 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
372 <env key="FermaT" path="${fermat.dir}" />
373 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
374 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
375 <arg value="${file.dir}/${file.name}${transf.wsl.ext}"/>
376 </exec>
378 <exec executable="perl">
379 <arg value="lib/compare-w-wt.pl"/>
380 <arg value="${file.dir}/outputs"/>
381 <arg value="${file.out}"/>
382 </exec>
383 </target>
385 <target name="test-fn">
386 <basename property="file.name" file="${filename}" suffix=".obj"/>
387 <dirname property="file.dir" file="${filename}"/>
388 <foreach param="inputfile" target="test-m-w" inheritall="true">
389 <path>
390 <fileset dir='${tests.dir}'>
391 <include name="${file.name}*.txt"/>
392 </fileset>
393 </path>
394 </foreach>
395 </target>
397 <target name="test-fn-t">
398 <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
399 <dirname property="file.dir" file="${filename}"/>
400 <foreach param="inputfile" target="test-w-wt" inheritall="true">
401 <path>
402 <fileset dir='${tests.dir}'>
403 <include name="${file.name}*.txt"/>
404 </fileset>
405 </path>
406 </foreach>
407 </target>
409 <target name="test-all-m" depends="init-compare,init-time"
410 description="Run all the tests from the test directory to compare MJ and WSL" >
411 <record name="${log.file.tests.m}${time}.txt" emacsmode="true" />
412 <foreach param="filename" target="test-fn" inheritall="true">
413 <path>
414 <fileset dir='${samples.temp.dir}'>
415 <include name="*.obj"/>
416 </fileset>
417 </path>
418 </foreach>
419 <record name="${log.file.tests.m}${time}.txt" action="stop" />
420 <move file="${log.file.tests.m}.txt" tofile="${log.file.tests.m}-previous.txt" failonerror="false"/>
421 <copy file="${log.file.tests.m}${time}.txt" tofile="${log.file.tests.m}.txt"/>
422 </target>
424 <target name="test-all-t" depends="init-compare,init-time"
425 description="Run all the tests from the test directory to compare WSL and transformations" >
426 <record name="${log.file.tests.t}${time}.txt" emacsmode="true" />
427 <foreach param="filename" target="test-fn-t">
428 <path>
429 <fileset dir='${samples.temp.dir}'>
430 <include name="*${transf.wsl.ext}"/>
431 </fileset>
432 </path>
433 </foreach>
434 <record name="${log.file.tests.t}${time}.txt" action="stop" />
435 <move file="${log.file.tests.t}.txt" tofile="${log.file.tests.t}-previous.txt" failonerror="false"/>
436 <copy file="${log.file.tests.t}${time}.txt" tofile="${log.file.tests.t}.txt"/>
437 </target>
439 <target name="q-test">
440 <!-- for quick tests -->
441 <antcall target="test-fn">
442 <param name="file.name" value="Rek1"/>
443 <param name="file.dir" value="${samples.temp.dir}"/>
444 </antcall>
445 </target>
447 <!-- output serveral versions of files -->
449 <target name="output-all-versions"
450 description="generate variations on the translations in the 'local' folder and tar them">
451 <antcall>
452 <target name="mj-samples"/>
453 <target name="mjc2wsl-samples"/>
454 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
455 <param name="mjc2wsl.options" value=""/>
456 </antcall>
457 <antcall>
458 <target name="mj-samples"/>
459 <target name="mjc2wsl-samples"/>
460 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
461 <param name="mjc2wsl.options" value="--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-inline"/>
467 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
468 </antcall>
469 <antcall>
470 <target name="mj-samples"/>
471 <target name="mjc2wsl-samples"/>
472 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
473 <param name="mjc2wsl.options" value="--genPopPush"/>
474 </antcall>
475 <antcall>
476 <target name="mj-samples"/>
477 <target name="mjc2wsl-samples"/>
478 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
479 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
480 </antcall>
481 <tar basedir="local/out" compression="gzip"
482 destfile="local/mjc2wsl-samples.tgz"
483 includes="*/*.wsl"/>
484 </target>
487 <!-- output a comparison Latex file and compile it -->
489 <target name="output-comparison-pdf-single">
490 <basename property="file.name" file="${filename}" suffix=".obj"/>
491 <echo append='true' file="${samples.temp.dir}/tex/comparison.tex">
492 \section{${file.name}}
493 \begin{paracol}{4}
494 \lstinputlisting[style=mj]{../${file.name}.mj}
495 \switchcolumn
496 \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
497 \switchcolumn
498 \lstinputlisting[style=wsl,lastline=200]{../${file.name}.wsl}
499 \switchcolumn
500 \lstinputlisting[style=wslt,lastline=200]{../${file.name}${transf.wsl.ext}}
501 \end{paracol}
502 </echo>
503 </target>
505 <target name="output-comparison-pdf"
506 description="Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
508 <copy file="lib/tex/comparison-start.tex" overwrite="true"
509 tofile="${samples.temp.dir}/tex/comparison.tex"/>
510 <foreach param="filename" target="output-comparison-pdf-single" inheritall="true">
511 <path>
512 <fileset dir='${samples.temp.dir}'>
513 <include name="*.obj"/>
514 </fileset>
515 </path>
516 </foreach>
517 <concat destfile="${samples.temp.dir}/tex/comparison.tex" append="true">
518 <filelist dir="lib/tex" files="comparison-end.tex"/>
519 </concat>
520 <antcall target="output-comparison-compile"/>
521 </target>
523 <target name="output-comparison-compile">
524 <exec command="pdflatex comparison.tex"
525 dir="${samples.temp.dir}/tex"/>
526 </target>
528 <!-- jedit specific flags; needs to be the first or the last 10 lines
529 :noTabs=true:
530 -->
531 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner