gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
test files for the samples
[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 <property name="mjc2wsl.class.dir" value="bin" />
18 <property name="mjc2wsl.src.dir" value="src" />
19 <property name="mjc2wsl.options" value="" />
21 <property name="res.dir" value="res" />
23 <property name="compiler.class.jar" value="lib/mj.jar" />
24 <property name="compiler.class.dir" value="lib/compiler-bin" />
25 <property name="compiler.src.dir" value="lib/compiler-src" />
26 <property name="compiler.classname.compiler" value="MJ.Compiler" />
27 <property name="compiler.classname.interpreter" value="MJ.Run" />
28 <property name="compiler.classname.decoder" value="MJ.Decode" />
30 <property name="samples.main.dir" value="samples" />
31 <property name="samples.temp.dir" value="temp" />
33 <property name="transf.wsl.file" value="src-wsl/transf-min.wsl" />
34 <property name="transf.wsl.ini" value="transf.ini" />
36 <property name="tests.dir" value="tests" />
38 <property name="log.dir" value="logs" />
39 <property name="log.file.transformations" value="${log.dir}/transformations" />
40 <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
42 <description>
43 Builder script for mjc2wsl and related tools, runs test
44 on given samples.
46 Also gives options to chain the tools on individual files.
47 </description>
49 <!-- general tasks -->
51 <target name="init" depends="init-time">
52 <mkdir dir="${mjc2wsl.class.dir}"/>
53 <mkdir dir="${compiler.class.dir}"/>
54 <mkdir dir="${samples.temp.dir}"/>
55 <mkdir dir="${log.dir}"/>
56 <copy todir="${samples.temp.dir}">
57 <fileset dir="${samples.main.dir}">
58 <include name="*.mj"/>
59 </fileset>
60 </copy>
61 </target>
63 <target name="init-time">
64 <tstamp>
65 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
66 </tstamp>
67 </target>
69 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
70 description="build the tools, run them on the samples to check">
72 </target>
74 <target name="clean" description="clean up all the generated content">
75 <delete includeemptydirs="true">
76 <fileset dir="${mjc2wsl.class.dir}"/>
77 <fileset dir="${compiler.class.dir}"/>
78 <fileset dir="${samples.temp.dir}"/>
79 <fileset dir="${log.dir}"/>
80 </delete>
81 </target>
83 <!-- version tasks
84 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
86 <!-- this target is only run if the 'version' property is undefined -->
88 <target name="update-version-string" unless="version">
89 <!-- get a new version string using git describe if possible -->
90 <echo message="Updating version string..."/>
91 <exec executable="git" outputproperty="version"
92 failifexecutionfails="false">
93 <arg value="describe"/>
94 </exec>
95 <antcall target="-store-version-string"/>
96 <!-- ensure version is defined even if git was not available -->
97 <property file="${res.dir}/version.properties"/>
98 </target>
100 <target name="-store-version-string" if="version">
101 <!-- store the new version string in the correct property file -->
102 <echo message="version=${version}"/>
103 <propertyfile file="${res.dir}/version.properties">
104 <entry key="version" value="${version}"/>
105 </propertyfile>
106 <exec executable="git" failifexecutionfails="false">
107 <arg value="update-index"/>
108 <arg value="--assume-unchanged"/>
109 <arg value="${res.dir}/version.properties"/>
110 </exec>
111 </target>
113 <!-- mjc2wsl related tasks -->
115 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
116 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
117 </target>
119 <target name="mjc2wsl">
120 <echo message="${filename}" />
121 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
122 <arg line="${mjc2wsl.options}" />
123 <arg value="${filename}" />
124 </java>
125 </target>
127 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
128 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
129 <echo>Used options:${mjc2wsl.options}</echo>
130 <foreach param="filename" target="mjc2wsl">
131 <path>
132 <fileset dir='${samples.temp.dir}'>
133 <include name="*.obj"/>
134 </fileset>
135 </path>
136 </foreach>
137 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
138 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
139 </target>
141 <target name="mjc2wsl-samples1" depends="build">
142 <!-- simplistic version when antlib (foreach) is not available -->
143 <antcall target="mjc2wsl">
144 <param name="filename" value="samples-temp/sample0.obj" />
145 </antcall>
146 </target>
149 <!-- MicroJava related tasks -->
152 <target name="mj-build" depends="init" description="build the mj compiler">
153 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
154 </target>
156 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
157 <echo message="${filename}" />
158 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
159 <arg value="${filename}" />
160 </java>
161 </target>
163 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
164 <foreach param="filename" target="mj-compile">
165 <path>
166 <fileset dir='${samples.temp.dir}'>
167 <include name="*.mj"/>
168 </fileset>
169 </path>
170 </foreach>
171 </target>
173 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
174 <echo message="${filename}" />
175 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.decoder}">
176 <arg value="${filename}" />
177 </java>
178 </target>
180 <target name="mj-decode-samples" description="decode all of the compiled samples and save into file 'decoded.txt'">
181 <record name="${samples.temp.dir}/decoded.txt" emacsmode="true" loglevel="info"/>
182 <foreach param="filename" target="mj-decode">
183 <path>
184 <fileset dir='${samples.temp.dir}'>
185 <include name="*.obj"/>
186 </fileset>
187 </path>
188 </foreach>
189 <record name="${samples.temp.dir}/decoded.txt" action="stop"/>
190 </target>
192 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
193 <echo message="${filename}" />
194 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
195 <arg value="${filename}" />
196 </java>
197 </target>
199 <target name="mj-samples1" depends="mj-build">
200 <!-- simplistic version when antlib (foreach) is not available -->
201 <antcall target="mj-compile">
202 <param name="filename" value="samples-temp/sample.mj" />
203 </antcall>
204 <antcall target="mj-compile">
205 <param name="filename" value="samples-temp/sample1.mj" />
206 </antcall>
207 <antcall target="mj-compile">
208 <param name="filename" value="samples-temp/sample0.mj" />
209 </antcall>
210 </target>
213 <!-- wsl related tasks -->
215 <target name="wsl-run" >
216 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
217 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
218 <env key="FermaT" path="${fermat.dir}" />
219 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
220 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
221 <arg value="${filename}"/>
222 </exec>
223 </target>
225 <target name="wsl-transf"
226 description="transform (simplify) a single wsl file generated by mjc2wsl">
227 <delete file="${transf.wsl.ini}"/>
229 <antcall target="wsl-run">
230 <param name="filename" value="${transf.wsl.file}" />
231 <param name="inputstring" value="${transf.filename}" />
232 </antcall>
233 </target>
235 <target name="wsl-transf-samples" depends="init-time,make-transf-ini-samples"
236 description="transform (simplify) the wsl files generated by mjc2wsl">
237 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
238 <antcall target="wsl-run">
239 <param name="filename" value="${transf.wsl.file}" />
240 </antcall>
241 <record name="${log.file.transformations}${time}.txt" action="stop" />
242 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
243 </target>
245 <target name="make-transf-ini-samples">
246 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
247 <patternset id="non.transformed.sources">
248 <include name="**/*.wsl"/>
249 <exclude name="**/*_t.wsl"/>
250 </patternset>
251 </fileset>
252 <pathconvert pathsep="${line.separator}"
253 property="generated-wsl-files" refid="generated-wsl-fileset" />
255 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
256 </target>
258 <!-- Testing tasks -->
260 <target name="manual-test-run"
261 description="run .obj .wsl _t.wsl, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
262 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
263 <antcall target="mj-run">
264 <param name="filename" value="${file.dir}/${file.name}.obj" />
265 <param name="inputstring" value="${inputstring}" />
266 </antcall>
267 <record name="${file.dir}/${file.name}.out1" action="stop" />
268 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
269 <antcall target="wsl-run">
270 <param name="filename" value="${file.dir}/${file.name}.wsl" />
271 <param name="inputstring" value="${inputstring}" />
272 </antcall>
273 <record name="${file.dir}/${file.name}.out2" action="stop" />
274 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
275 <antcall target="wsl-run">
276 <param name="filename" value="${file.dir}/${file.name}_t.wsl" />
277 <param name="inputstring" value="${inputstring}" />
278 </antcall>
279 <record name="${file.dir}/${file.name}.out3" action="stop" />
280 </target>
282 <target name="manual-test-run-samples-dir"
283 description="run .obj .wsl _t.wsl, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
284 <antcall target="manual-test-run">
285 <param name="file.dir" value="${samples.temp.dir}"/>
286 </antcall>
287 </target>
289 <target name="init-compare">
290 <mkdir dir="${samples.temp.dir}/outputs"/>
291 </target>
293 <target name="test-m-w">
295 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
297 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
298 classname="${compiler.classname.interpreter}"
299 input="${inputfile}"
300 error="${samples.temp.dir}/outputs/${file.out}.errmj"
301 output="${samples.temp.dir}/outputs/${file.out}.outmj">
302 <arg value="${file.dir}/${file.name}.obj" />
303 </java>
305 <exec executable="${fermat.dir}/bin/wsl"
306 input="${inputfile}"
307 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
308 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
309 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
310 <env key="FermaT" path="${fermat.dir}" />
311 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
312 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
313 <arg value="${file.dir}/${file.name}.wsl"/>
314 </exec>
316 <exec executable="perl" resultproperty="ook">
317 <arg value="lib/compare-m-w.pl"/>
318 <arg value="${file.dir}/outputs"/>
319 <arg value="${file.out}"/>
320 </exec>
322 </target>
324 <target name="test-w-wt">
326 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
328 <exec executable="${fermat.dir}/bin/wsl"
329 input="${inputfile}"
330 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
331 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
332 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
333 <env key="FermaT" path="${fermat.dir}" />
334 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
335 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
336 <arg value="${file.dir}/${file.name}.wsl"/>
337 </exec>
339 <exec executable="${fermat.dir}/bin/wsl"
340 input="${inputfile}"
341 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
342 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
343 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
344 <env key="FermaT" path="${fermat.dir}" />
345 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
346 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
347 <arg value="${file.dir}/${file.name}_t.wsl"/>
348 </exec>
350 <exec executable="perl">
351 <arg value="lib/compare-w-wt.pl"/>
352 <arg value="${file.dir}/outputs"/>
353 <arg value="${file.out}"/>
354 </exec>
355 </target>
357 <target name="test-fn">
358 <basename property="file.name" file="${filename}" suffix=".obj"/>
359 <dirname property="file.dir" file="${filename}"/>
360 <foreach param="inputfile" target="test-m-w" inheritall="true">
361 <path>
362 <fileset dir='${tests.dir}'>
363 <include name="${file.name}*.txt"/>
364 </fileset>
365 </path>
366 </foreach>
367 </target>
369 <target name="test-fn-t">
370 <basename property="file.name" file="${filename}" suffix="_t.wsl"/>
371 <dirname property="file.dir" file="${filename}"/>
372 <foreach param="inputfile" target="test-w-wt" inheritall="true">
373 <path>
374 <fileset dir='${tests.dir}'>
375 <include name="${file.name}*.txt"/>
376 </fileset>
377 </path>
378 </foreach>
379 </target>
381 <target name="test-all-m" depends="init-compare"
382 description="Run all the tests from the test directory to compare MJ and WSL" >
383 <foreach param="filename" target="test-fn" inheritall="true">
384 <path>
385 <fileset dir='${samples.temp.dir}'>
386 <include name="*.obj"/>
387 </fileset>
388 </path>
389 </foreach>
390 </target>
392 <target name="test-all-t" depends="init-compare"
393 description="Run all the tests from the test directory to compare WSL and transformations" >
394 <foreach param="filename" target="test-fn-t">
395 <path>
396 <fileset dir='${samples.temp.dir}'>
397 <include name="*_t.wsl"/>
398 </fileset>
399 </path>
400 </foreach>
401 </target>
403 <target name="q-test">
404 <!-- for quick tests -->
405 <antcall target="test-fn">
406 <param name="file.name" value="Rek1"/>
407 <param name="file.dir" value="${samples.temp.dir}"/>
408 </antcall>
409 </target>
411 <!-- output serveral versions of files -->
413 <target name="output-all-versions"
414 description="generate variations on the translations in the 'local' folder and tar them">
415 <antcall>
416 <target name="mj-samples"/>
417 <target name="mjc2wsl-samples"/>
418 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
419 <param name="mjc2wsl.options" value=""/>
420 </antcall>
421 <antcall>
422 <target name="mj-samples"/>
423 <target name="mjc2wsl-samples"/>
424 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
425 <param name="mjc2wsl.options" value="--genInlinePrint"/>
426 </antcall>
427 <antcall>
428 <target name="mj-samples"/>
429 <target name="mjc2wsl-samples"/>
430 <param name="samples.temp.dir" value="local/out/popPush-inline"/>
431 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
432 </antcall>
433 <antcall>
434 <target name="mj-samples"/>
435 <target name="mjc2wsl-samples"/>
436 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
437 <param name="mjc2wsl.options" value="--genPopPush"/>
438 </antcall>
439 <antcall>
440 <target name="mj-samples"/>
441 <target name="mjc2wsl-samples"/>
442 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
443 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
444 </antcall>
445 <tar basedir="local/out" compression="gzip"
446 destfile="local/mjc2wsl-samples.tgz"
447 includes="*/*.wsl"/>
448 </target>
450 <!-- jedit specific flags; needs to be the first or the last 10 lines
451 :noTabs=true:
452 -->
453 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner