gitweb on Svarog

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