gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl, default to PushPop, change some of the information output
[mjc2wsl.git] / build.xml
index 1b7010b..762aef3 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,17 @@
 <project name="mjc2wsl" default="all">
 <project name="mjc2wsl" default="all">
+    <description>
+        Builder script for mjc2wsl and related tools, runs tests
+        on given samples.
+    </description>
+
+    <!-- use this file for any custom local needs -->
     <property file="custom.properties"/>
     <property file="custom.properties"/>
-    
+    <property environment="env"/>
+
+    <!-- try and detect the fermat.dir based on the operating system
+        should be set as a custom value in "custom.properties"
+        if it's in a non default location.
+    -->
      <condition property="fermat.dir" value="C:\fermat3">
        <os family="windows" />
      </condition>
      <condition property="fermat.dir" value="C:\fermat3">
        <os family="windows" />
      </condition>
        <not><os family="windows" /></not>
      </condition>
 
        <not><os family="windows" /></not>
      </condition>
 
-    
     <property name="java.encoding" value="utf-8" />
     <taskdef resource="net/sf/antcontrib/antlib.xml"/>
     <property name="java.encoding" value="utf-8" />
     <taskdef resource="net/sf/antcontrib/antlib.xml"/>
-    
+
+    <!-- **************************************** -->
+    <!-- main variables that can be altered in the
+        properties file or through command line switches.
+    -->
+    <!-- **************************************** -->
+
+    <!-- when using multiple threads there is a problem with logging!-->
+    <property name="global.max.threads" value="1" />
+
     <property name="mjc2wsl.class.dir" value="bin" />
     <property name="mjc2wsl.src.dir" value="src" />
     <property name="mjc2wsl.options" value="" />
     <property name="mjc2wsl.class.dir" value="bin" />
     <property name="mjc2wsl.src.dir" value="src" />
     <property name="mjc2wsl.options" value="" />
+    <property name="mjc2wsl.main" value="com.quemaster.transformations.mjc2wsl.Mjc2wsl" />
 
     <property name="res.dir" value="res" />
 
     <property name="res.dir" value="res" />
-    
-    <property name="compiler.class.dir" value="compiler-bin" />
-    <property name="compiler.src.dir" value="compiler" />
+    <property name="dist.dir" value="dist" />
 
 
-    <property name="samples.main.dir" value="samples" />
-    <property name="samples.temp.dir" value="samples-temp" />
+    <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" />
+    <property name="compiler.classname.interpreter" value="MJ.Run" />
+    <property name="compiler.classname.decoder" value="MJ.Decode" />
 
 
-    <property name="transf.wsl.file" value="src-wsl/transf-min.wsl" />
+    <property name="samples.main.dir" value="samples/alpha-mj" />
+    <property name="samples.temp.dir" value="temp/alpha-mj" />
+
+    <property name="transf.wsl.file" value="src-wsl/hill_climbing.wsl" />
     <property name="transf.wsl.ini" value="transf.ini" />
     <property name="transf.wsl.ini" value="transf.ini" />
+    <property name="transf.wsl.ext" value="_tr.wsl" />
+    <!-- args can be used to send additional arguments to a script -->
+    <property name="transf.wsl.args" value="" />
 
 
-    <description>
-        Builder script for mjc2wsl and related tools, runs test
-        on given samples.
-        
-        Also gives options to chain the tools on individual files.
-    </description>
+    <property name="metrics.wsl.file" value="src-wsl/metrics_csv.wsl" />
+    <property name="metrics.extension" value=".met" />
+
+    <property name="tests.dir" value="tests" />
 
 
-    <target name="init">
+    <property name="log.dir" value="${basedir}/logs" />
+    <property name="log.file.transformations" value="${log.dir}/transformations" />
+    <property name="log.file.mjc2wsl" value="${log.dir}/mjc2wsl" />
+    <property name="log.file.tests.m" value="${log.dir}/tests-mj" />
+    <property name="log.file.tests.t" value="${log.dir}/tests-wsl" />
+
+    <property name="version.file" value="${res.dir}/com/quemaster/transformations/mjc2wsl/version.properties" />
+
+    <!-- **************************************** -->
+    <!-- patterns -->
+    <!-- **************************************** -->
+
+    <patternset id="non.transformed.sources">
+        <include name="**/*.wsl"/>
+        <exclude name="**/*${transf.wsl.ext}"/>
+    </patternset>
+
+    <patternset id="transformed.sources">
+        <include name="**/*${transf.wsl.ext}"/>
+    </patternset>
+
+    <!-- **************************************** -->
+    <!-- general tasks -->
+    <!-- **************************************** -->
+
+    <target name="init" depends="init-time">
         <mkdir dir="${mjc2wsl.class.dir}"/>
         <mkdir dir="${compiler.class.dir}"/>
         <mkdir dir="${samples.temp.dir}"/>
         <mkdir dir="${mjc2wsl.class.dir}"/>
         <mkdir dir="${compiler.class.dir}"/>
         <mkdir dir="${samples.temp.dir}"/>
+        <mkdir dir="${log.dir}"/>
+        <mkdir dir="${dist.dir}"/>
         <copy todir="${samples.temp.dir}">
             <fileset dir="${samples.main.dir}">
                 <include name="*.mj"/>
         <copy todir="${samples.temp.dir}">
             <fileset dir="${samples.main.dir}">
                 <include name="*.mj"/>
         </copy>
     </target>
 
         </copy>
     </target>
 
-    <target name="build" depends="init" description="build the mjc2wsl tool">
+    <target name="init-time">
+        <tstamp>
+          <format property="time" pattern="yy-MM-dd--HH-mm-ss-SSS"/>
+        </tstamp>
+    </target>
+
+    <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples,metrics-samples-compare-wsl'
+        description="build the tools, run them on the samples to check">
+
+    </target>
+
+    <target name="clean" description="clean up all the generated content">
+        <delete includeemptydirs="true">
+            <fileset dir="${mjc2wsl.class.dir}"/>
+            <fileset dir="${compiler.class.dir}"/>
+            <fileset dir="${samples.temp.dir}"/>
+            <fileset dir="${log.dir}"/>
+        </delete>
+    </target>
+
+    <target name="pack.jar" depends="build,update-version-string"
+            description="Packs the binaries in a jar and place it in ${dist.dir}">
+
+        <mkdir dir="${dist.dir}"/>
+        <jar destfile="${dist.dir}/mjc2wsl.jar"
+             includes="**">
+            <manifest>
+              <attribute name="Built-By" value="${user.name}"/>
+              <attribute name="Implementation-Vendor"
+              value="Doni Pracner"/>
+              <attribute name="Implementation-Title"
+               value="MicroJava bytecode to WSL"/>
+              <attribute name="Implementation-Version" value="${version}"/>
+              <attribute name="Main-Class" value="${mjc2wsl.main}"/>
+            </manifest>
+            <fileset dir="${mjc2wsl.class.dir}"/>
+        </jar>
+
+    </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="${version.file}"/>
+    </target>
+
+    <target name="-store-version-string" if="version">
+            <!-- store the new  version string in the correct property file -->
+            <echo message="version=${version}"/>
+            <dirname file="${version.file}" property="version.file.dir"/>
+            <mkdir dir="${version.file.dir}" />
+            <propertyfile file="${version.file}">
+                    <entry key="version" value="${version}"/>
+            </propertyfile>
+            <exec executable="git" failifexecutionfails="false">
+                    <arg value="update-index"/>
+                    <arg value="--assume-unchanged"/>
+                    <arg value="${version.file}"/>
+            </exec>
+    </target>
+
+    <!-- **************************************** -->
+    <!-- mjc2wsl related tasks -->
+    <!-- **************************************** -->
+
+    <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
         <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
         <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
+        <copy todir="${mjc2wsl.class.dir}">
+            <fileset dir="${res.dir}"/>
+        </copy>
+    </target>
+
+    <target name="mjc2wsl">
+        <echo message="${filename}" />
+        <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="${mjc2wsl.main}">
+            <arg line="${mjc2wsl.options}" />
+            <arg value="${filename}" />
+        </java>
+    </target>
+
+    <target name="mjc2wsl-samples" depends="build,init-time" description="run the mjc2wsl tool on the samples">
+        <record name="${log.file.mjc2wsl}${time}.txt" emacsmode="true" />
+        <echo>Used options:${mjc2wsl.options}</echo>
+        <foreach param="filename" target="mjc2wsl"  parallel="true" maxthreads="${global.max.threads}">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*.obj"/>
+            </fileset>
+            </path>
+        </foreach>
+        <record name="${log.file.mjc2wsl}${time}.txt" action="stop" />
+        <copy file="${log.file.mjc2wsl}${time}.txt" tofile="${log.file.mjc2wsl}.txt"/>
     </target>
 
     </target>
 
+    <target name="mjc2wsl-samples1" depends="build">
+    <!-- simplistic version when antlib (foreach) is not available -->
+        <antcall target="mjc2wsl">
+            <param name="filename" value="samples-temp/sample0.obj" />
+        </antcall>
+    </target>
+
+
+    <!-- **************************************** -->
+    <!-- MicroJava related tasks -->
+    <!-- **************************************** -->
+
+
     <target name="mj-build" depends="init" description="build the mj compiler">
         <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
     </target>
     <target name="mj-build" depends="init" description="build the mj compiler">
         <javac srcdir="${compiler.src.dir}" destdir="${compiler.class.dir}" includeAntRuntime='no' />
     </target>
-    
-    <target name="mj-compile">
+
+    <target name="mj-compile" description="compile a MJ into obj file; given ${filename}">
         <echo message="${filename}" />
         <echo message="${filename}" />
-        <java classpath="${compiler.class.dir}" classname="Compiler">
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.compiler}">
             <arg value="${filename}" />
         </java>
     </target>
             <arg value="${filename}" />
         </java>
     </target>
-    
-    <target name="mj-samples" depends="mj-build" description="run the mj compiler on the samples">
-        <foreach param="filename" target="mj-compile">
+
+    <target name="mj-samples" description="run the mj compiler on the samples" depends="init">
+        <foreach param="filename" target="mj-compile"  parallel="true" maxthreads="${global.max.threads}">
             <path>
             <fileset dir='${samples.temp.dir}'>
                 <include name="*.mj"/>
             <path>
             <fileset dir='${samples.temp.dir}'>
                 <include name="*.mj"/>
         </foreach>
     </target>
 
         </foreach>
     </target>
 
-    <target name="mj-samples1" depends="mj-build">
-    <!-- simplistic version when antlib (foreach) is not available -->
-        <antcall target="mj-compile">
-            <param name="filename" value="samples-temp/sample.mj" />
-        </antcall>
-        <antcall target="mj-compile">
-            <param name="filename" value="samples-temp/sample1.mj" />
-        </antcall>
-        <antcall target="mj-compile">
-            <param name="filename" value="samples-temp/sample0.mj" />
-        </antcall>
-    </target>
-    
-    <target name="mjc2wsl">
+    <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
         <echo message="${filename}" />
         <echo message="${filename}" />
-        <java classpath="${mjc2wsl.class.dir}:${res.dir}" classname="mjc2wsl">
-            <arg line="${mjc2wsl.options}" />
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}"
+              classname="${compiler.classname.decoder}"
+              output="${filename}.decoded" >
             <arg value="${filename}" />
         </java>
     </target>
             <arg value="${filename}" />
         </java>
     </target>
-    
-    <target name="mjc2wsl-samples" depends="build" description="run the mjc2wsl tool on the samples">
-        <foreach param="filename" target="mjc2wsl">
+
+    <target name="mj-decode-samples" description="decode all of the obj files in ${samples.temp.dir}">
+        <foreach param="filename" target="mj-decode">
             <path>
             <fileset dir='${samples.temp.dir}'>
                 <include name="*.obj"/>
             <path>
             <fileset dir='${samples.temp.dir}'>
                 <include name="*.obj"/>
             </path>
         </foreach>
     </target>
             </path>
         </foreach>
     </target>
-    
-    <target name="mjc2wsl-samples1" depends="build">
+
+    <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
+        <echo message="${filename}" />
+        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.interpreter}" inputstring="${inputstring}">
+            <arg value="${filename}" />
+        </java>
+    </target>
+
+    <target name="mj-samples1" depends="mj-build">
     <!-- simplistic version when antlib (foreach) is not available -->
     <!-- simplistic version when antlib (foreach) is not available -->
-        <antcall target="mjc2wsl">
-            <param name="filename" value="samples-temp/sample0.obj" />
+        <antcall target="mj-compile">
+            <param name="filename" value="samples-temp/sample.mj" />
+        </antcall>
+        <antcall target="mj-compile">
+            <param name="filename" value="samples-temp/sample1.mj" />
+        </antcall>
+        <antcall target="mj-compile">
+            <param name="filename" value="samples-temp/sample0.mj" />
         </antcall>
     </target>
         </antcall>
     </target>
-    
+
+
+    <!-- **************************************** -->
+    <!-- wsl related tasks -->
+    <!-- **************************************** -->
+
     <target name="wsl-run" >
     <target name="wsl-run" >
-        <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
-            <env key="PATH" path="${env.PATH}:${fermat.dir}/bin"/>
+        <property name="args" value=""/>
+        <property name="wslrun.workdir" value=""/>
+        <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}"
+            dir="${wslrun.workdir}" >
+            <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="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>
         </exec>
     </target>
-    
-    <target name="wsl-transf" 
+
+    <target name="wsl-transf"
         description="transform (simplify) a single wsl file generated by mjc2wsl">
         description="transform (simplify) a single wsl file generated by mjc2wsl">
-        <delete file="${transf.wsl.ini}"/>
-        
+        <stopwatch name="transf-${transf.filename}" action="start"/>
         <antcall target="wsl-run">
             <param name="filename" value="${transf.wsl.file}" />
         <antcall target="wsl-run">
             <param name="filename" value="${transf.wsl.file}" />
-            <param name="inputstring" value="${transf.filename}" />
+            <param name="args" value="${transf.wsl.args} ${transf.filename}" />
         </antcall>
         </antcall>
+        <record name="${transf.filename}-time.txt" action="start" emacsmode="true"/>
+        <stopwatch name="transf-${transf.filename}" action="total"/>
+        <record name="${transf.filename}-time.txt" action="stop"/>
+    </target>
+
+    <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" parallel="true" maxthreads="${global.max.threads}">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <patternset refid="non.transformed.sources"/>
+                <depth max="0"/>
+            </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>
-    
-    <target name="wsl-transf-samples" depends="make-transf-ini-samples"
-        description="transform (simplify) the wsl files generated by mjc2wsl">
+
+    <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>
         <antcall target="wsl-run">
             <param name="filename" value="${transf.wsl.file}" />
         </antcall>
+        <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>
-    
+
     <target name="make-transf-ini-samples">
         <fileset dir="${samples.temp.dir}" casesensitive="no" id="generated-wsl-fileset">
     <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>
         </fileset>
-        <pathconvert pathsep="${line.separator}" 
+        <pathconvert pathsep="${line.separator}"
             property="generated-wsl-files" refid="generated-wsl-fileset" />
 
         <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
     </target>
             property="generated-wsl-files" refid="generated-wsl-fileset" />
 
         <echo file="${transf.wsl.ini}">${generated-wsl-files}</echo>
     </target>
-    
-    <target name="all" depends='mj-samples,mjc2wsl-samples,wsl-transf-samples'
-        description="build the tools, run them on the samples to check">
-    
+
+
+    <!-- **************************************** -->
+    <!-- Testing tasks -->
+    <!-- **************************************** -->
+
+    <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}${transf.wsl.ext}" />
+            <param name="inputstring" value="${inputstring}" />
+        </antcall>
+        <record name="${file.dir}/${file.name}.out3" action="stop" />
     </target>
     </target>
-    
-    <target name="clean" description="clean up all the generated content">
-        <delete includeemptydirs="true">
-            <fileset dir=".">
-                <include name="${mjc2wsl.class.dir}/*.class"/>
-                <include name="${compiler.class.dir}/*.class"/>
-                <include name="${samples.temp.dir}/*"/>
+
+    <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,init-time"
+    description="Run all the tests from the test directory to compare MJ and WSL" >
+        <record name="${log.file.tests.m}${time}.txt" emacsmode="true" />
+        <foreach param="filename" target="test-fn" inheritall="true">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*.obj"/>
+            </fileset>
+            </path>
+        </foreach>
+        <record name="${log.file.tests.m}${time}.txt" action="stop" />
+        <move file="${log.file.tests.m}.txt" tofile="${log.file.tests.m}-previous.txt" failonerror="false"/>
+        <copy file="${log.file.tests.m}${time}.txt" tofile="${log.file.tests.m}.txt"/>
+    </target>
+
+    <target name="test-all-t" depends="init-compare,init-time"
+    description="Run all the tests from the test directory to compare WSL and transformations" >
+        <record name="${log.file.tests.t}${time}.txt" emacsmode="true" />
+        <foreach param="filename" target="test-fn-t">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*${transf.wsl.ext}"/>
+            </fileset>
+            </path>
+        </foreach>
+        <record name="${log.file.tests.t}${time}.txt" action="stop" />
+        <move file="${log.file.tests.t}.txt" tofile="${log.file.tests.t}-previous.txt" failonerror="false"/>
+        <copy file="${log.file.tests.t}${time}.txt" tofile="${log.file.tests.t}.txt"/>
+    </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>
+
+
+    <!-- **************************************** -->
+    <!-- metrics -->
+    <!-- **************************************** -->
+
+    <target name="metrics-compare-wsl">
+        <basename property="metrics.temp.name" file="${metrics.run.filename}" suffix="${transf.wsl.ext}"/>
+        <dirname property="metrics.temp.dir" file="${metrics.run.filename}"/>
+        <antcall target="wsl-run">
+            <param name="filename" value="${metrics.wsl.file}" />
+            <param name="args" value="-o ${metrics.temp.dir}/${metrics.temp.name}${metrics.extension} -c ${metrics.temp.dir}/${metrics.temp.name}.wsl ${metrics.temp.dir}/${metrics.temp.name}${transf.wsl.ext}" />
+
+        </antcall>
+
+    </target>
+
+    <target name="metrics-samples-compare-wsl" depends="init"
+    description="metrics on transformed wsl files (csv file)" >
+
+        <antcall target="wsl-run">
+            <param name="filename" value="${metrics.wsl.file}" />
+            <param name="args" value="-o ${samples.temp.dir}/0000-header${metrics.extension} -HC" />
+
+        </antcall>
+
+        <foreach param="metrics.run.filename" target="metrics-compare-wsl" parallel="true" maxthreads="${global.max.threads}">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <patternset refid="transformed.sources"/>
             </fileset>
             </fileset>
-            <dirset dir=".">
-                <include name="${mjc2wsl.class.dir}"/>
-                <include name="${compiler.class.dir}"/>
-                <include name="${samples.temp.dir}"/>
-            </dirset>
+            </path>
+        </foreach>
+
+        <concat destfile="${samples.temp.dir}/metrics-wsl-compare.csv">
+          <fileset dir="${samples.temp.dir}" includes="*${metrics.extension}"/>
+        </concat>
+    </target>
+
+
+    <!-- **************************************** -->
+    <!-- output serveral versions of files -->
+    <!-- **************************************** -->
+
+    <target name="output-all-versions"
+        description="generate variations on the translations in the 'local' folder and tar them">
+        <delete>
+                <fileset dir="local/out/"/>
         </delete>
         </delete>
+        <mkdir dir="local/out"/>
+        <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>
+        <antcall>
+            <target name="mj-samples"/>
+            <target name="mjc2wsl-samples"/>
+            <param name="samples.temp.dir" value="local/out/popPush-loc-separate"/>
+            <param name="mjc2wsl.options" value="--genPopPush --genInlinePrint --genLocalsSeparate --genLocalVars"/>
+        </antcall>
+        <tar basedir="local/out" compression="gzip"
+            destfile="local/mjc2wsl-samples.tgz"
+            includes="*/*.wsl"/>
     </target>
     </target>
-    
+
+
+    <!-- **************************************** -->
+    <!-- output a comparison Latex file and compile it -->
+    <!-- **************************************** -->
+
+    <target name="output-comparison-pdf-single">
+        <basename property="file.name" file="${filename}" suffix=".mj"/>
+        <echo append='true' file="${samples.temp.dir}/tex/comparison.tex">
+        \section{${file.name}}
+        \begin{paracol}{4}
+        \lstinputlisting[style=mj]{../${file.name}.mj}
+        \switchcolumn
+        \lstinputlisting[style=decoded]{../${file.name}.obj.decoded}
+        \switchcolumn
+        \lstinputlisting[style=wsl,lastline=200]{../${file.name}.wsl}
+        \switchcolumn
+        \lstinputlisting[style=wslt,lastline=200]{../${file.name}${transf.wsl.ext}}
+        \end{paracol}
+        </echo>
+    </target>
+
+    <target name="output-comparison-pdf"
+        description="Makes a parallel display in Latex and produces a pdf (tex dir in temp dir)" >
+
+        <copy file="lib/tex/comparison-start.tex" overwrite="true"
+            tofile="${samples.temp.dir}/tex/comparison.tex"/>
+        <foreach param="filename" target="output-comparison-pdf-single" inheritall="true">
+            <path>
+            <fileset dir='${samples.temp.dir}'>
+                <include name="*.mj"/>
+            </fileset>
+            </path>
+        </foreach>
+        <concat destfile="${samples.temp.dir}/tex/comparison.tex" append="true">
+            <filelist dir="lib/tex" files="comparison-end.tex"/>
+        </concat>
+        <antcall target="output-comparison-compile"/>
+    </target>
+
+    <target name="output-comparison-compile">
+        <exec command="pdflatex comparison.tex"
+              dir="${samples.temp.dir}/tex"/>
+    </target>
+
     <!-- jedit specific flags; needs to be the first or the last 10 lines
     :noTabs=true:
     -->
     <!-- jedit specific flags; needs to be the first or the last 10 lines
     :noTabs=true:
     -->
-</project>
\ No newline at end of file
+</project>
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner