gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl - - changes so that the version string is loaded from a file; there is a...
[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="log.dir" value="logs" />
37 <property name="log.file.transformations" value="${log.dir}/transformations" />
38 <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
40 <description>
41 Builder script for mjc2wsl and related tools, runs test
42 on given samples.
44 Also gives options to chain the tools on individual files.
45 </description>
47 <!-- general tasks -->
49 <target name="init" depends="init-time">
50 <mkdir dir="${mjc2wsl.class.dir}"/>
51 <mkdir dir="${compiler.class.dir}"/>
52 <mkdir dir="${samples.temp.dir}"/>
53 <mkdir dir="${log.dir}"/>
54 <copy todir="${samples.temp.dir}">
55 <fileset dir="${samples.main.dir}">
56 <include name="*.mj"/>
57 </fileset>
58 </copy>
59 </target>
61 <target name="init-time">
62 <tstamp>
63 <format property="time" pattern="yy-MM-dd--HH-mm-ss"/>
64 </tstamp>
65 </target>
67 <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
68 description="build the tools, run them on the samples to check">
70 </target>
72 <target name="clean" description="clean up all the generated content">
73 <delete includeemptydirs="true">
74 <fileset dir="${mjc2wsl.class.dir}"/>
75 <fileset dir="${compiler.class.dir}"/>
76 <fileset dir="${samples.temp.dir}"/>
77 <fileset dir="${log.dir}"/>
78 </delete>
79 </target>
81 <!-- version tasks
82 based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
84 <!-- this target is only run if the 'version' property is undefined -->
86 <target name="update-version-string" unless="version">
87 <!-- get a new version string using git describe if possible -->
88 <echo message="Updating version string..."/>
89 <exec executable="git" outputproperty="version"
90 failifexecutionfails="false">
91 <arg value="describe"/>
92 </exec>
93 <antcall target="-store-version-string"/>
94 <!-- ensure version is defined even if git was not available -->
95 <property file="${res.dir}/version.properties"/>
96 </target>
98 <target name="-store-version-string" if="version">
99 <!-- store the new version string in the correct property file -->
100 <echo message="version=${version}"/>
101 <propertyfile file="${res.dir}/version.properties">
102 <entry key="version" value="${version}"/>
103 </propertyfile>
104 <exec executable="git" failifexecutionfails="false">
105 <arg value="update-index"/>
106 <arg value="--assume-unchanged"/>
107 <arg value="${res.dir}/version.properties"/>
108 </exec>
109 </target>
111 <!-- mjc2wsl related tasks -->
113 <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
114 <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
115 </target>
117 <target name="mjc2wsl">
118 <echo message="${filename}" />
119 <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="mjc2wsl">
120 <arg line="${mjc2wsl.options}" />
121 <arg value="${filename}" />
122 </java>
123 </target>
125 <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
126 <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
127 <echo>Used options:${mjc2wsl.options}</echo>
128 <foreach param="filename" target="mjc2wsl">
129 <path>
130 <fileset dir='${samples.temp.dir}'>
131 <include name="*.obj"/>
132 </fileset>
133 </path>
134 </foreach>
135 <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
136 <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
137 </target>
139 <target name="mjc2wsl-samples1" depends="build">
140 <!-- simplistic version when antlib (foreach) is not available -->
141 <antcall target="mjc2wsl">
142 <param name="filename" value="samples-temp/sample0.obj" />
143 </antcall>
144 </target>
147 <!-- MicroJava related tasks -->
150 <target name="mj-build" depends="init" description="build the mj compiler">
151 <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
152 </target>
154 <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
155 <echo message="${filename}" />
156 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
157 <arg value="${filename}" />
158 </java>
159 </target>
161 <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
162 <foreach param="filename" target="mj-compile">
163 <path>
164 <fileset dir='${samples.temp.dir}'>
165 <include name="*.mj"/>
166 </fileset>
167 </path>
168 </foreach>
169 </target>
171 <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
172 <echo message="${filename}" />
173 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.decoder}">
174 <arg value="${filename}" />
175 </java>
176 </target>
178 <target name="mj-decode-samples" description="decode all of the compiled samples and save into file 'decoded.txt'">
179 <record name="${samples.temp.dir}/decoded.txt" emacsmode="true" loglevel="info"/>
180 <foreach param="filename" target="mj-decode">
181 <path>
182 <fileset dir='${samples.temp.dir}'>
183 <include name="*.obj"/>
184 </fileset>
185 </path>
186 </foreach>
187 <record name="${samples.temp.dir}/decoded.txt" action="stop"/>
188 </target>
190 <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
191 <echo message="${filename}" />
192 <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
193 <arg value="${filename}" />
194 </java>
195 </target>
197 <target name="mj-samples1" depends="mj-build">
198 <!-- simplistic version when antlib (foreach) is not available -->
199 <antcall target="mj-compile">
200 <param name="filename" value="samples-temp/sample.mj" />
201 </antcall>
202 <antcall target="mj-compile">
203 <param name="filename" value="samples-temp/sample1.mj" />
204 </antcall>
205 <antcall target="mj-compile">
206 <param name="filename" value="samples-temp/sample0.mj" />
207 </antcall>
208 </target>
211 <!-- wsl related tasks -->
213 <target name="wsl-run" >
214 <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
215 <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
216 <env key="FermaT" path="${fermat.dir}" />
217 <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
218 <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
219 <arg value="${filename}"/>
220 </exec>
221 </target>
223 <target name="wsl-transf"
224 description="transform (simplify) a single wsl file generated by mjc2wsl">
225 <delete file="${transf.wsl.ini}"/>
227 <antcall target="wsl-run">
228 <param name="filename" value="${transf.wsl.file}" />
229 <param name="inputstring" value="${transf.filename}" />
230 </antcall>
231 </target>
233 <target name="wsl-transf-samples" depends="init-time,make-transf-ini-samples"
234 description="transform (simplify) the wsl files generated by mjc2wsl">
235 <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
236 <antcall target="wsl-run">
237 <param name="filename" value="${transf.wsl.file}" />
238 </antcall>
239 <record name="${log.file.transformations}${time}.txt" action="stop" />
240 <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
241 </target>
243 <target name="make-transf-ini-samples">
244 <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
245 <patternset id="non.transformed.sources">
246 <include name="**/*.wsl"/>
247 <exclude name="**/*_t.wsl"/>
248 </patternset>
249 </fileset>
250 <pathconvert pathsep="${line.separator}"
251 property="generated-wsl-files" refid="generated-wsl-fileset" />
253 <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
254 </target>
256 <!-- Testing tasks -->
258 <target name="test-run"
259 description="run .obj .wsl _t.wsl, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
260 <antcall target="mj-run">
261 <param name="filename" value="${file.dir}/${file.name}.obj" />
262 <param name="inputstring" value="${inputstring}" />
263 </antcall>
264 <antcall target="wsl-run">
265 <param name="filename" value="${file.dir}/${file.name}.wsl" />
266 <param name="inputstring" value="${inputstring}" />
267 </antcall>
268 <antcall target="wsl-run">
269 <param name="filename" value="${file.dir}/${file.name}_t.wsl" />
270 <param name="inputstring" value="${inputstring}" />
271 </antcall>
272 </target>
274 <target name="test-run-samples-dir"
275 description="run .obj .wsl _t.wsl, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
276 <antcall target="test-run">
277 <param name="file.dir" value="${samples.temp.dir}"/>
278 </antcall>
279 </target>
281 <!-- jedit specific flags; needs to be the first or the last 10 lines
282 :noTabs=true:
283 -->
284 </project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner