gitweb on Svarog

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