gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - added logging to main tasks that work on all the samples; slightly improved...
[mjc2wsl.git] / build.xml
1 <project name="mjc2wsl" default="all">
2 <property file="custom.properties"/>
4 <condition property="fermat.dir" value="C:\fermat3">
5 <os family="windows" />
6 </condition>
8 <condition property="fermat.dir" value="${user.home}/fermat3">
9 <not><os family="windows" /></not>
10 </condition>
13 <property name="java.encoding" value="utf-8" />
14 <taskdef resource="net/sf/antcontrib/antlib.xml"/>
16 <property name="mjc2wsl.class.dir" value="bin" />
17 <property name="mjc2wsl.src.dir" value="src" />
18 <property name="mjc2wsl.options" value="" />
20 <property name="res.dir" value="res" />
22 <property name="compiler.class.dir" value="lib/compiler-bin" />
23 <property name="compiler.src.dir" value="lib/compiler-src" />
24 <property name="compiler.classname.compiler" value="MJ.Compiler" />
25 <property name="compiler.classname.interpreter" value="MJ.Run" />
26 <property name="compiler.classname.decoder" value="MJ.Decode" />
28 <property name="samples.main.dir" value="samples" />
29 <property name="samples.temp.dir" value="temp" />
31 <property name="transf.wsl.file" value="src-wsl/transf-min.wsl" />
32 <property name="transf.wsl.ini" value="transf.ini" />
34 <property name="log.dir" value="logs" />
35 <property name="log.file.transformations" value="${log.dir}/transformations" />
36 <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
38 <description>
39 Builder script for mjc2wsl and related tools, runs test
40 on given samples.
42 Also gives options to chain the tools on individual files.
43 </description>
45 <!-- general tasks -->
47 <target name="init" depends="init-time">
48 <mkdir dir="${mjc2wsl.class.dir}"/>
49 <mkdir dir="${compiler.class.dir}"/>
50 <mkdir dir="${samples.temp.dir}"/>
51 <mkdir dir="${log.dir}"/>
52 <copy todir="${samples.temp.dir}">
53 <fileset dir="${samples.main.dir}">
54 <include name="*.mj"/>
55 </fileset>
56 </copy>
57 </target>
59 <target name="init-time">
60 <tstamp>
61 <format property="time" pattern="(yy-MM-dd)-(HH-mm-ss)"/>
62 </tstamp>
63 </target>
65 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
66 description="build the tools, run them on the samples to check">
68 </target>
70 <target name="clean" description="clean up all the generated content">
71 <delete includeemptydirs="true">
72 <fileset dir="${mjc2wsl.class.dir}"/>
73 <fileset dir="${compiler.class.dir}"/>
74 <fileset dir="${samples.temp.dir}"/>
75 <fileset dir="${log.dir}"/>
76 </delete>
77 </target>
80 <!-- mjc2wsl related tasks -->
82 <target name="build" depends="init" description="build the mjc2wsl tool">
83 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
84 </target>
86 <target name="mjc2wsl">
87 <echo message="${filename}" />
88 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="mjc2wsl">
89 <arg line="${mjc2wsl.options}" />
90 <arg value="${filename}" />
91 </java>
92 </target>
94 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
95 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
96 <echo>Used options:${mjc2wsl.options}</echo>
97 <foreach param="filename" target="mjc2wsl">
98 <path>
99 <fileset dir='${samples.temp.dir}'>
100 <include name="*.obj"/>
101 </fileset>
102 </path>
103 </foreach>
104 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
105 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
106 </target>
108 <target name="mjc2wsl-samples1" depends="build">
109 <!-- simplistic version when antlib (foreach) is not available -->
110 <antcall target="mjc2wsl">
111 <param name="filename" value="samples-temp/sample0.obj" />
112 </antcall>
113 </target>
116 <!-- MicroJava related tasks -->
119 <target name="mj-build" depends="init" description="build the mj compiler">
120 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
121 </target>
123 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
124 <echo message="${filename}" />
125 <java classpath="${compiler.class.dir}" classname="${compiler.classname.compiler}">
126 <arg value="${filename}" />
127 </java>
128 </target>
130 <target name="mj-samples" depends="mj-build" description="run the mj compiler on the samples">
131 <foreach param="filename" target="mj-compile">
132 <path>
133 <fileset dir='${samples.temp.dir}'>
134 <include name="*.mj"/>
135 </fileset>
136 </path>
137 </foreach>
138 </target>
140 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
141 <echo message="${filename}" />
142 <java classpath="${compiler.class.dir}" classname="${compiler.classname.decoder}">
143 <arg value="${filename}" />
144 </java>
145 </target>
147 <target name="mj-decode-samples" depends="mj-build" description="decode all of the compiled samples and save into file 'decoded.txt'">
148 <record name="${samples.temp.dir}/decoded.txt" emacsmode="true" loglevel="info"/>
149 <foreach param="filename" target="mj-decode">
150 <path>
151 <fileset dir='${samples.temp.dir}'>
152 <include name="*.obj"/>
153 </fileset>
154 </path>
155 </foreach>
156 <record name="${samples.temp.dir}/decoded.txt" action="stop"/>
157 </target>
159 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
160 <echo message="${filename}" />
161 <java classpath="${compiler.class.dir}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
162 <arg value="${filename}" />
163 </java>
164 </target>
166 <target name="mj-samples1" depends="mj-build">
167 <!-- simplistic version when antlib (foreach) is not available -->
168 <antcall target="mj-compile">
169 <param name="filename" value="samples-temp/sample.mj" />
170 </antcall>
171 <antcall target="mj-compile">
172 <param name="filename" value="samples-temp/sample1.mj" />
173 </antcall>
174 <antcall target="mj-compile">
175 <param name="filename" value="samples-temp/sample0.mj" />
176 </antcall>
177 </target>
180 <!-- wsl related tasks -->
182 <target name="wsl-run" >
183 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
184 <env key="PATH" path="${env.PATH}:${fermat.dir}/bin"/>
185 <env key="FermaT" path="${fermat.dir}" />
186 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
187 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e5.scm" />
188 <arg value="${filename}"/>
189 </exec>
190 </target>
192 <target name="wsl-transf"
193 description="transform (simplify) a single wsl file generated by mjc2wsl">
194 <delete file="${transf.wsl.ini}"/>
196 <antcall target="wsl-run">
197 <param name="filename" value="${transf.wsl.file}" />
198 <param name="inputstring" value="${transf.filename}" />
199 </antcall>
200 </target>
202 <target name="wsl-transf-samples" depends="init-time,make-transf-ini-samples"
203 description="transform (simplify) the wsl files generated by mjc2wsl">
204 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
205 <antcall target="wsl-run">
206 <param name="filename" value="${transf.wsl.file}" />
207 </antcall>
208 <record name="${log.file.transformations}${time}" action="stop" />
209 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
210 </target>
212 <target name="make-transf-ini-samples">
213 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
214 <patternset id="non.transformed.sources">
215 <include name="**/*.wsl"/>
216 <exclude name="**/*_t.wsl"/>
217 </patternset>
218 </fileset>
219 <pathconvert pathsep="${line.separator}"
220 property="generated-wsl-files" refid="generated-wsl-fileset" />
222 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
223 </target>
225 <!-- Testing tasks -->
227 <target name="test-run"
228 description="run .obj .wsl _t.wsl, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
229 <antcall target="mj-run">
230 <param name="filename" value="${file.dir}/${file.name}.obj" />
231 <param name="inputstring" value="${inputstring}" />
232 </antcall>
233 <antcall target="wsl-run">
234 <param name="filename" value="${file.dir}/${file.name}.wsl" />
235 <param name="inputstring" value="${inputstring}" />
236 </antcall>
237 <antcall target="wsl-run">
238 <param name="filename" value="${file.dir}/${file.name}_t.wsl" />
239 <param name="inputstring" value="${inputstring}" />
240 </antcall>
241 </target>
243 <target name="test-run-samples-dir"
244 description="run .obj .wsl _t.wsl, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
245 <antcall target="test-run">
246 <param name="file.dir" value="${samples.temp.dir}"/>
247 </antcall>
248 </target>
250 <!-- jedit specific flags; needs to be the first or the last 10 lines
251 :noTabs=true:
252 -->
253 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner