gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
5c227f33c54936a482e8862239cd263c85ae17f6
[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 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
233 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
234 <env key="FermaT" path="${fermat.dir}" />
235 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
236 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
237 <arg line="${filename} ${args}"/>
238 </exec>
239 </target>
241 <target name="wsl-transf"
242 description="transform (simplify) a single wsl file generated by mjc2wsl">
244 <antcall target="wsl-run">
245 <param name="filename" value="${transf.wsl.file}" />
246 <param name="args" value="${transf.filename}" />
247 </antcall>
248 </target>
250 <target name="wsl-transf-samples" depends="init"
251 description="transform (simplify) the wsl files generated by mjc2wsl" >
252 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
253 <foreach param="transf.filename" target="wsl-transf" parallel="true" maxthreads="${global.max.threads}">
254 <path>
255 <fileset dir='${samples.temp.dir}'>
256 <patternset refid="non.transformed.sources"/>
257 </fileset>
258 </path>
259 </foreach>
260 <record name="${log.file.transformations}${time}.txt" action="stop" />
261 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
262 </target>
264 <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
265 description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
266 <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
267 <antcall target="wsl-run">
268 <param name="filename" value="${transf.wsl.file}" />
269 </antcall>
270 <record name="${log.file.transformations}${time}i.txt" action="stop" />
271 <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
272 </target>
274 <target name="make-transf-ini-samples">
275 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
276 <patternset refid="non.transformed.sources"/>
277 </fileset>
278 <pathconvert pathsep="${line.separator}"
279 property="generated-wsl-files" refid="generated-wsl-fileset" />
281 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
282 </target>
284 <!-- Testing tasks -->
286 <target name="manual-test-run"
287 description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
288 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
289 <antcall target="mj-run">
290 <param name="filename" value="${file.dir}/${file.name}.obj" />
291 <param name="inputstring" value="${inputstring}" />
292 </antcall>
293 <record name="${file.dir}/${file.name}.out1" action="stop" />
294 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
295 <antcall target="wsl-run">
296 <param name="filename" value="${file.dir}/${file.name}.wsl" />
297 <param name="inputstring" value="${inputstring}" />
298 </antcall>
299 <record name="${file.dir}/${file.name}.out2" action="stop" />
300 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
301 <antcall target="wsl-run">
302 <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
303 <param name="inputstring" value="${inputstring}" />
304 </antcall>
305 <record name="${file.dir}/${file.name}.out3" action="stop" />
306 </target>
308 <target name="manual-test-run-samples-dir"
309 description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
310 <antcall target="manual-test-run">
311 <param name="file.dir" value="${samples.temp.dir}"/>
312 </antcall>
313 </target>
315 <target name="init-compare">
316 <mkdir dir="${samples.temp.dir}/outputs"/>
317 </target>
319 <target name="test-m-w">
321 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
323 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
324 classname="${compiler.classname.interpreter}"
325 input="${inputfile}"
326 error="${samples.temp.dir}/outputs/${file.out}.errmj"
327 output="${samples.temp.dir}/outputs/${file.out}.outmj">
328 <arg value="${file.dir}/${file.name}.obj" />
329 </java>
331 <exec executable="${fermat.dir}/bin/wsl"
332 input="${inputfile}"
333 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
334 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
335 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
336 <env key="FermaT" path="${fermat.dir}" />
337 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
338 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
339 <arg value="${file.dir}/${file.name}.wsl"/>
340 </exec>
342 <exec executable="perl" resultproperty="ook">
343 <arg value="lib/compare-m-w.pl"/>
344 <arg value="${file.dir}/outputs"/>
345 <arg value="${file.out}"/>
346 </exec>
348 </target>
350 <target name="test-w-wt">
352 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
354 <exec executable="${fermat.dir}/bin/wsl"
355 input="${inputfile}"
356 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
357 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
358 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
359 <env key="FermaT" path="${fermat.dir}" />
360 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
361 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
362 <arg value="${file.dir}/${file.name}.wsl"/>
363 </exec>
365 <exec executable="${fermat.dir}/bin/wsl"
366 input="${inputfile}"
367 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
368 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
369 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
370 <env key="FermaT" path="${fermat.dir}" />
371 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
372 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
373 <arg value="${file.dir}/${file.name}${transf.wsl.ext}"/>
374 </exec>
376 <exec executable="perl">
377 <arg value="lib/compare-w-wt.pl"/>
378 <arg value="${file.dir}/outputs"/>
379 <arg value="${file.out}"/>
380 </exec>
381 </target>
383 <target name="test-fn">
384 <basename property="file.name" file="${filename}" suffix=".obj"/>
385 <dirname property="file.dir" file="${filename}"/>
386 <foreach param="inputfile" target="test-m-w" inheritall="true">
387 <path>
388 <fileset dir='${tests.dir}'>
389 <include name="${file.name}*.txt"/>
390 </fileset>
391 </path>
392 </foreach>
393 </target>
395 <target name="test-fn-t">
396 <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
397 <dirname property="file.dir" file="${filename}"/>
398 <foreach param="inputfile" target="test-w-wt" inheritall="true">
399 <path>
400 <fileset dir='${tests.dir}'>
401 <include name="${file.name}*.txt"/>
402 </fileset>
403 </path>
404 </foreach>
405 </target>
407 <target name="test-all-m" depends="init-compare,init-time"
408 description="Run all the tests from the test directory to compare MJ and WSL" >
409 <record name="${log.file.tests.m}${time}.txt" emacsmode="true" />
410 <foreach param="filename" target="test-fn" inheritall="true">
411 <path>
412 <fileset dir='${samples.temp.dir}'>
413 <include name="*.obj"/>
414 </fileset>
415 </path>
416 </foreach>
417 <record name="${log.file.tests.m}${time}.txt" action="stop" />
418 <move file="${log.file.tests.m}.txt" tofile="${log.file.tests.m}-previous.txt" failonerror="false"/>
419 <copy file="${log.file.tests.m}${time}.txt" tofile="${log.file.tests.m}.txt"/>
420 </target>
422 <target name="test-all-t" depends="init-compare,init-time"
423 description="Run all the tests from the test directory to compare WSL and transformations" >
424 <record name="${log.file.tests.t}${time}.txt" emacsmode="true" />
425 <foreach param="filename" target="test-fn-t">
426 <path>
427 <fileset dir='${samples.temp.dir}'>
428 <include name="*${transf.wsl.ext}"/>
429 </fileset>
430 </path>
431 </foreach>
432 <record name="${log.file.tests.t}${time}.txt" action="stop" />
433 <move file="${log.file.tests.t}.txt" tofile="${log.file.tests.t}-previous.txt" failonerror="false"/>
434 <copy file="${log.file.tests.t}${time}.txt" tofile="${log.file.tests.t}.txt"/>
435 </target>
437 <target name="q-test">
438 <!-- for quick tests -->
439 <antcall target="test-fn">
440 <param name="file.name" value="Rek1"/>
441 <param name="file.dir" value="${samples.temp.dir}"/>
442 </antcall>
443 </target>
445 <!-- output serveral versions of files -->
447 <target name="output-all-versions"
448 description="generate variations on the translations in the 'local' folder and tar them">
449 <antcall>
450 <target name="mj-samples"/>
451 <target name="mjc2wsl-samples"/>
452 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
453 <param name="mjc2wsl.options" value=""/>
454 </antcall>
455 <antcall>
456 <target name="mj-samples"/>
457 <target name="mjc2wsl-samples"/>
458 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
459 <param name="mjc2wsl.options" value="--genInlinePrint"/>
460 </antcall>
461 <antcall>
462 <target name="mj-samples"/>
463 <target name="mjc2wsl-samples"/>
464 <param name="samples.temp.dir" value="local/out/popPush-inline"/>
465 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
466 </antcall>
467 <antcall>
468 <target name="mj-samples"/>
469 <target name="mjc2wsl-samples"/>
470 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
471 <param name="mjc2wsl.options" value="--genPopPush"/>
472 </antcall>
473 <antcall>
474 <target name="mj-samples"/>
475 <target name="mjc2wsl-samples"/>
476 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
477 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
478 </antcall>
479 <tar basedir="local/out" compression="gzip"
480 destfile="local/mjc2wsl-samples.tgz"
481 includes="*/*.wsl"/>
482 </target>
485 <!-- output a comparison Latex file and compile it -->
487 <target name="output-comparison-pdf-single">
488 <basename property="file.name" file="${filename}" suffix=".obj"/>
489 <echo append='true' file="${samples.temp.dir}/tex/comparison.tex">
490 \section{${file.name}}
491 \begin{paracol}{4}
492 \lstinputlisting[style=mj]{../${file.name}.mj}
493 \switchcolumn
494 \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
495 \switchcolumn
496 \lstinputlisting[style=wsl,lastline=200]{../${file.name}.wsl}
497 \switchcolumn
498 \lstinputlisting[style=wslt,lastline=200]{../${file.name}${transf.wsl.ext}}
499 \end{paracol}
500 </echo>
501 </target>
503 <target name="output-comparison-pdf"
504 description="Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
506 <copy file="lib/tex/comparison-start.tex" overwrite="true"
507 tofile="${samples.temp.dir}/tex/comparison.tex"/>
508 <foreach param="filename" target="output-comparison-pdf-single" inheritall="true">
509 <path>
510 <fileset dir='${samples.temp.dir}'>
511 <include name="*.obj"/>
512 </fileset>
513 </path>
514 </foreach>
515 <concat destfile="${samples.temp.dir}/tex/comparison.tex" append="true">
516 <filelist dir="lib/tex" files="comparison-end.tex"/>
517 </concat>
518 <antcall target="output-comparison-compile"/>
519 </target>
521 <target name="output-comparison-compile">
522 <exec command="pdflatex comparison.tex"
523 dir="${samples.temp.dir}/tex"/>
524 </target>
526 <!-- jedit specific flags; needs to be the first or the last 10 lines
527 :noTabs=true:
528 -->
529 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner