gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - new tasks for making parallel code stages display in a pdf
[mjc2wsl.git] / build.xml
index 3712f02..206065d 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <project name="mjc2wsl" default="all">
     <property file="custom.properties"/>
     <property environment="env"/>
 <project name="mjc2wsl" default="all">
     <property file="custom.properties"/>
     <property environment="env"/>
-    
+
      <condition property="fermat.dir" value="C:\fermat3">
        <os family="windows" />
      </condition>
      <condition property="fermat.dir" value="C:\fermat3">
        <os family="windows" />
      </condition>
@@ -10,7 +10,7 @@
        <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"/>
     
@@ -55,7 +55,7 @@
         <include name="**/*.wsl"/>
         <exclude name="**/*${transf.wsl.ext}"/>
     </patternset>
         <include name="**/*.wsl"/>
         <exclude name="**/*${transf.wsl.ext}"/>
     </patternset>
-    
+
     <!-- general tasks -->
 
     <target name="init" depends="init-time">
     <!-- general tasks -->
 
     <target name="init" depends="init-time">
             <fileset dir="${log.dir}"/>
         </delete>
     </target>
             <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>
-       
+    
+    <!-- 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,update-version-string" description="build the mjc2wsl tool">
     <!-- mjc2wsl related tasks -->
     
     <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
 
     <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
         <echo message="${filename}" />
 
     <target name="mj-decode" description="decode a MJ obj file given in ${filename}">
         <echo message="${filename}" />
-        <java classpath="${compiler.class.dir}:${compiler.class.jar}" classname="${compiler.classname.decoder}">
+        <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="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"/>
+    <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}'>
         <foreach param="filename" target="mj-decode">
             <path>
             <fileset dir='${samples.temp.dir}'>
             </fileset>
             </path>
         </foreach>
             </fileset>
             </path>
         </foreach>
-        <record name="${samples.temp.dir}/decoded.txt" action="stop"/>
     </target>
     
     <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
     </target>
     
     <target name="mj-run" description="run a MJ obj file given in ${filename} with ${inputstring}">
     
     <target name="manual-test-run" 
     description="run .obj .wsl ${transf.wsl.ext}, given are ${file.dir}, ${file.name} (no extension) and an ${inputstring}">
     
     <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">
+        <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>
             <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" />
+        <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>
         <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" />
+        <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>
         <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" />
+        <record name="${file.dir}/${file.name}.out3" action="stop" />
     </target>
     
     <target name="manual-test-run-samples-dir"
     </target>
     
     <target name="manual-test-run-samples-dir"
             includes="*/*.wsl"/>
     </target>
 
             includes="*/*.wsl"/>
     </target>
 
+
+    <!-- output a comparison Latex file and compile it -->
+
+    <target name="output-comparison-pdf-single">
+        <basename property="file.name" file="${filename}" suffix=".obj"/>
+        <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="*.obj"/>
+            </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:
     -->
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner