summaryrefslogblamecommitdiff
path: root/src/build/msil.xml
blob: e64c88714fe643f6622190180111ee6f895fac02 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                      
               


                                                                                                                                                                           
                                                                   


                                                                                  
                                                  
                                                                               
 



                                                                                

                                                         




                                                     



                                                                       

                                                                                
              
                                                                                












                                                                                  
















                                                                    


                                                                 
                                                         

                                                                     

           
                                                          




                                
                                      




                           
                               


             

           







                                                                                

                                                                                 
                                        
                                                         

                                                             




                                                                               

                                                                    

                                                                             
           












                                                            

           




                                                                                                       
           


                                           
                               


                                               
             
                                                     
















                                                                                             
                                                      
                                                                     
                  
                                                                                       


















                                                                                         
                                                                       
           

           


                                                       
              
                                 







                                                               
                                             
              
                                 







                                                               

                                                         


                                
            


                                                 
                                                        

                                         
                                                               



                


                                                          
                


                                                              
                






                                                                



             





                                                                                              















                                                                                




                                                                                


                                                                                      

                                                         

                                       

                                               

                                                                
           


                                                       

                                       

                                               
           
                                                   


                                                    












                                                                                          
 
          

 
<?xml version="1.0" encoding="UTF-8"?>

<project name="sabbus-msil">

  <description>
    SuperSabbus extension for the MSIL library targeted for the dotnet framework. THIS FILE IS NOT STAND-ALONE AND SHOULD ONLY BE USED THROUGH ENTRY POINTS IN SUPERSABBUS.
  </description>

  <!-- TODO: test / make it work on Windows (use <ilasm/> task) -->
  <!-- TODO: for separate compilation: make sure only files that have been changed
             since last run are re-compiled -->
  <!-- TODO: run test suite (or at least a part of it) on .NET -->
  <!-- TODO: generate scaladoc of .NET library -->
  <!-- TODO: (?) generate the runner scripts with scala.tools.ant.ScalaTool -->

<!-- ===========================================================================
PROPERTIES
============================================================================ -->

  <!-- contains the scala-net / scalac-net commands -->
  <property name="src-mono.dir" value="${src.dir}/mono"/>

  <!-- Loads custom properties definitions -->
  <property file="${src.dir}/build/msil.properties"/>

  <!-- Sets location of build folders -->
  <property name="build-msil.dir" value="${build.dir}/msil"/>
  <property name="build-msil-src.dir" value="${build.dir}/msil-src"/>
  <property name="build-msil-pack.dir" value="${build.dir}/msil-pack"/>


<!-- ===========================================================================
INITIALISATION
============================================================================ -->
  <target name="msil.init">
    <!-- define the "ilasm" task (and others). they are in fact already there from
         antlib.xml, but in a deprecated version. -->
    <!-- <taskdef resource="org/apache/ant/dotnet/antlib.xml"
             classpath="${lib-ant.dir}/ant-dotnet-1.0.jar"/> -->

    <!-- Sets ilasm command. Search in
           - dotnet.home/ilasm.exe
           - unix.mono.home/ilasm
           - win.mono.home/lib/mono/2.0/ilasm.exe
           - path
         (the ".home"s can be set in msil.properties) -->
    <condition property="ilasm.cmd" value="${dotnet.home}/ilasm.exe">
      <and>
        <os family="windows"/><isset property="dotnet.home"/>
        <available file="${dotnet.home}/ilasm.exe"/>
      </and>
    </condition>
    <condition property="ilasm.cmd" value="${unix.mono.home}/ilasm">
      <and>
        <os family="unix"/><isset property="unix.mono.home"/>
        <available file="${unix.mono.home}/ilasm"/>
      </and>
    </condition>
    <condition property="ilasm.cmd" value="${win.mono.home}/ilasm">
      <and>
        <os family="windows"/><isset property="win.mono.home"/>
        <available file="${win.mono.home}/lib/mono/2.0/ilasm.exe"/>
      </and>
    </condition>
    <condition property="ilasm.cmd" value="ilasm">
      <and><available file="ilasm" filepath="${env.PATH}"/></and>
    </condition>
    <echo level="verbose" message="Found: ${ilasm.cmd}"/>
    <fail message="Command 'ilasm' not found">
      <condition><not><isset property="ilasm.cmd"/></not></condition>
    </fail>

    <!-- Sets ilasm arguments (either Windows or Unix) -->
    <if>
      <isset property="os.win"/>
      <then>
        <property
          name="ilasm.args"
          value="/quiet /dll /output="
        />
      </then>
      <else>
        <property
          name="ilasm.args"
          value="/dll /output:"
        />
      </else>
    </if>
  </target>


<!-- ===========================================================================
MSIL BUILD
============================================================================ -->

  <target name="msil.start" depends="msil.init"/>

  <target name="msil.src" depends="msil.start">
    <!-- simple sync & copy overwrite is not very nice, because overwritten files
         will then have a new timestamp, and be recompiled -->
    <mkdir dir="${build-msil-src.dir}"/>
    <copy todir="${build-msil-src.dir}" overwrite="true">
      <!-- FIXME: include new collection library -->
      <fileset dir="${src.dir}/library" excludes="scalax/**">
        <and>
          <present present="srconly" targetdir="${src.dir}/dotnet-library"/>
          <different targetdir="${build-msil-src.dir}" ignoreFileTimes="true"/>
        </and>
      </fileset>
      <!-- FIXME: include new collection library -->
      <fileset dir="${src.dir}/dotnet-library" excludes="scalax/**">
        <different targetdir="${build-msil-src.dir}" ignoreFileTimes="true"/>
      </fileset>
    </copy>
    <delete verbose="true">
      <difference>
        <fileset dir="${build-msil-src.dir}"/>
        <union>
          <fileset dir="${build-msil-src.dir}">
            <present targetdir="${src.dir}/dotnet-library"/>
          </fileset>
          <fileset dir="${build-msil-src.dir}">
            <present targetdir="${src.dir}/library"/>
          </fileset>
        </union>
      </difference>
    </delete>
  </target>

  <target name="msil.lib" depends="msil.src">
    <stopwatch name="msil.lib.timer"/>
    <mkdir dir="${build-msil.dir}/library"/>
    <!-- <ilasm srcdir="${msil.dir}/il" includes="*.msil" outputfile="${msil.dir}/lib/predef.dll"/> -->

    <scalac
        srcdir="${build-msil-src.dir}"
        destdir="${build-msil.dir}/library"
        target="msil"
        assemname="predef.msil"
        assemrefs="${lib.dir}">
      <include name="**/*.scala"/>
      <exclude name="scala/ScalaObject.scala"/>
    </scalac>
    <stopwatch name="msil.lib.timer" action="total"/>
  </target>

  <target name="msil.done" depends="msil.lib"/>

  <target name="msil.clean" depends="msil-pack.clean">
    <delete dir="${build-msil.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
    <delete dir="${build-msil-src.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
  </target>

<!-- ===========================================================================
PACKED MSIL BUILD (MSIL-PACK)
============================================================================ -->

  <target name="msil-pack.start" depends="msil.done"/>

  <target name="msil-pack.lib" depends="msil-pack.start">
    <mkdir dir="${build-msil-pack.dir}/lib"/>
    <pathconvert property="ilasm.infiles" pathsep=" ">
      <fileset dir="${build-msil.dir}/library" includes="**/*.msil"/>
    </pathconvert>
    <property name="msil-pack-lib.file" value="${build-msil-pack.dir}/lib/predef.dll"/>

    <!--
        NOTE: Command line length hell on windows. The maximal command line length on
        Windows XP or later is 8191 characters (http://support.microsoft.com/kb/830473).

        BUT: this only applies for processes executed directly in the shell, which is NOT
        the case by default when using ant's "exec" command; this one uses the Java VM's
        execution facilities which allow larger command lines. Testing gives:
          - Windows XP: 32768 characters

        When the parameter (vmlauncher="false") is specified, the <exec/> command uses
        the udnerlying shell, and the smaller limit applies.

        The call to ilasm produces lots of output, which could be avoided using
        (spawn="true"). This seems to work wrt to the character limit (32768), but is
        probably not the best solution since it's incompatible with (failonerror),
        and does not produce any output at all.
    -->
    <exec executable="${ilasm.cmd}" failonerror="true">
      <arg line="${ilasm.args}${msil-pack-lib.file} ${ilasm.infiles}"/>
    </exec>
  </target>

  <target name="msil-pack.bin" depends="msil-pack.lib">
    <mkdir dir="${build-msil-pack.dir}/bin"/>
    <copy todir="${build-msil-pack.dir}/bin">
      <fileset
        dir="${src-mono.dir}/bin"
        includes="scala-net*"
      />
      <filterset>
        <filter token="VERSION" value="${version.number}"/>
        <filter token="COPYRIGHT" value="${copyright.string}"/>
        <filter token="NAME" value="Scala code runner"/>
      </filterset>
    </copy>
    <copy todir="${build-msil-pack.dir}/bin">
      <fileset
        dir="${src-mono.dir}/bin"
        includes="scalac-net*"
      />
      <filterset>
        <filter token="VERSION" value="${version.number}"/>
        <filter token="COPYRIGHT" value="${copyright.string}"/>
        <filter token="NAME" value="Scala compiler"/>
      </filterset>
    </copy>
    <chmod perm="ugo+rx" dir="${build-msil-pack.dir}/bin"
           includes="scala*-net*" excludes="*.bat"/>

    <if>
      <isset property="os.win"/>
      <then>
        <copy todir="${build-msil-pack.dir}/lib">
          <fileset
              dir="${lib.dir}"
              includes="mscorlib.dll,scalaruntime.dll"/>
          <fileset
              dir="${build-pack.dir}/lib"
              includes="scala-compiler.jar,scala-library.jar"/>
        </copy>
      </then>
      <else>
        <symlink
            link="${build-msil-pack.dir}/lib/mscorlib.dll"
            resource="${lib.dir}/mscorlib.dll"
            overwrite="yes"/>
        <symlink
            link="${build-msil-pack.dir}/lib/scalaruntime.dll"
            resource="${lib.dir}/scalaruntime.dll"
            overwrite="yes"/>
        <symlink
            link="${build-msil-pack.dir}/lib/scala-compiler.jar"
            resource="${build-pack.dir}/lib/scala-compiler.jar"
            overwrite="yes"/>
        <symlink
            link="${build-msil-pack.dir}/lib/scala-library.jar"
            resource="${build-pack.dir}/lib/scala-library.jar"
            overwrite="yes"/>
      </else>
    </if>
  </target>

  <target name="msil-pack.done" depends="msil-pack.bin"/>

  <target name="msil-pack.clean">
    <delete dir="${build-msil-pack.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/>
  </target>

<!-- ===========================================================================
DOCUMENTATION
============================================================================ -->

  <!-- see four.xml for template -->
  <target name="msil-docs.done"/>

  <target name="msil-docs.clean"/>

<!-- ===========================================================================
BOOTRAPING TEST AND TEST SUITE
============================================================================ -->

  <!-- see four.xml for template -->
  <target name="msil-test.done"/>


<!-- ===========================================================================
DISTRIBUTION
============================================================================ -->

  <target name="msil-dist.start" depends="msil-pack.done">
    <property name="msil-dist.dir" value="${dists.dir}/scala-msil-${version.number}"/>
  </target>

  <target name="msil-dist.lib" depends="msil-dist.start">
    <mkdir dir="${msil-dist.dir}/lib"/>
    <copy toDir="${msil-dist.dir}/lib">
      <fileset dir="${build-msil-pack.dir}/lib"
               includes="*.dll"/>
      <fileset dir="${build-msil-pack.dir}/lib"
               includes="scala-compiler.jar,scala-library.jar"/>
    </copy>
  </target>

  <target name="msil-dist.bin" depends="msil-dist.lib">
    <mkdir dir="${msil-dist.dir}/bin"/>
    <copy toDir="${msil-dist.dir}/bin">
      <fileset dir="${build-msil-pack.dir}/bin"
               includes="scala*-net*"/>
    </copy>
    <chmod perm="ugo+rx" dir="${msil-dist.dir}/bin"
           includes="scala*-net*" excludes="*.bat"/>
  </target>

  <target name="msil-dist.latest" depends="msil-dist.bin" unless="os.win">
    <symlink link="${dists.dir}/latest-msil" resource="${msil-dist.dir}" overwrite="yes"/>
  </target>

  <target name="msil-dist.done" depends="msil-dist.latest"/>

<!-- ===========================================================================
TEST AND DISTRIBUTION BUNDLE (ALL)
============================================================================ -->

  <target name="msil-all.done" depends="msil-dist.done, msil-test.done"/>

  <target name="msil-all.clean" depends="msil-docs.clean, msil.clean"/>

</project>