gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
142a84b3e6ecdd1475035a8f3f93830d817a821b
[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" />
46 <description>
47 Builder script for mjc2wsl and related tools, runs test
48 on given samples.
50 Also gives options to chain the tools on individual files.
51 </description>
53 <patternset id="non.transformed.sources">
54 <include name="**/*.wsl"/>
55 <exclude name="**/*${transf.wsl.ext}"/>
56 </patternset>
58 <!-- general tasks -->
60 <target name="init" depends="init-time">
61 <mkdir dir="${mjc2wsl.class.dir}"/>
62 <mkdir dir="${compiler.class.dir}"/>
63 <mkdir dir="${samples.temp.dir}"/>
64 <mkdir dir="${log.dir}"/>
65 <copy todir="${samples.temp.dir}">
66 <fileset dir="${samples.main.dir}">
67 <include name="*.mj"/>
68 </fileset>
69 </copy>
70 </target>
72 <target name="init-time">
73 <tstamp>
74 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
75 </tstamp>
76 </target>
78 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
79 description="build the tools, run them on the samples to check">
81 </target>
83 <target name="clean" description="clean up all the generated content">
84 <delete includeemptydirs="true">
85 <fileset dir="${mjc2wsl.class.dir}"/>
86 <fileset dir="${compiler.class.dir}"/>
87 <fileset dir="${samples.temp.dir}"/>
88 <fileset dir="${log.dir}"/>
89 </delete>
90 </target>
92 <!-- version tasks
93 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
95 <!-- this target is only run if the 'version' property is undefined -->
97 <target name="update-version-string" unless="version">
98 <!-- get a new version string using git describe if possible -->
99 <echo message="Updating version string..."/>
100 <exec executable="git" outputproperty="version"
101 failifexecutionfails="false">
102 <arg value="describe"/>
103 </exec>
104 <antcall target="-store-version-string"/>
105 <!-- ensure version is defined even if git was not available -->
106 <property file="${res.dir}/version.properties"/>
107 </target>
109 <target name="-store-version-string" if="version">
110 <!-- store the new version string in the correct property file -->
111 <echo message="version=${version}"/>
112 <propertyfile file="${res.dir}/version.properties">
113 <entry key="version" value="${version}"/>
114 </propertyfile>
115 <exec executable="git" failifexecutionfails="false">
116 <arg value="update-index"/>
117 <arg value="--assume-unchanged"/>
118 <arg value="${res.dir}/version.properties"/>
119 </exec>
120 </target>
122 <!-- mjc2wsl related tasks -->
124 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
125 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
126 </target>
128 <target name="mjc2wsl">
129 <echo message="${filename}" />
130 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
131 <arg line="${mjc2wsl.options}" />
132 <arg value="${filename}" />
133 </java>
134 </target>
136 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
137 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
138 <echo>Used options:${mjc2wsl.options}</echo>
139 <foreach param="filename" target="mjc2wsl" parallel="true" maxthreads="${global.max.threads}">
140 <path>
141 <fileset dir='${samples.temp.dir}'>
142 <include name="*.obj"/>
143 </fileset>
144 </path>
145 </foreach>
146 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
147 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
148 </target>
150 <target name="mjc2wsl-samples1" depends="build">
151 <!-- simplistic version when antlib (foreach) is not available -->
152 <antcall target="mjc2wsl">
153 <param name="filename" value="samples-temp/sample0.obj" />
154 </antcall>
155 </target>
158 <!-- MicroJava related tasks -->
161 <target name="mj-build" depends="init" description="build the mj compiler">
162 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
163 </target>
165 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
166 <echo message="${filename}" />
167 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
168 <arg value="${filename}" />
169 </java>
170 </target>
172 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
173 <foreach param="filename" target="mj-compile" parallel="true" maxthreads="${global.max.threads}">
174 <path>
175 <fileset dir='${samples.temp.dir}'>
176 <include name="*.mj"/>
177 </fileset>
178 </path>
179 </foreach>
180 </target>
182 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
183 <echo message="${filename}" />
184 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.decoder}">
185 <arg value="${filename}" />
186 </java>
187 </target>
189 <target name="mj-decode-samples" description="decode all of the compiled samples and save into file 'decoded.txt'">
190 <record name="${samples.temp.dir}/decoded.txt" emacsmode="true" loglevel="info"/>
191 <foreach param="filename" target="mj-decode">
192 <path>
193 <fileset dir='${samples.temp.dir}'>
194 <include name="*.obj"/>
195 </fileset>
196 </path>
197 </foreach>
198 <record name="${samples.temp.dir}/decoded.txt" action="stop"/>
199 </target>
201 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
202 <echo message="${filename}" />
203 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
204 <arg value="${filename}" />
205 </java>
206 </target>
208 <target name="mj-samples1" depends="mj-build">
209 <!-- simplistic version when antlib (foreach) is not available -->
210 <antcall target="mj-compile">
211 <param name="filename" value="samples-temp/sample.mj" />
212 </antcall>
213 <antcall target="mj-compile">
214 <param name="filename" value="samples-temp/sample1.mj" />
215 </antcall>
216 <antcall target="mj-compile">
217 <param name="filename" value="samples-temp/sample0.mj" />
218 </antcall>
219 </target>
222 <!-- wsl related tasks -->
224 <target name="wsl-run" >
225 <property name="args" value=""/>
226 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
227 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
228 <env key="FermaT" path="${fermat.dir}" />
229 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
230 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
231 <arg line="${filename} ${args}"/>
232 </exec>
233 </target>
235 <target name="wsl-transf"
236 description="transform (simplify) a single wsl file generated by mjc2wsl">
238 <antcall target="wsl-run">
239 <param name="filename" value="${transf.wsl.file}" />
240 <param name="args" value="${transf.filename}" />
241 </antcall>
242 </target>
244 <target name="wsl-transf-samples" depends="init"
245 description="transform (simplify) the wsl files generated by mjc2wsl" >
246 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
247 <foreach param="transf.filename" target="wsl-transf" parallel="true" maxthreads="${global.max.threads}">
248 <path>
249 <fileset dir='${samples.temp.dir}'>
250 <patternset refid="non.transformed.sources"/>
251 </fileset>
252 </path>
253 </foreach>
254 <record name="${log.file.transformations}${time}.txt" action="stop" />
255 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
256 </target>
258 <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
259 description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
260 <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
261 <antcall target="wsl-run">
262 <param name="filename" value="${transf.wsl.file}" />
263 </antcall>
264 <record name="${log.file.transformations}${time}i.txt" action="stop" />
265 <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
266 </target>
268 <target name="make-transf-ini-samples">
269 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
270 <patternset refid="non.transformed.sources"/>
271 </fileset>
272 <pathconvert pathsep="${line.separator}"
273 property="generated-wsl-files" refid="generated-wsl-fileset" />
275 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
276 </target>
278 <!-- Testing tasks -->
280 <target name="manual-test-run"
281 description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
282 <record name="${file.dir}/${file.name}.out1" emacsmode="true" />
283 <antcall target="mj-run">
284 <param name="filename" value="${file.dir}/${file.name}.obj" />
285 <param name="inputstring" value="${inputstring}" />
286 </antcall>
287 <record name="${file.dir}/${file.name}.out1" action="stop" />
288 <record name="${file.dir}/${file.name}.out2" emacsmode="true" />
289 <antcall target="wsl-run">
290 <param name="filename" value="${file.dir}/${file.name}.wsl" />
291 <param name="inputstring" value="${inputstring}" />
292 </antcall>
293 <record name="${file.dir}/${file.name}.out2" action="stop" />
294 <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
295 <antcall target="wsl-run">
296 <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
297 <param name="inputstring" value="${inputstring}" />
298 </antcall>
299 <record name="${file.dir}/${file.name}.out3" action="stop" />
300 </target>
302 <target name="manual-test-run-samples-dir"
303 description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
304 <antcall target="manual-test-run">
305 <param name="file.dir" value="${samples.temp.dir}"/>
306 </antcall>
307 </target>
309 <target name="init-compare">
310 <mkdir dir="${samples.temp.dir}/outputs"/>
311 </target>
313 <target name="test-m-w">
315 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
317 <java classpath="${compiler.class.dir}:${compiler.class.jar}"
318 classname="${compiler.classname.interpreter}"
319 input="${inputfile}"
320 error="${samples.temp.dir}/outputs/${file.out}.errmj"
321 output="${samples.temp.dir}/outputs/${file.out}.outmj">
322 <arg value="${file.dir}/${file.name}.obj" />
323 </java>
325 <exec executable="${fermat.dir}/bin/wsl"
326 input="${inputfile}"
327 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
328 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
329 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
330 <env key="FermaT" path="${fermat.dir}" />
331 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
332 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
333 <arg value="${file.dir}/${file.name}.wsl"/>
334 </exec>
336 <exec executable="perl" resultproperty="ook">
337 <arg value="lib/compare-m-w.pl"/>
338 <arg value="${file.dir}/outputs"/>
339 <arg value="${file.out}"/>
340 </exec>
342 </target>
344 <target name="test-w-wt">
346 <basename property="file.out" file="${inputfile}" suffix=".txt"/>
348 <exec executable="${fermat.dir}/bin/wsl"
349 input="${inputfile}"
350 error="${samples.temp.dir}/outputs/${file.out}.errwsl"
351 output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
352 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
353 <env key="FermaT" path="${fermat.dir}" />
354 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
355 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
356 <arg value="${file.dir}/${file.name}.wsl"/>
357 </exec>
359 <exec executable="${fermat.dir}/bin/wsl"
360 input="${inputfile}"
361 error="${samples.temp.dir}/outputs/${file.out}.errwslt"
362 output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
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}${transf.wsl.ext}"/>
368 </exec>
370 <exec executable="perl">
371 <arg value="lib/compare-w-wt.pl"/>
372 <arg value="${file.dir}/outputs"/>
373 <arg value="${file.out}"/>
374 </exec>
375 </target>
377 <target name="test-fn">
378 <basename property="file.name" file="${filename}" suffix=".obj"/>
379 <dirname property="file.dir" file="${filename}"/>
380 <foreach param="inputfile" target="test-m-w" inheritall="true">
381 <path>
382 <fileset dir='${tests.dir}'>
383 <include name="${file.name}*.txt"/>
384 </fileset>
385 </path>
386 </foreach>
387 </target>
389 <target name="test-fn-t">
390 <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
391 <dirname property="file.dir" file="${filename}"/>
392 <foreach param="inputfile" target="test-w-wt" inheritall="true">
393 <path>
394 <fileset dir='${tests.dir}'>
395 <include name="${file.name}*.txt"/>
396 </fileset>
397 </path>
398 </foreach>
399 </target>
401 <target name="test-all-m" depends="init-compare"
402 description="Run all the tests from the test directory to compare MJ and WSL" >
403 <foreach param="filename" target="test-fn" inheritall="true">
404 <path>
405 <fileset dir='${samples.temp.dir}'>
406 <include name="*.obj"/>
407 </fileset>
408 </path>
409 </foreach>
410 </target>
412 <target name="test-all-t" depends="init-compare"
413 description="Run all the tests from the test directory to compare WSL and transformations" >
414 <foreach param="filename" target="test-fn-t">
415 <path>
416 <fileset dir='${samples.temp.dir}'>
417 <include name="*${transf.wsl.ext}"/>
418 </fileset>
419 </path>
420 </foreach>
421 </target>
423 <target name="q-test">
424 <!-- for quick tests -->
425 <antcall target="test-fn">
426 <param name="file.name" value="Rek1"/>
427 <param name="file.dir" value="${samples.temp.dir}"/>
428 </antcall>
429 </target>
431 <!-- output serveral versions of files -->
433 <target name="output-all-versions"
434 description="generate variations on the translations in the 'local' folder and tar them">
435 <antcall>
436 <target name="mj-samples"/>
437 <target name="mjc2wsl-samples"/>
438 <param name="samples.temp.dir" value="local/out/headTail-proc"/>
439 <param name="mjc2wsl.options" value=""/>
440 </antcall>
441 <antcall>
442 <target name="mj-samples"/>
443 <target name="mjc2wsl-samples"/>
444 <param name="samples.temp.dir" value="local/out/headTail-inline"/>
445 <param name="mjc2wsl.options" value="--genInlinePrint"/>
446 </antcall>
447 <antcall>
448 <target name="mj-samples"/>
449 <target name="mjc2wsl-samples"/>
450 <param name="samples.temp.dir" value="local/out/popPush-inline"/>
451 <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
452 </antcall>
453 <antcall>
454 <target name="mj-samples"/>
455 <target name="mjc2wsl-samples"/>
456 <param name="samples.temp.dir" value="local/out/popPush-proc"/>
457 <param name="mjc2wsl.options" value="--genPopPush"/>
458 </antcall>
459 <antcall>
460 <target name="mj-samples"/>
461 <target name="mjc2wsl-samples"/>
462 <param name="samples.temp.dir" value="local/out/popPush-glob"/>
463 <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
464 </antcall>
465 <tar basedir="local/out" compression="gzip"
466 destfile="local/mjc2wsl-samples.tgz"
467 includes="*/*.wsl"/>
468 </target>
470 <!-- jedit specific flags; needs to be the first or the last 10 lines
471 :noTabs=true:
472 -->
473 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner