gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - add wsl metrics tasks
[mjc2wsl.git] / build.xml
index f8bde04..9af121c 100644 (file)
--- a/build.xml
+++ b/build.xml
     <property name="transf.wsl.ini" value="transf.ini" />
     <property name="transf.wsl.ext" value="_t.wsl" />
     
+    <property name="metrics.wsl.file" value="src-wsl/metrics.wsl" />
+    <property name="metrics.extension" value=".met" />
+
     <property name="tests.dir" value="tests" />
 
     <property name="log.dir" value="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" />
 
     <description>
         Builder script for mjc2wsl and related tools, runs test
         <exclude name="**/*${transf.wsl.ext}"/>
     </patternset>
 
+    <patternset id="transformed.sources">
+        <include name="**/*${transf.wsl.ext}"/>
+    </patternset>
+
     <!-- general tasks -->
 
     <target name="init" depends="init-time">
 
     <target name="wsl-run" >
         <property name="args" value=""/>
-        <exec executable="${fermat.dir}/bin/wsl" inputstring="${inputstring}">
+        <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/" />
             </fileset>
             </path>
         </foreach>
-        <record name="${log.file.tests}${time}.txt" action="stop" />
+        <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"
+    <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}'>
             </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">
             <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>
+
+        <!--
+        <echo>-o ${metrics.temp.name}.met -c ${metrics.temp.name}.wsl ${metrics.temp.name}${transf.wsl.ext}</echo>
+        -->
+    </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>
+            </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"
             includes="*/*.wsl"/>
     </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:
     -->
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner