gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - improvements to the transf scripts to use the command line params, property...
[mjc2wsl.git] / build.xml
index 68a8941..421377f 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -20,6 +20,7 @@
 
     <property name="res.dir" value="res" />
     
+    <property name="compiler.class.jar" value="lib/mj.jar" />
     <property name="compiler.class.dir" value="lib/compiler-bin" />
     <property name="compiler.src.dir" value="lib/compiler-src" />
     <property name="compiler.classname.compiler" value="MJ.Compiler" />
@@ -31,6 +32,9 @@
 
     <property name="transf.wsl.file" value="src-wsl/transf-min.wsl" />
     <property name="transf.wsl.ini" value="transf.ini" />
+    <property name="transf.wsl.ext" value="_t.wsl" />
+    
+    <property name="tests.dir" value="tests" />
 
     <property name="log.dir" value="logs" />
     <property name="log.file.transformations" value="${log.dir}/transformations" />
         Also gives options to chain the tools on individual files.
     </description>
 
+    <patternset id="non.transformed.sources">
+        <include name="**/*.wsl"/>
+        <exclude name="**/*${transf.wsl.ext}"/>
+    </patternset>
+    
     <!-- general tasks -->
 
     <target name="init" depends="init-time">
             <fileset dir="${log.dir}"/>
         </delete>
     </target>
+       
+       <!-- version tasks
+       based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
     
+       <!-- this target is only run if the 'version' property is undefined -->
+       
+       <target name="update-version-string" unless="version">
+               <!-- get a new version string using git describe if possible -->
+               <echo message="Updating version string..."/>
+               <exec executable="git" outputproperty="version"
+                       failifexecutionfails="false">
+                       <arg value="describe"/>
+               </exec>
+               <antcall target="-store-version-string"/>
+               <!-- ensure version is defined even if git was not available -->
+               <property file="${res.dir}/version.properties"/>
+       </target>
     
+       <target name="-store-version-string" if="version">
+               <!-- store the new  version string in the correct property file -->
+               <echo message="version=${version}"/>
+               <propertyfile file="${res.dir}/version.properties">
+                       <entry key="version" value="${version}"/>
+               </propertyfile>
+               <exec executable="git" failifexecutionfails="false">
+                       <arg value="update-index"/>
+                       <arg value="--assume-unchanged"/>
+                       <arg value="${res.dir}/version.properties"/>
+               </exec>
+       </target>
+       
     <!-- mjc2wsl related tasks -->
     
-    <target name="build" depends="init" description="build the mjc2wsl tool">
+    <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
         <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
     </target>
 
     <target name="mjc2wsl">
         <echo message="${filename}" />
-        <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="mjc2wsl">
+        <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="com.quemaster.transformations.mjc2wsl.mjc2wsl">
             <arg line="${mjc2wsl.options}" />
             <arg value="${filename}" />
         </java>
     
     <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
         <echo message="${filename}" />
-        <java classpath="${compiler.class.dir}" classname="${compiler.classname.compiler}">
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
             <arg value="${filename}" />
         </java>
     </target>
     
-    <target name="mj-samples" depends="mj-build" description="run the mj compiler on the samples">
+    <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
         <foreach param="filename" target="mj-compile">
             <path>
             <fileset dir='${samples.temp.dir}'>
 
     <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
         <echo message="${filename}" />
-        <java classpath="${compiler.class.dir}" classname="${compiler.classname.decoder}">
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.decoder}">
             <arg value="${filename}" />
         </java>
     </target>
     
-    <target name="mj-decode-samples" depends="mj-build" description="decode all of the compiled samples and save into file 'decoded.txt'">
+    <target name="mj-decode-samples" description="decode all of the compiled samples and save into file 'decoded.txt'">
         <record name="${samples.temp.dir}/decoded.txt" emacsmode="true" loglevel="info"/>
         <foreach param="filename" target="mj-decode">
             <path>
     
     <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
         <echo message="${filename}" />
-        <java classpath="${compiler.class.dir}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
             <arg value="${filename}" />
         </java>
     </target>
     <!-- wsl related tasks -->
 
     <target name="wsl-run" >
+        <property name="args" value=""/>
         <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
-            <env key="PATH" path="${env.PATH}:${fermat.dir}/bin"/>
+            <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
             <env key="FermaT" path="${fermat.dir}" />
             <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
-            <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e5.scm" />
-            <arg value="${filename}"/>
+            <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
+            <arg line="${filename} ${args}"/>
         </exec>
     </target>
     
     <target name="wsl-transf" 
         description="transform (simplify) a single wsl file generated by mjc2wsl">
-        <delete file="${transf.wsl.ini}"/>
         
         <antcall target="wsl-run">
             <param name="filename" value="${transf.wsl.file}" />
-            <param name="inputstring" value="${transf.filename}" />
+            <param name="args" value="${transf.filename}" />
         </antcall>
     </target>
     
-    <target name="wsl-transf-samples" depends="init-time,make-transf-ini-samples"
-        description="transform (simplify) the wsl files generated by mjc2wsl">
+    <target name="wsl-transf-samples" depends="init"
+    description="transform (simplify) the wsl files generated by mjc2wsl" >
         <record name="${log.file.transformations}${time}.txt" emacsmode="true" />
+        <foreach param="transf.filename" target="wsl-transf">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <patternset refid="non.transformed.sources"/>
+            </fileset>
+            </path>
+        </foreach>
+        <record name="${log.file.transformations}${time}.txt" action="stop" />
+        <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
+    </target>
+
+    <target name="wsl-transf-samples-ini" depends="init-time,make-transf-ini-samples"
+        description="transform (simplify) the wsl files generated by mjc2wsl - uses ini file">
+        <record name="${log.file.transformations}${time}i.txt" emacsmode="true" />
         <antcall target="wsl-run">
             <param name="filename" value="${transf.wsl.file}" />
         </antcall>
-        <record name="${log.file.transformations}${time}" action="stop" />
-        <copy file="${log.file.transformations}${time}.txt" tofile="${log.file.transformations}.txt"/>
+        <record name="${log.file.transformations}${time}i.txt" action="stop" />
+        <copy file="${log.file.transformations}${time}i.txt" tofile="${log.file.transformations}.txt"/>
     </target>
     
     <target name="make-transf-ini-samples">
         <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
-                <patternset id="non.transformed.sources">
-                    <include name="**/*.wsl"/>
-                    <exclude name="**/*_t.wsl"/>
-                </patternset>
+                <patternset refid="non.transformed.sources"/>
         </fileset>
         <pathconvert pathsep="${line.separator}" 
             property="generated-wsl-files" refid="generated-wsl-fileset" />
     
     <!-- Testing tasks -->
     
-    <target name="test-run" 
-    description="run .obj .wsl _t.wsl, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
-        <antcall target="mj-run">
+    <target name="manual-test-run" 
+    description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
+       <record name="${file.dir}/${file.name}.out1"  emacsmode="true" />
+       <antcall target="mj-run">
             <param name="filename" value="${file.dir}/${file.name}.obj" />
             <param name="inputstring" value="${inputstring}" />
         </antcall>
+       <record name="${file.dir}/${file.name}.out1" action="stop" />
+       <record name="${file.dir}/${file.name}.out2"  emacsmode="true" />
         <antcall target="wsl-run">
             <param name="filename" value="${file.dir}/${file.name}.wsl" />
             <param name="inputstring" value="${inputstring}" />
         </antcall>
+       <record name="${file.dir}/${file.name}.out2" action="stop" />
+       <record name="${file.dir}/${file.name}.out3" emacsmode="true" />
         <antcall target="wsl-run">
-            <param name="filename" value="${file.dir}/${file.name}_t.wsl" />
+            <param name="filename" value="${file.dir}/${file.name}${transf.wsl.ext}" />
             <param name="inputstring" value="${inputstring}" />
         </antcall>
+       <record name="${file.dir}/${file.name}.out3" action="stop" />
     </target>
     
-    <target name="test-run-samples-dir"
-    description="run .obj .wsl _t.wsl, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
-        <antcall target="test-run">
+    <target name="manual-test-run-samples-dir"
+    description="run .obj .wsl ${transf.wsl.ext}, in the samples-temp directory; given ${file.name} (no extension) and an ${inputstring}">
+        <antcall target="manual-test-run">
             <param name="file.dir" value="${samples.temp.dir}"/>
         </antcall>
     </target>
     
+    <target name="init-compare">
+        <mkdir dir="${samples.temp.dir}/outputs"/>
+    </target>
+        
+    <target name="test-m-w">
+    
+    <basename property="file.out" file="${inputfile}" suffix=".txt"/>
+    
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" 
+        classname="${compiler.classname.interpreter}" 
+        input="${inputfile}"
+        error="${samples.temp.dir}/outputs/${file.out}.errmj"
+        output="${samples.temp.dir}/outputs/${file.out}.outmj">
+            <arg value="${file.dir}/${file.name}.obj" />
+        </java>
+        
+        <exec executable="${fermat.dir}/bin/wsl" 
+        input="${inputfile}"
+        error="${samples.temp.dir}/outputs/${file.out}.errwsl"
+        output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
+            <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
+            <env key="FermaT" path="${fermat.dir}" />
+            <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
+            <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
+            <arg value="${file.dir}/${file.name}.wsl"/>
+        </exec>
+        
+        <exec executable="perl" resultproperty="ook">
+            <arg value="lib/compare-m-w.pl"/>
+            <arg value="${file.dir}/outputs"/>
+            <arg value="${file.out}"/>
+        </exec>
+        
+    </target>
+    
+    <target name="test-w-wt">
+    
+    <basename property="file.out" file="${inputfile}" suffix=".txt"/>
+    
+        <exec executable="${fermat.dir}/bin/wsl" 
+        input="${inputfile}"
+        error="${samples.temp.dir}/outputs/${file.out}.errwsl"
+        output="${samples.temp.dir}/outputs/${file.out}.outwsl" >
+            <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
+            <env key="FermaT" path="${fermat.dir}" />
+            <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
+            <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
+            <arg value="${file.dir}/${file.name}.wsl"/>
+        </exec>
+        
+        <exec executable="${fermat.dir}/bin/wsl" 
+        input="${inputfile}"
+        error="${samples.temp.dir}/outputs/${file.out}.errwslt"
+        output="${samples.temp.dir}/outputs/${file.out}.outwslt" >
+            <env key="PATH" path="${fermat.dir}/bin:${env.PATH}"/>
+            <env key="FermaT" path="${fermat.dir}" />
+            <env key="SCHEME_LIBRARY_PATH" path="${fermat.dir}/slib/" />
+            <env key="SCM_INIT_PATH" path="${fermat.dir}/scm/Init5e7.scm" />
+            <arg value="${file.dir}/${file.name}${transf.wsl.ext}"/>
+        </exec>
+        
+        <exec executable="perl">
+            <arg value="lib/compare-w-wt.pl"/>
+            <arg value="${file.dir}/outputs"/>
+            <arg value="${file.out}"/>
+        </exec>
+    </target>
+
+    <target name="test-fn">
+        <basename property="file.name" file="${filename}" suffix=".obj"/>
+        <dirname property="file.dir" file="${filename}"/>
+        <foreach param="inputfile" target="test-m-w" inheritall="true">
+            <path>
+            <fileset dir='${tests.dir}'>
+                <include name="${file.name}*.txt"/>
+            </fileset>
+            </path>
+        </foreach>
+    </target>
+    
+    <target name="test-fn-t">
+        <basename property="file.name" file="${filename}" suffix="${transf.wsl.ext}"/>
+        <dirname property="file.dir" file="${filename}"/>
+        <foreach param="inputfile" target="test-w-wt" inheritall="true">
+            <path>
+            <fileset dir='${tests.dir}'>
+                <include name="${file.name}*.txt"/>
+            </fileset>
+            </path>
+        </foreach>
+    </target>
+    
+    <target name="test-all-m" depends="init-compare"
+    description="Run all the tests from the test directory to compare MJ and WSL" >
+        <foreach param="filename" target="test-fn" inheritall="true">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*.obj"/>
+            </fileset>
+            </path>
+        </foreach>
+    </target>
+
+    <target name="test-all-t" depends="init-compare"
+    description="Run all the tests from the test directory to compare WSL and transformations" >
+        <foreach param="filename" target="test-fn-t">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*${transf.wsl.ext}"/>
+            </fileset>
+            </path>
+        </foreach>
+    </target>
+    
+    <target name="q-test">
+    <!-- for quick tests -->
+        <antcall target="test-fn">
+            <param name="file.name" value="Rek1"/>
+            <param name="file.dir" value="${samples.temp.dir}"/>
+        </antcall>
+    </target>
+    
+    <!-- output serveral versions of files -->
+
+    <target name="output-all-versions"
+        description="generate variations on the translations in the 'local' folder and tar them">
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/headTail-proc"/>
+            <param name="mjc2wsl.options" value=""/>
+        </antcall>
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/headTail-inline"/>
+            <param name="mjc2wsl.options" value="--genInlinePrint"/>
+        </antcall>
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/popPush-inline"/>
+            <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint"/>
+        </antcall>
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/popPush-proc"/>
+            <param name="mjc2wsl.options" value="--genPopPush"/>
+        </antcall>
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/popPush-glob"/>
+            <param name="mjc2wsl.options" value="--genPopPush --genGlobalVars"/>
+        </antcall>
+        <tar basedir="local/out" compression="gzip"
+            destfile="local/mjc2wsl-samples.tgz"
+            includes="*/*.wsl"/>
+    </target>
+
     <!-- jedit specific flags; needs to be the first or the last 10 lines
     :noTabs=true:
     -->
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner