ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet NetCommand.java Ilasm.java CSharp.java
Date Tue, 28 Nov 2000 13:35:49 GMT
bodewig     00/11/28 05:35:48

  Modified:    docs     dotnet.html
               src/main/org/apache/tools/ant/taskdefs/optional/dotnet
                        NetCommand.java Ilasm.java CSharp.java
  Log:
  Update of the .NET tasks.
  
  Submitted by:	Steve Loughran <steve_l@iseran.com>
  
  Revision  Changes    Path
  1.2       +366 -19   jakarta-ant/docs/dotnet.html
  
  Index: dotnet.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/dotnet.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dotnet.html	2000/11/09 16:18:46	1.1
  +++ dotnet.html	2000/11/28 13:35:47	1.2
  @@ -1,12 +1,13 @@
   <html>
   <head>
  -<title> .Net classes for Ant
  +<title> .NET classes for Ant
   </title>
  -<body>
  -<h1>.Net classes for Ant</h1>
  +<body bgcolor="#ffffff">
  +<h1>dotnet classes for Ant</h1>
   
  -
  -Vision: make ant the definative build tool for .net projects, just
  +<h3>Steve Loughran; steve_l@iseran.com</h3>
  +<h2>Vision</h2>
  +Make ant the definative build tool for .NET projects, just
   as it is becoming for java projects
   <p>
   
  @@ -44,9 +45,9 @@
   <li>ilasm - IL assembler - *.il -&gt;.exe or .dll
   <li>ResX - ResXToResources.exe .resx -&gt; .resources
   <li>al - assembly linker (.dll) -&gt;
  -<li>Signcode - .exe + keys -&gt; .exe'
  +<li>Signcode - .exe + keys -&gt; .exe
   <li>Resgen - .properties -&gt; .resources
  -<li>Type Library Exporter (TlbExp.exe- .dll -&gt; .tlb
  +<li>Type Library Exporter (TlbExp.exe) .dll -&gt; .tlb
   <li>TlbImp.exe Type Library Importer 
   <li>RegAsm.exe Assembly Registration Tool .dll -&gt; .reg | registration
   <li>WebServiceUtil -SOAP proxy import, SDL generation tool
  @@ -68,8 +69,9 @@
   
   <ol>
   
  -<li>code up C sharp task and distribute for feedback & identify possible
  +<li>code up C sharp task and distribute for feedback &amp; identify possible
   aid
  +<li>Use for a real end to end development task
   <li>Add the next task I need (whatever that is)
   <li>Refactor to produce a base class for .net tasks
   <li>Leave it other people write all the other tasks
  @@ -88,15 +90,12 @@
   <hr>
   <h2>Using Ant in .net projects</h2>
   
  -<h3>
  -Setup</h3>
  -
   To use the net tasks one needs
   <ul>
   
  -<li> A win2K box (or any other platform which supports the .net build tools)
  +<li> A Win2K box (or any other platform which supports the .net build tools)
   
  -<li> JavaVM - Java1.1 or later
  +<li> JavaVM - Java1.1 or later; Java1.3 recommended.
   
   <li> Ant downloaded and the environment and path variables set up so 
   that typing 'ant' invokes ant via a batch file.
  @@ -111,16 +110,364 @@
   
   <li> A build.xml file to describe the build process
   </ul>
  +
  +<hr>
  +<h2> Change Log </h2>
   
  -An example build.xml file is included in the test directory.
  +<h4>Version 0.3</h4>
   
  +The changes here reflect Beta-1 of the dotnet SDK and experience of use in 
  +more complex projects. This build does not work with the older SDK, 
  +primarily because the automatic reference feature references libraries
  +only found in the new SDK version.  
  +<p>
  +External changes
  +<ul>
  +<li>Recursive inclusion of .cs and .il files
  +
  +<li>Documentation enhanced, includes examples and details of all parameters
  +
  +<li>The csc task automatically includes the common dotnet assemblies, so
  +there is no need to remember to refer to 'System.dll', 'System.Web.Services',
  + etc. This feature can be disabled by setting the 'includeDefaultReferences' 
  + flag to false. 
  +
  + <li> References can also be referred to using the ReferenceFiles parameter, which
  +is an ant path specification. The old 'references' string is still retained.
  +<
  +li> An 'extraoptions' attribute enables the build file to include any CSC options
  +which are not explicitly supported in the CSC task. 
  +</ul>
  +
  +Internal changes
  +<ul>
  +<li>Some minor refactoring (move common code a method)
  +<li>Application of Jedits JavaStyle task resulted in a major reshaping of
  +the codebase and the insertion of a blank line every second line. Significant
  +effort was required to revert some (but not all) changes.
  +<li>Removed throws clause from methods which can't throw exceptions 
  +</ul>
  +
  +The test harness has been expanded to include unicode source file  
  +(the build works but the rest of the system has 'issues' with high unicode
  +package and method names)
  +
  +<h4>Version 0.2</h4>
  +First public edition, added to the ant cvs tree. Tested on the PDC build of 
  +the dotnet SDK only, and still immature. The command execution code was 
  +refactored out into a 'NetCommand' class for re-use. The Ilasm task was added
  +at this time.
  +
  +<h4>Version 0.1</h4>
  +Initial proof of concept; very rudimentary support for CSC only. 
  +
  +<hr>
   <h2>Task: CSC</h2>
   
   This task compiles CSharp source into executables or modules.
  -Consult the javadoc file for parameter details.
  -<h2> Task: ilasm <h2>
  -Task to assemble .il files. 
  -Consult the javadoc file for parameter details.
  +
  +This task compiles CSharp source into executables or modules.
  +The task will only work on win2K until other platforms support csc.exe or 
  +an equivalent. CSC.exe must be on the execute path too.
  +
  +<p>
  +All parameters are optional: &lt;csc/&gt; should suffice to produce a debug
  +build of all *.cs files. References to external files do require explicit 
  +enumeration, so are one of the first attributes to consider adding. 
  +
  +<p>
  +
  +The task is a directory based task, so attributes like <b>includes="**/*.cs"</b> and 
  +<b>excludes="broken.cs"</b> can be used to control the files pulled in. By default, 
  +all *.cs files from the project folder down are included in the command. 
  +When this happens the output file -if not specified-
  +is taken as the first file in the list, which may be somewhat hard to control.
  +Specifying the output file with <b>'outfile'</b> seems prudent. 
  +
  +<p>
  +
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <td valign="top"><b>Attribute</b></td>
  +    <td valign="top"><b>Description</b></td>
  +    <td align="center" valign="top"><b>Example Values</b></td>
  +  </tr>
  +
  +<tr>
  +    <td valign="top">additionalModules
  +    <td valign="top">Semicolon separated list of modules to refer to
  +    </tr>
  +  <tr>
  +    <td valign="top">defaultexcludes</td>
  +    <td valign="top">indicates whether default excludes should be used or not
  +      </td>
  +    <td valign="top">"true"(default) or "false"
  +	</tr>
  +<tr>
  +    <td valign="top">definitions
  +    <td valign="top">defined constants
  +    <td valign="top"> "RELEASE;BETA1"
  +    </tr>
  +<tr>
  +    <td valign="top">debug
  +    <td valign="top">include debug information
  +    <td valign="top">"true"(default) or "false"
  +    </tr>
  +
  +<tr>
  +    <td valign="top">docFile
  +    <td valign="top">name of file for documentation
  +    <td valign="top">"doc.xml"
  +    </tr>
  +  <tr>
  +    <td valign="top">excludes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      excluded. No files (except default excludes) are excluded when omitted.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">extraOptions</td>
  +    <td valign="top">Any extra options which aren't explicitly 
  +		supported by the CSharp task </td>
  +	<td>"/warnaserror+ /baseaddress:0x12840000"
  +  </tr>
  +
  +  
  +<tr>
  +    <td valign="top">failOnError
  +    <td valign="top">Should a failed compile halt the build?
  +    <td valign="top">"true"(default) or "false"
  +    </tr>
  +  <tr>
  +    <td valign="top">includes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      included. All files are included when omitted.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">includeDefaultReferences</td>
  +    <td valign="top">Flag which when true automatically includes
  +	the common assemblies in dotnet beta1, and tells the compiler to link in
  +	mscore.dll
  +	</td>
  +    <td valign="top">"true"(default) or "false"
  +  </tr>
  +
  +  <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +  </tr>
  +
  +<tr>
  +    <td valign="top">incremental
  +    <td valign="top">Incremental build flag. Avoid till it works
  +    <td valign="top">"true" or "false"(default)
  +    </tr>
  +<tr>
  +    <td valign="top">mainClass
  +    <td valign="top">name of main class for executables
  +    <td valign="top">"com.example.project.entrypoint"
  +    </tr>
  +<tr>
  +    <td valign="top">optimize
  +    <td valign="top">optimisation flag
  +    <td valign="top">"true" or "false"(default)
  +    </tr>
  +<tr>
  +    <td valign="top">outputFile
  +    <td valign="top">filename of output
  +    <td valign="top">"example.exe"
  +    </tr>
  +<tr>
  +    <td valign="top">references
  +    <td valign="top">Semicolon separated list of dlls to refer to
  +	<td valign="top">"mylib.dll;nunit.dll"</td>
  +    </tr>
  +<tr>
  +    <td valign="top">referenceFiles </td>
  +    <td valign="top">Ant Path descriptioon of references to include. 
  +	Wildcards should work. 
  +	<td valign="top"></td>
  +    </tr>
  +	
  +<tr>
  +    <td valign="top">srcDir
  +    <td valign="top">source directory (default = project directory)
  +    <td valign="top">"."</td>
  +    </tr>
  +<tr>
  +    <td valign="top">targetType
  +    <td valign="top">Type of target
  +    <td valign="top">"exe","module","winexe" or "library"
  +    </tr>
  +<tr>
  +    <td valign="top">unsafe
  +    <td valign="top">enable unsafe code
  +    <td valign="top">"true" or "false"(default)
  +    </tr>
  +<tr>
  +    <td valign="top">warnLevel
  +    <td valign="top">level of warning currently between 1 and 4 with 4
  +	being the strictest. 
  +    <td valign="top">"1"-"4"
  +    </tr>
  +<tr>
  +    <td valign="top">win32Icon
  +    <td valign="top">filename of icon to include
  + 	<td valign="top">"res/myicon.ico"</td>
  +   </tr>
  +
  +</table>
  +<p>
  +Example
  +<pre>&lt;csc
  +        optimize=&quot;true&quot;
  +        debug=&quot;false&quot;
  +        docFile=&quot;documentation.xml&quot;
  +        warnLevel=&quot;4&quot;
  +        unsafe=&quot;false&quot;
  +        targetType=&quot;exe&quot;
  +        incremental=&quot;false&quot;
  +        definitions=&quot;RELEASE&quot;
  +        excludes=&quot;src/unicode_class.cs&quot;
  +        mainClass = &quot;MainApp&quot;
  +        outputFile=&quot;NetApp.exe&quot;
  +        /&gt;   
  +</pre>
  +<hr>
  +<h2> Task: ilasm </h2>
  +Task to assemble .net 'Intermediate Language' files.
  +The task will only work on win2K until other platforms support csc.exe or 
  +an equivalent. ilasm.exe must be on the execute path too.
  +<p>
  +
  +<p>
  +All parameters are optional: &lt;il/&gt; should suffice to produce a debug
  +build of all *.il files.
  +The option set is roughly compatible with the CSharp class;
  +even though the command line options are only vaguely
  +equivalent. [The low level commands take things like /OUT=file,
  +csc wants /out:file ... /verbose is used some places; /quiet here in
  +ildasm... etc.] It would be nice if someone made all the command line
  +tools consistent (and not as brittle as the java cmdline tools) 
  +
  +
  +<p>
  +
  +The task is a directory based task, so attributes like <b>includes="*.il"</b> and 
  +<b>excludes="broken.il"</b> can be used to control the files pulled in. 
  +Each file is built on its own, producing an appropriately named output file unless
  +manually specified with <b>outfile</b>
  +
  +<p>
  +
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <td valign="top"><b>Attribute</b></td>
  +    <td valign="top"><b>Description</b></td>
  +    <td align="center" valign="top"><b>Example</b></td>
  +  </tr>
  +
  +
  +<tr>
  +  <tr>
  +    <td valign="top">defaultexcludes</td>
  +    <td valign="top">indicates whether default excludes should be used or not
  +      (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  +  </tr>
  +
  +<tr>
  +    <td valign="top">debug
  +    <td valign="top">include debug information
  +    <td valign="top">true (default)
  +    </tr>
  +<tr>
  +  <tr>
  +    <td valign="top">excludes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      excluded. No files (except default excludes) are excluded when omitted.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">extraOptions</td>
  +    <td valign="top">Any extra options which aren't explicitly 
  +		supported by the ilasm task </td>
  +	<td>
  +  </tr>
  +  
  +<tr>
  +    <td valign="top">failOnError
  +    <td valign="top">Should a failed compile halt the build?
  +    <td valign="top">"true"(default)
  +    </tr>
  +  <tr>
  +    <td valign="top">includes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      included. All files are included when omitted.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +  </tr>
  +<tr>
  +    <td valign="top">listing
  +    <td valign="top">Produce a listing (off by default). Listings go to the
  +	current output stream
  +    <td valign="top">"on", "off" (default)
  +    </tr>
  +<tr>
  +    <td valign="top">outputFile
  +    <td valign="top">filename of output
  +    <td valign="top">"example.exe"
  +    </tr>
  +<tr>
  +    <td valign="top">owner
  +    <td valign="top">restrict disassembly by setting the 'owner' string
  +    <td valign="top">"secret"
  +    </tr>
  +<tr>
  +    <td valign="top">resourceFile
  +    <td valign="top">name of resource file to include
  +    <td valign="top">"resources.res"
  +    </tr>
  +<tr>
  +    <td valign="top">srcDir
  +    <td valign="top">source directory (default = project directory)
  +    <td valign="top">
  +    </tr>
  +<tr>
  +    <td valign="top">targetType
  +    <td valign="top">Type of target. library means DLL is output. 
  +    <td valign="top">"exe"(default),"library"
  +    </tr>
  +<tr>
  +    <td valign="top">verbose
  +    <td valign="top">output progress messages
  +    <td valign="top">"on", "off" (default)
  +    </tr>
  +
  +</table>
  +<p>
  +Example
  +<pre>&lt;ilasm
  +        outputFile=&quot;app.exe&quot;
  +        verbose=&quot;on&quot;
  +        listing=&quot;on&quot;
  +        owner=&quot;secret&quot;
  +        /&gt;
  +</pre>
  +<hr>
  +<p align="center">Copyright &copy; 2000 Apache Software Foundation. All rights
  +Reserved.</p>
   
   </body>
  -</html>
  \ No newline at end of file
  +</html>
  
  
  
  1.3       +51 -50    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
  
  Index: NetCommand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NetCommand.java	2000/11/25 02:38:43	1.2
  +++ NetCommand.java	2000/11/28 13:35:47	1.3
  @@ -2,7 +2,7 @@
    *******************************************************************
    *
    * File:         CSharp.java
  - * RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java,v 1.2 2000/11/25 02:38:43 donaldp Exp $
  + * RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java,v 1.3 2000/11/28 13:35:47 bodewig Exp $
    * Author:       Steve Loughran
    * Created:      July 21,  2000
    * Modified:     $Modtime: 00-11-01 10:09 $
  @@ -70,7 +70,7 @@
   The reference CD to listen to while editing this file is
   Underworld Everything, Everything
   variable naming policy from Fowler's refactoring book.
  -*/
  + */
   
   // place below the optional ant tasks package
   
  @@ -86,7 +86,6 @@
   import org.apache.tools.ant.types.*;
   
   
  -
   /**
   This is a helper class to spawn net commands out. 
   In its initial form it contains no .net specifics, just contains
  @@ -94,118 +93,118 @@
   to have a means of setting the path to point to the dotnet bin directory; in which
   case the shared code should go in here.
   @author Steve Loughran steve_l@iseran.com
  -
  +@created 2000-11-01
  +@version 0.3
    */
   
  -
   public class NetCommand {
  -
  +    
       /** constructor
  -        @param owning task
  -        @param title (for logging/errors)
  -        @param executable. Leave off the '.exe. for future portability
  +    @param owning task
  +    @param title (for logging/errors)
  +    @param executable. Leave off the '.exe. for future portability
       */
  -
  -    public NetCommand(Task owner, String title, String program)
  -        throws BuildException {
  +    
  +    public NetCommand(Task owner, String title, String program) {
           _owner=owner;
           _title=title;
           _program=program;
           _commandLine=new Commandline();
           _commandLine.setExecutable(_program);
           prepareExecutor();
  -    }
  -
  +        }
  +    
       /** owner project
        */
       protected Task _owner;
  -
  +    
       /** executabe
        */
       protected Execute _exe;
  -
  +    
       /** what is the command line
        */
       protected Commandline _commandLine;
  -
  +    
       /** title of the command
        */
       protected String _title;
  -
  +    
       /** actual program to invoke
        */
       protected String _program;
  -
  +    
       /** trace flag
        */
       protected boolean _traceCommandLine=false;
  -
  +    
  +    /**
  +     * turn tracing on or off
  +     * @param b trace flag
  +     */
       public void setTraceCommandLine(boolean b){
           _traceCommandLine=b;
       }
  -
  +    
       /** flag to control action on execution trouble
  -     */
  -
  +    */
       protected boolean _failOnError;
  -
  -    /**set fail on error flag
  +    
  +    /**
  +     * set fail on error flag
  +     * @param b fail flag -set to true to cause an exception to be raised if
  +     * the return value != 0
        */
       public void setFailOnError(boolean b){
           _failOnError=b;
       }
  -
  +    
       /** query fail on error flag
  -     */
  +    */
       public boolean getFailFailOnError() {
           return _failOnError;
       }
  -
  -
  -        
  -    /** verbose text log
  -     * @param string to add to log iff verbose is defined for the build
  +    
  +    /** 
  +     * verbose text log
  +     * @param msg string to add to log iff verbose is defined for the build
        */
       protected void logVerbose(String msg){
           _owner.getProject().log(msg,Project.MSG_VERBOSE);
  -    }
  -
  -
  -    /** error text log
  -     * @param string to add to the error log
  +        }
  +    
  +    
  +    /**
  +     * error text log
  +     * @param  msg  message to display as an error
        */
       protected void logError(String msg) {
           _owner.getProject().log(msg,Project.MSG_ERR);
       }
  -
  -    /*
  +    
  +    /**
        * add an argument to a command line; do nothing if the arg is null or empty string
  -     * @param commandline to extend
  -     * @param next arg
  +     * @param  argument  The feature to be added to the Argument attribute 
        */
       public void addArgument(String argument){
           if(argument!=null && argument.length()!=0) {
               _commandLine.createArgument().setValue(argument);
           }
       }
  -
  +    
       /**
        * set up the command sequence..
        */
  -    protected void prepareExecutor() throws BuildException {
  +    protected void prepareExecutor() {
           // default directory to the project's base directory
           File dir = _owner.getProject().getBaseDir();
           ExecuteStreamHandler handler=new LogStreamHandler(_owner,
  -                                                          Project.MSG_INFO, Project.MSG_WARN);
  +                   Project.MSG_INFO, Project.MSG_WARN);
           _exe = new Execute(handler, null);
           _exe.setAntRun(_owner.getProject());
           _exe.setWorkingDirectory(dir);
  -        /* do nothing with env variables. REVISIT: SDK command line?
  -           String[] environment = env.getVariables();
  -           exe.setEnvironment(environment);
  -        */
       }
  -
  +    
       /**
        * Run the command using the given Execute instance.
        * @throws an exception of something goes wrong and the failOnError flag is true
  @@ -217,8 +216,10 @@
               if(_traceCommandLine) {
                   _owner.log(_commandLine.toString());
               }
  -            else
  +            else {
  +                //in verbose mode we always log stuff
                   logVerbose(_commandLine.toString());
  +            }
               _exe.setCommandline(_commandLine.getCommandline());
               err = _exe.execute();
               if (err != 0) {
  
  
  
  1.3       +189 -218  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java
  
  Index: Ilasm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Ilasm.java	2000/11/25 02:38:42	1.2
  +++ Ilasm.java	2000/11/28 13:35:47	1.3
  @@ -2,7 +2,7 @@
   *******************************************************************
   *
   * File:         Csharp.java
  -* RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java,v 1.2 2000/11/25 02:38:42 donaldp Exp $
  +* RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java,v 1.3 2000/11/28 13:35:47 bodewig Exp $
   * Author:       Steve Loughran
   * Created:      July 21,  2000
   * Modified:                $Modtime: 00-11-01 10:25 $
  @@ -67,11 +67,11 @@
   
   /* build notes
   
  --The reference CD to listen to while editing this file is 
  -nap: Underworld  - Everything, Everything
  --variable naming policy from Fowler's refactoring book.
  --tested against the PDC pre-beta of csc.exe; future versions will 
  -inevitably change things
  +   -The reference CD to listen to while editing this file is 
  +       nap: Underworld  - Everything, Everything
  +   -variable naming policy from Fowler's refactoring book.
  +   -tested against the PDC pre-beta of csc.exe; future versions will 
  +    inevitably change things
   */
   
   // ====================================================================
  @@ -93,157 +93,64 @@
   import org.apache.tools.ant.types.*;
   
   /**
  -   Task to assemble .net 'Intermediate Language' files.
  -   The task will only work on win2K until other platforms support csc.exe or 
  -   an equivalent. ilasm.exe must be on the execute path too.
  -   <p>
  -
  -   <p>
  -   All parameters are optional: &lt;il/&gt; should suffice to produce a debug
  -   build of all *.il files.
  -   The option set is roughly compatible with the CSharp class;
  -   even though the command line options are only vaguely
  -   equivalent. [The low level commands take things like /OUT=file,
  -   csc wants /out:file ... /verbose is used some places; /quiet here in
  -   ildasm... etc.] It would be nice if someone made all the command line
  -   tools consistent (and not as brittle as the java cmdline tools) 
  -
  -
  -   <p>
  -
  -   The task is a directory based task, so attributes like <b>includes="*.il"</b> and 
  -   <b>excludes="broken.il"</b> can be used to control the files pulled in. 
  -   Each file is built on its own, producing an appropriately named output file unless
  -   manually specified with <b>outfile</b>
  -
  -   <p>
  -
  -   <table border="1" cellpadding="2" cellspacing="0">
  -   <tr>
  -   <td valign="top"><b>Attribute</b></td>
  -   <td valign="top"><b>Description</b></td>
  -   <td align="center" valign="top"><b>Example</b></td>
  -   </tr>
  -
  -
  -   <tr>
  -   <tr>
  -   <td valign="top">defaultexcludes</td>
  -   <td valign="top">indicates whether default excludes should be used or not
  -   (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  -   </tr>
  -
  -   <tr>
  -   <td valign="top">debug
  -   <td valign="top">include debug information
  -   <td valign="top">true (default)
  -   </tr>
  -   <tr>
  -   <tr>
  -   <td valign="top">excludes</td>
  -   <td valign="top">comma separated list of patterns of files that must be
  -   excluded. No files (except default excludes) are excluded when omitted.</td>
  -   </tr>
  -   <tr>
  -   <td valign="top">excludesfile</td>
  -   <td valign="top">the name of a file. Each line of this file is
  -   taken to be an exclude pattern</td>
  -   </tr>
  -   <tr>
  -   <td valign="top">failOnError
  -   <td valign="top">Should a failed compile halt the build?
  -   <td valign="top">true(default)
  -   </tr>
  -   <tr>
  -   <td valign="top">includes</td>
  -   <td valign="top">comma separated list of patterns of files that must be
  -   included. All files are included when omitted.</td>
  -   </tr>
  -   <tr>
  -   <td valign="top">includesfile</td>
  -   <td valign="top">the name of a file. Each line of this file is
  -   taken to be an include pattern</td>
  -   </tr>
  -   <tr>
  -   <td valign="top">listing
  -   <td valign="top">Produce a listing (off by default)
  -   <td valign="top">off (default)
  -   </tr>
  -   <tr>
  -   <td valign="top">outputFile
  -   <td valign="top">filename of output
  -   <td valign="top">"example.exe"
  -   </tr>
  -   <tr>
  -   <td valign="top">owner
  -   <td valign="top">restrict disassembly by setting the 'owner' string
  -   <td valign="top">"secret"
  -   </tr>
  -   <tr>
  -   <td valign="top">resourceFile
  -   <td valign="top">name of resource file to include
  -   <td valign="top">"resources.res"
  -   </tr>
  -   <tr>
  -   <td valign="top">srcDir
  -   <td valign="top">source directory (default = project directory)
  -   <td valign="top">
  -   </tr>
  -   <tr>
  -   <td valign="top">targetType
  -   <td valign="top">Type of target. library means DLL is output. 
  -   <td valign="top">"exe","library"
  -   </tr>
  -   <tr>
  -   <td valign="top">verbose
  -   <td valign="top">output progress messages
  -   <td valign="top">off (default)
  -   </tr>
  +Task to assemble .net 'Intermediate Language' files.
  +The task will only work on win2K until other platforms support csc.exe or 
  +an equivalent. ilasm.exe must be on the execute path too.
  +<p>
  +
  +<p>
  +All parameters are optional: &lt;il/&gt; should suffice to produce a debug
  +build of all *.il files.
  +The option set is roughly compatible with the CSharp class;
  +even though the command line options are only vaguely
  +equivalent. [The low level commands take things like /OUT=file,
  +csc wants /out:file ... /verbose is used some places; /quiet here in
  +ildasm... etc.] It would be nice if someone made all the command line
  +tools consistent (and not as brittle as the java cmdline tools) 
  +
  +
  +<p>
  +
  +The task is a directory based task, so attributes like <b>includes="*.il"</b> and 
  +<b>excludes="broken.il"</b> can be used to control the files pulled in. 
  +Each file is built on its own, producing an appropriately named output file unless
  +manually specified with <b>outfile</b>
   
  -   </table>
   
  +@author Steve Loughran steve_l@iseran.com
  +@version 0.2
  + */
   
   
  -
  -   @author Steve Loughran steve_l@iseran.com
  -   @version 0.1
  -*/
  -// ====================================================================
  -
   public class Ilasm
       extends org.apache.tools.ant.taskdefs.MatchingTask {
   
  -    //=============================================================================        
       /** constructor inits everything and set up the search pattern
  -     */
  -
  +    */
       public Ilasm () {
           Clear();
           setIncludes(file_pattern);
       }
   
  -
  -    //-----------------------------------------------------------------------------
       /** name of the executable. the .exe suffix is deliberately not included 
        * in anticipation of the unix version
        */
       protected static final String exe_name="ilasm";
  -
  +    
       /** what is the file extension we search on?
        */
       protected static final String file_ext="il";
  -
  +    
       /** and now derive the search pattern from the extension 
        */
  -    protected static final String file_pattern="*."+file_ext;
  -
  +    protected static final String file_pattern="**/*."+file_ext;
  +    
       /** title of task for external presentation
        */
       protected static final String exe_title="ilasm";
  -
  -    //=============================================================================        
  +    
       /** reset all contents. 
  -     */
  +    */
       public void Clear() {
           _targetType=null;
           _srcDir=null;
  @@ -255,49 +162,56 @@
           _failOnError=true;
           _resourceFile=null;
           _owner=null;
  +        _extraOptions=null;     
       }
   
  -    //=============================================================================        
       /** source directory upon which the search pattern is applied
        */
       private File _srcDir;
  -
  +    
       /**
        * Set the source dir to find the files to be compiled
  +     * @param  srcDirName  The new SrcDir value 
        */
       public void setSrcDir(String srcDirName){
           _srcDir = project.resolveFile(srcDirName);
       }
  +    
   
  -
  -    //=============================================================================        
       /** type of target. Should be one of exe|library|module|winexe|(null)
  -        default is exe; the actual value (if not null) is fed to the command line.
  -        <br>See /target
  -    */
  +    default is exe; the actual value (if not null) is fed to the command line.
  +    <br>See /target
  +     */
       protected String _targetType;
  -
  +    
       /** define the target
  -     * param target. 
  -     * @throws BuildException if target is not one of exe|library|module|winexe 
  +     * @param  targetType          one of exe|library|
  +     * @exception BuildException if target is not one of exe|library|module|winexe 
        */
  -
  +    
       public void setTargetType(String targetType)
           throws  BuildException {
           targetType=targetType.toLowerCase();
           if(targetType.equals("exe") || targetType.equals("library")) {
  -            _targetType=targetType;        
  +            _targetType=targetType; 
           }
           else 
               throw new BuildException("targetType " +targetType+" is not a valid type");
       }
   
  +    /**
  +     * accessor method for target type
  +     * @return the current target option
  +     */
       public String getTargetType() { 
           return _targetType;
  -    }         
  -
  -    /** get the argument or null for no argument needed
  -     */
  +    }   
  +    
  +    /** g
  +     *  get the target type or null for no argument needed 
  +     *
  +     * @return    The TargetTypeParameter value 
  +    */
   
       protected String getTargetTypeParameter() {
           if(!notEmpty(_targetType))
  @@ -305,72 +219,96 @@
           if (_targetType.equals("exe"))
               return "/exe";
           else 
  -            if (_targetType.equals("library"))
  -                return "/dll";
  -            else
  -                return null;
  -    }        
  +        if (_targetType.equals("library"))
  +            return "/dll";
  +        else
  +            return null;
  +    }   
           
  -    //=============================================================================        
       /** owner string is a slightly trivial barrier to disassembly
  -     */
  -
  +    */
  +    
       protected String _owner;
  -
  +    
  +    /**
  +     *  Sets the Owner attribute 
  +     *
  +     * @param  s  The new Owner value 
  +     */
  +    
       public void setOwner(String s) {
           _owner=s;
  -    }
  +        }
       
  +    /**
  +     *  Gets the Owner switch for ilasm
  +     *
  +     * @return    The Owner string
  +     */    
       protected String getOwnerParameter() {
           if(notEmpty(_owner))
               return "/owner="+_owner;
           else 
               return null;
       }
  -
  -    //=============================================================================        
  +        
       /** test for a string containing something useful
        * @param string to test
        * @returns true if the argument is not null or empty
  -     */
  +    */
       protected boolean notEmpty(String s)
  -    {return s!=null && s.length()!=0;}
  -
  -    //=============================================================================        
  +        {return s!=null && s.length()!=0;}
  +    
       /** verbose flag
        */
  -     
       protected boolean _verbose;
   
  +    /** 
  +     * enable/disable verbose ILASM output
  +     * @param b flag set to true for verbose on
  +     */
       public void setVerbose(boolean b) {
           _verbose=b;
       }
  -
  +    
  +    /** 
  +     * turn the verbose flag into a parameter for ILASM
  +     * @return null or the appropriate command line string
  +     */
       protected String getVerboseParameter() {
           return _verbose?null:"/quiet";
       }   
  -
  -    //=============================================================================        
  +    
  +        
       /** listing flag
        */
  -     
  +         
       protected boolean _listing;
   
  +    /** 
  +     * enable/disable listing
  +     * @param b flag set to true for listing on
  +     */
       public void setListing(boolean b) {
           _listing=b;
       }
  -
  +    
  +    /** 
  +     * turn the listing flag into a parameter for ILASM
  +     * @return the appropriate string from the state of the listing flag
  +     */
       protected String getListingParameter() {
           return _listing?"/listing":"/nolisting";
       }
  -   
  -    //=============================================================================        
  -    /** output file. If not supplied this is derived from the
  +       
  +    
  +    /**
  +     * output file. If not supplied this is derived from the
        *  source file
        */
  - 
  +     
       protected String _outputFile;
  -
  +    
       /**
        * Set the definitions
        * @param list of definitions split by ; or , or even :
  @@ -378,89 +316,119 @@
       public void setOutputFile(String params) {
           _outputFile=params;
       }
  -
  -    /** get the argument or null for no argument needed
  -     */
  +    
  +    /**
  +     * get the output file 
  +     * @return the argument string or null for no argument
  +    */
       protected String getOutputFileParameter() {
           if (_outputFile==null || _outputFile.length()==0)
               return null;
           File f=project.resolveFile(_outputFile);
           return "/output="+f.toString();
       }
  -
  -    //=============================================================================        
  +    
       /** resource file (.res format) to include in the app. 
        */
  - 
  -    protected String _resourceFile;
  -
  -    public void setResourceFile(String s) {
  -        _resourceFile=s;
  -    }
  +    protected File _resourceFile;
       
  +    /**
  +     * Set the resource file 
  +     * @param fileName path to the file. Can be relative, absolute, whatever.
  +     */public void setResourceFile(String fileName) {
  +        _resourceFile = project.resolveFile(fileName);
  +    }
  +        
       protected String getResourceFileParameter() {
  -        if(notEmpty(_resourceFile)) {
  -            return "/resource="+_resourceFile;
  +        if(_resourceFile!=null) {
  +            return "/resource="+_resourceFile.toString();
           }
  -        else 
  +        else {
               return null;
  +        }
       }
  -   
  -    //=============================================================================        
  +    
       /** flag to control action on execution trouble
  -     */
  -
  +    */
       protected boolean _failOnError;
  -
  +    
       /**set fail on error flag
  -     */
  +    */
       public void setFailOnError(boolean b){
           _failOnError=b;
       }
  -
  +    
       /** query fail on error flag
  -     */
  +    */
       public boolean getFailFailOnError() {
           return _failOnError;
       }
  -
  -    //=============================================================================        
  +        
       /** debug flag. Controls generation of debug information. 
        */
  - 
       protected boolean _debug;
  -
  +    
       /** set the debug flag on or off
  -     * @param on/off flag
  +     * @param f on/off flag
        */
  - 
       public void setDebug(boolean f)
  -    {_debug=f;}
  +        {_debug=f;}
           
       /** query the debug flag
        * @return true if debug is turned on
        */
  - 
       public boolean getDebug() {
           return _debug;
       }
  -
  +    
       /** get the argument or null for no argument needed
  -     */
  +    */
       protected String getDebugParameter() {
           return _debug?"/debug":null;
  -    }        
  -   
  -    //=============================================================================        
  +    }   
  +
  +    /** any extra command options?
  +     */
  +    protected String _extraOptions;
  +    
  +    /**
  +     *  Sets the ExtraOptions attribute
  +     *
  +     * @param  extraOptions  The new ExtraOptions value 
  +     */
  +    public void setExtraOptions(String extraOptions)
  +        {this._extraOptions=extraOptions;}
  +    
  +    /**
  +     *  Gets the ExtraOptions attribute 
  +     *
  +     * @return    The ExtraOptions value 
  +     */
  +    public String getExtraOptions()
  +        {return this._extraOptions;}
  +    
  +    /**
  +     *  get any extra options or null for no argument needed 
  +     *
  +     * @return    The ExtraOptions Parameter to CSC 
  +     */
  +    protected String getExtraOptionsParameter() {
  +        if (_extraOptions!=null && _extraOptions.length()!=0)
  +            return _extraOptions;
  +        else
  +            return null;
  +    } 
  +
  +        
       /** This is the execution entry point. Build a list of files and
        *  call ilasm on each of them.
  +     * @throws BuildException if the assembly failed and FailOnError is true
        */
  -
       public void execute() 
           throws BuildException {
           if (_srcDir == null)
  -            _srcDir=project.resolveFile(".");
  -
  +                _srcDir=project.resolveFile(".");
  +    
           //get dependencies list. 
           DirectoryScanner scanner = super.getDirectoryScanner(_srcDir);
           String[] dependencies = scanner.getIncludedFiles();
  @@ -472,13 +440,15 @@
               targetFile=baseDir+File.separator+targetFile;
               executeOneFile(targetFile);
           }
  -    
  +        
       } // end execute
  -
  -    //=============================================================================        
  -    /** do the work by building the command line and then calling it
  +    
  +        
  +    /**
  +     * do the work for one file by building the command line then calling it
  +     * @param targetFile name of the the file to assemble
  +     * @throws BuildException if the assembly failed and FailOnError is true
        */
  -
       public void executeOneFile(String targetFile) 
           throws BuildException {
           NetCommand command=new NetCommand(this,exe_title,exe_name);
  @@ -493,8 +463,9 @@
           command.addArgument(getOwnerParameter());
           command.addArgument(getResourceFileParameter());
           command.addArgument(getVerboseParameter());
  -
  +        command.addArgument(getExtraOptionsParameter());
    
  +
           /* space for more argumentativeness
              command.addArgument();
              command.addArgument();
  
  
  
  1.3       +396 -358  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
  
  Index: CSharp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CSharp.java	2000/11/25 02:38:42	1.2
  +++ CSharp.java	2000/11/28 13:35:48	1.3
  @@ -2,7 +2,7 @@
   *******************************************************************
   *
   * File:         Csharp.java
  -* RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java,v 1.2 2000/11/25 02:38:42 donaldp Exp $
  +* RCS:          $Header: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java,v 1.3 2000/11/28 13:35:48 bodewig Exp $
   * Author:       Steve Loughran
   * Created:      July 21,  2000
   * Modified:     $Modtime: 00-11-01 12:57 $
  @@ -67,11 +67,11 @@
   
   /* build notes
   
  --The reference CD to listen to while editing this file is 
  -nap: Underworld  - Everything, Everything
  --variable naming policy from Fowler's refactoring book.
  --tested against the PDC pre-beta of csc.exe; future versions will 
  -inevitably change things
  +    -The reference CD to listen to while editing this file is 
  +        nap: Underworld  - Everything, Everything
  +    -variable naming policy from Fowler's refactoring book.
  +    -tested against the PDC pre-beta of csc.exe; future versions will 
  +     inevitably change things
   */
   
   // ====================================================================
  @@ -85,12 +85,10 @@
   // imports
   // ====================================================================
   
  -import java.io.*;
  -import java.text.*;
  -import java.util.*;
   import org.apache.tools.ant.*;
   import org.apache.tools.ant.taskdefs.*;
   import org.apache.tools.ant.types.*;
  +import java.io.*;
   
   
   // ====================================================================
  @@ -115,474 +113,507 @@
   
   <p>
   
  -<table border="1" cellpadding="2" cellspacing="0">
  -  <tr>
  -    <td valign="top"><b>Attribute</b></td>
  -    <td valign="top"><b>Description</b></td>
  -    <td align="center" valign="top"><b>Example</b></td>
  -  </tr>
  -
  -
  -<tr>
  -    <td valign="top">additionalModules
  -    <td valign="top">Semicolon separated list of modules to refer to
  -    </tr>
  -  <tr>
  -    <td valign="top">defaultexcludes</td>
  -    <td valign="top">indicates whether default excludes should be used or not
  -      (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  -  </tr>
  -<tr>
  -    <td valign="top">definitions
  -    <td valign="top">defined constants
  -    <td valign="top"> "RELEASE;BETA1"
  -    </tr>
  -<tr>
  -    <td valign="top">debug
  -    <td valign="top">include debug information
  -    <td valign="top">"true" or "false"
  -    </tr>
  -
  -<tr>
  -    <td valign="top">docFile
  -    <td valign="top">name of file for documentation
  -    <td valign="top">"doc.xml"
  -    </tr>
  -  <tr>
  -    <td valign="top">excludes</td>
  -    <td valign="top">comma separated list of patterns of files that must be
  -      excluded. No files (except default excludes) are excluded when omitted.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">excludesfile</td>
  -    <td valign="top">the name of a file. Each line of this file is
  -      taken to be an exclude pattern</td>
  -  </tr>
  -<tr>
  -    <td valign="top">failOnError
  -    <td valign="top">Should a failed compile halt the build?
  -    <td valign="top">"true" or "false"
  -    </tr>
  -  <tr>
  -    <td valign="top">includes</td>
  -    <td valign="top">comma separated list of patterns of files that must be
  -      included. All files are included when omitted.</td>
  -  </tr>
  -  <tr>
  -    <td valign="top">includesfile</td>
  -    <td valign="top">the name of a file. Each line of this file is
  -      taken to be an include pattern</td>
  -  </tr>
  -<tr>
  -    <td valign="top">incremental
  -    <td valign="top">Incremental build flag. Off by default
  -    <td valign="top">"false"
  -    </tr>
  -<tr>
  -    <td valign="top">mainClass
  -    <td valign="top">name of main class for executables
  -    <td valign="top">com.example.project.entrypoint
  -    </tr>
  -<tr>
  -    <td valign="top">optimize
  -    <td valign="top">optimisation flag
  -    <td valign="top">"true" or "false"
  -    </tr>
  -<tr>
  -    <td valign="top">outputFile
  -    <td valign="top">filename of output
  -    <td valign="top">"example.exe"
  -    </tr>
  -<tr>
  -    <td valign="top">references
  -    <td valign="top">Semicolon separated list of dlls to refer to
  -    </tr>
  -<tr>
  -    <td valign="top">srcDir
  -    <td valign="top">source directory (default = project directory)
  -    <td valign="top">
  -    </tr>
  -<tr>
  -    <td valign="top">targetType
  -    <td valign="top">Type of target
  -    <td valign="top">"exe","module","winexe","library"
  -    </tr>
  -<tr>
  -    <td valign="top">unsafe
  -    <td valign="top">enable unsafe code
  -    <td valign="top">"true" or "false"
  -    </tr>
  -<tr>
  -    <td valign="top">warnLevel
  -    <td valign="top">level of warning
  -    <td valign="top">1-4
  -    </tr>
  -<tr>
  -    <td valign="top">win32Icon
  -    <td valign="top">filename of icon to include
  -    <td valign="top">
  -    </tr>
  -
  -</table>
  -
   
  -
  -<p>
  -The first pass is just a proof of concept; enough to test. 
   <p>
   TODO
   <ol>
  -    <li>get PATH incorporated into reference/module lookup
  +    <li>is incremental build still broken in beta-1?
       <li>is Win32Icon broken?
       <li>all the missing options
   </ol>
   <p>
   History
  -        <Table>
  -        <tr><td>0.2</td>
  -                <td> Slightly different</td>
  -                <td> Split command execution to a separate class; 
  -        </tr>
  -        <tr><td>0.1</td>
  -                <td> "I can't believe it's so rudimentary"</td>
  -                <td>  First pass; minimal builds only support; 
  -        </tr>
  +    <Table>
  +    <tr><td>0.3</td>
  +        <td> Beta 1 edition </td>
  +        <td> To avoid having to remember which assemblies to include, 
  +        the task automatically refers to the main dotnet libraries in Beta1.
  +        
  +    </tr>    <tr><td>0.2</td>
  +        <td> Slightly different</td>
  +        <td> Split command execution to a separate class; 
  +    </tr>
  +    <tr><td>0.1</td>
  +        <td> "I can't believe it's so rudimentary"</td>
  +        <td>  First pass; minimal builds only support; 
  +    </tr>
   
  -        </table>
  -@version 0.2
  +    </table>
  +@version 0.3
   @author Steve Loughran steve_l@iseran.com
   
    */
  -// ====================================================================
   
   public class CSharp 
       extends org.apache.tools.ant.taskdefs.MatchingTask {
   
  -    //=============================================================================        
       /** constructor inits everything and set up the search pattern
  -     */
  -
  +    */
  +    
       public CSharp () {
           Clear();
           setIncludes(csc_file_pattern);
       }
  -
  -
  -    //-----------------------------------------------------------------------------
  +    
       /** name of the executable. the .exe suffix is deliberately not included 
        * in anticipation of the unix version
        */
       protected static final String csc_exe_name="csc";
  -
  +    
       /** what is the file extension we search on?
        */
       protected static final String csc_file_ext="cs";
  -
  -    /** and now derive the search pattern from the extension 
  +    
  +    /** derive the search pattern from the extension 
        */
  -    protected static final String csc_file_pattern="*."+csc_file_ext;
  -
  -
  -    //=============================================================================        
  +    protected static final String csc_file_pattern="**/*."+csc_file_ext;
  +    
       /** list of reference classes. (pretty much a classpath equivalent)
        */
  -
       protected  String _references;
  -
  +    
       /**
  -     * Set the reference list to be used for this compilation.
  +     *  Set the reference list to be used for this compilation. 
  +     *
  +     * @param  s  The new References value 
        */
  -
       public void setReferences(String s) {
           _references=s;
       }
  -
  -    /** get the argument or null for no argument needed
  +    
  +    /**
  +     *  get the reference string or null for no argument needed 
  +     *
  +     * @return    The References Parameter to CSC 
        */
       protected String getReferencesParameter() {
           //bail on no references
  -        if (_references==null ||_references.length()==0)
  -            return null;
  -        else
  +        if (notEmpty(_references)) 
               return "/reference:"+_references;
  +        else
  +            return null;
       }
  -            
  -
  -    /* using the path approach didnt work as it could not handle the implicit
  -       execution path. Perhaps that could be extracted from the runtime and then
  -       the path approach would be viable
  -
  -
  -       protected  Path _references;
  -
  -       public void setReferences(Path s) {
  -       //demand create pathlist
  -       if(_references==null)
  -       _references=new Path(this.project);
  -       _references.append(s);
  -       }
  -
  -       protected String getReferencesParameter()
  -       {
  -       //bail on no references
  -       if (_references==null)
  -       return null;
  -       //iterate through the ref list & generate an entry for each
  -       //or just rely on the fact that the toString operator does this, but
  -       //noting that the separator is ';' on windows, ':' on unix
  -       String refpath=_references.toString();
  -
  -       //bail on no references listed
  -       if (refpath.length()==0)
  -       return null;
  +                
  +    /**
  +     using the path approach didnt work as it could not handle the implicit
  +     execution path. Perhaps that could be extracted from the runtime and then
  +     the path approach would be viable
  +    */
  +    protected  Path _referenceFiles;
  +    
  +    /**
  +     * add another path to the reference file path list
  +     * @param path another path to append
  +     */
  +    public void setReferenceFiles(Path path) {
  +        //demand create pathlist
  +        if(_referenceFiles==null)
  +                _referenceFiles=new Path(this.project);
  +        _referenceFiles.append(path);
  +    }
  +    
  +    /**
  +     turn the path list into a list of files and a /references argument
  +     @return null or a string of references.
  +    */ 
  +    protected String getReferenceFilesParameter() {
  +        //bail on no references
  +        if (_references==null)
  +            return null;
  +        //iterate through the ref list & generate an entry for each
  +        //or just rely on the fact that the toString operator does this, but
  +        //noting that the separator is ';' on windows, ':' on unix
  +        String refpath=_references.toString();
  +    
  +        //bail on no references listed
  +        if (refpath.length()==0)
  +            return null;
           
  -       StringBuffer s=new StringBuffer("/reference:");
  -       s.append(refpath);
  -       return new String(s);
  -       }        
  +        StringBuffer s=new StringBuffer("/reference:");
  +        s.append(refpath);
  +        return new String(s);
  +    }   
  +    
  +    /** 
  +     * C# is really dumb in how it handles inclusion. You have to list
  +     * every 'assembly' -read DLL that is imported. So already you are
  +     * making a platform assumption -shared libraries have a .dll extension
  +     * and the poor developer has to know every library which is included
  +     * why the compiler cant find classes on the path or in a directory,
  +     * is a mystery.
  +     *
  +     * To reduce the need to be explicit, here is a long list of 
  +     * the core libraries used in Beta-1 of .NET
  +     * ommitting the blatantly non portable (MS.win32.interop)
  +     * and the .designer libraries. (ripping out Com was tempting)
  +     * Casing is chosen to match that of the file system <i>exactly</i>
  +     * so may work on a unix box too. 
  +     */
  +    protected static final String DEFAULT_REFERENCE_LIST
  +        ="System.dll;System.Drawing.dll;System.Data.dll;"+
  +         "System.Diagnostics.dll;"+
  +         "System.DirectoryServices.dll;"+
  +         "System.IO.dll;"+
  +         "System.Management.dll;"+
  +         "System.Messaging.dll;"+
  +         "System.Net.dll;"+
  +         "System.Runtime.Remoting.dll;"+
  +         "System.Runtime.Serialization.Formatters.Soap.dll;"+
  +         "System.Security.dll;"+
  +         "System.ServiceProcess.dll;"+
  +         "System.Text.RegularExpressions.dll;"+
  +         "System.Timers.dll;"+
  +         "System.Web.dll;"+
  +         "System.Web.Services.dll;"+
  +         "System.WinForms.dll;"+
  +         "System.XML.dll;"+
  +         "System.XML.Serialization.dll;"+
  +         "Microsoft.ComServices.dll;";
  +    
  +    /** 
  +     * get default reference list
  +     * @return null or a string of references.
  +    */ 
  +    protected String getDefaultReferenceParameter() {
  +        if(_includeDefaultReferences) {
  +            StringBuffer s=new StringBuffer("/reference:");
  +            s.append(DEFAULT_REFERENCE_LIST);
  +            return new String(s);
  +        }
  +        else
  +            return null;            
  +    }
  +     
  +     /** flag to enable automatic reference inclusion
  +      *
  +     */
  +     protected boolean _includeDefaultReferences;
  +
  +    /** set the automatic reference inclusion flag on or off
  +     *  this flag controls the string of references and the 
  +     *  /nostdlib option in CSC
  +    @param f on/off flag
       */
  -
  -    //=============================================================================        
  -    /* optimise flag
  +    public void setIncludeDefaultReferences(boolean f) {
  +        _includeDefaultReferences=f;
  +    }
  +    
  +    /** query the optimise flag
  +    @return true if optimise is turned on
  +     */
  +    public boolean getIncludeDefaultReferences() {
  +        return _includeDefaultReferences;
  +    }
  +    
  +    /**
  +     *  get the include default references flag or null for no argument needed 
  +     *
  +     * @return    The Parameter to CSC 
        */
  - 
  +    protected String getIncludeDefaultReferencesParameter() {
  +        return "/nostdlib"+(_includeDefaultReferences?"-":"+");
  +    }    
  +    
  +    /** optimise flag
  +     */
       protected boolean _optimize;
  -
  +    
       /** set the optimise flag on or off
  -        @param on/off flag
  +    @param f on/off flag
       */
       public void setOptimize(boolean f) {
           _optimize=f;
       }
  -
  +    
       /** query the optimise flag
  -        @return true if optimise is turned on
  -    */
  +    @return true if optimise is turned on
  +     */
       public boolean getOptimize() {
           return _optimize;
       }
  -
  -    /** get the argument or null for no argument needed
  +    
  +    /**
  +     *  get the optimise flag or null for no argument needed 
  +     *
  +     * @return    The Optimize Parameter to CSC 
        */
       protected String getOptimizeParameter() {
           return "/optimize"+(_optimize?"+":"-");
  -    }        
  +    }   
           
  -    //=============================================================================        
       /** incremental build flag */
       protected boolean _incremental;
  -
  +    
       /** set the incremental compilation flag on or off
  -     *@param on/off flag
  +     * @param f on/off flag
        */
       public void setIncremental(boolean f){
           _incremental=f;
       }
  -
  +    
       /** query the incrementalflag
        * @return true iff incremental compilation is turned on
        */
       public boolean getIncremental() {
           return _incremental;
       }
  -
  -    /** get the argument or null for no argument needed
  +    
  +    /**
  +     *  get the incremental build argument
  +     *
  +     * @return    The Incremental Parameter to CSC 
        */
       protected String getIncrementalParameter() {
           return "/incremental"+(_incremental?"+":"-");
  -    }        
  -
  -    //=============================================================================        
  +    }   
  +    
       /** debug flag. Controls generation of debug information. 
        */
  - 
       protected boolean _debug;
  -
  +    
       /** set the debug flag on or off
  -     * @param on/off flag
  +     * @param f on/off flag
        */
  - 
  -    public void setDebug(boolean f)
  -    {_debug=f;}
  +    public void setDebug(boolean f) {
  +        _debug=f;
  +    }
           
       /** query the debug flag
        * @return true if debug is turned on
        */
  - 
       public boolean getDebug() {
           return _debug;
       }
  -
  -    /** get the argument or null for no argument needed
  +    
  +    /**
  +     *  get the debug switch argument  
  +     *
  +     * @return    The Debug Parameter to CSC 
        */
       protected String getDebugParameter() {
           return "/debug"+(_debug?"+":"-");
  -    }        
  -
  -
  -    //=============================================================================        
  +    }   
  +    
       /** output XML documentation flag
  -     */        
  -        
  +    */  
       protected File _docFile;
           
       /** file for generated XML documentation
  -     * @param output file
  +     * @param f output file
        */
  - 
       public void setDocFile(String f) {
           _docFile=project.resolveFile(f);
       }
  -
  -
  -
  +            
       /** get the argument or null for no argument needed
  +     * @return    The DocFile Parameter to CSC 
        */
       protected String getDocFileParameter() {
           if (_docFile!=null)
               return "/doc:"+_docFile.toString();
           else
               return null;
  -    }        
  +    }   
           
  -    //=============================================================================        
       /** warning level: 0-4, with 4 being most verbose
  -     */
  +    */
       private int _warnLevel;
  -
  +    
       /** set warn level (no range checking)
  -     * @param warn level -see .net docs for valid range (probably 0-4)
  -     */
  +     * @param warnLevel warn level -see .net docs for valid range (probably 0-4)
  +    */
       public void setWarnLevel(int warnLevel)
  -    {this._warnLevel=warnLevel;}
  -
  +        {this._warnLevel=warnLevel;}
  +    
       /** query warn level
        * @return current value
  -     */
  +    */
       public int getWarnLevel()
  -    {return _warnLevel;}
  -
  -    /** get the argument or null for no argument needed
  +        {return _warnLevel;}
  +    
  +    /**
  +     *  get the warn level switch 
  +     *
  +     * @return    The WarnLevel Parameter to CSC 
        */
       protected String getWarnLevelParameter() {
           return "/warn:"+_warnLevel;
  -    }        
  -
  -    //=============================================================================        
  +    }   
  +    
       /** enable unsafe code flag. Clearly set to false by default
        */
  -
       protected boolean _unsafe;
  -
  +    
  +    /**
  +     *  Sets the Unsafe attribute 
  +     *
  +     * @param  unsafe  The new Unsafe value 
  +     */
       public void setUnsafe(boolean unsafe)
  -    {this._unsafe=unsafe;}
  -
  +        {this._unsafe=unsafe;}
  +    
  +    /**
  +     *  query the Unsafe attribute 
  +     *
  +     * @return    The Unsafe value 
  +     */
       public boolean getUnsafe()
  -    {return this._unsafe;}
  -
  +        {return this._unsafe;}
  +    
       /** get the argument or null for no argument needed
  -     */
  +     * @return    The Unsafe Parameter to CSC 
  +    */
       protected String getUnsafeParameter(){
           return _unsafe?"/unsafe":null;
  -    }        
  +    }   
           
  -    //=============================================================================        
       /** main class (or null for automatic choice)
        */
       protected String _mainClass;
  -
  +    
  +    /**
  +     *  Sets the MainClass attribute
  +     *
  +     * @param  mainClass  The new MainClass value 
  +     */
       public void setMainClass(String mainClass)
  -    {this._mainClass=mainClass;}
  -
  +        {this._mainClass=mainClass;}
  +    
  +    /**
  +     *  Gets the MainClass attribute 
  +     *
  +     * @return    The MainClass value 
  +     */
       public String getMainClass()
  -    {return this._mainClass;}
  -
  -    /** get the argument or null for no argument needed
  +        {return this._mainClass;}
  +    
  +    /**
  +     *  get the /main argument or null for no argument needed 
  +     *
  +     * @return    The MainClass Parameter to CSC 
        */
       protected String getMainClassParameter(){
           if (_mainClass!=null && _mainClass.length()!=0)
               return "/main:"+_mainClass;
           else
               return null;
  -    }        
  -
  -    //=============================================================================        
  +    } 
  +    
  +    /** any extra command options?
  +     */
  +    protected String _extraOptions;
  +    
  +    /**
  +     *  Sets the ExtraOptions attribute
  +     *
  +     * @param  extraOptions  The new ExtraOptions value 
  +     */
  +    public void setExtraOptions(String extraOptions)
  +        {this._extraOptions=extraOptions;}
  +    
  +    /**
  +     *  Gets the ExtraOptions attribute 
  +     *
  +     * @return    The ExtraOptions value 
  +     */
  +    public String getExtraOptions()
  +        {return this._extraOptions;}
  +    
  +    /**
  +     *  get any extra options or null for no argument needed 
  +     *
  +     * @return    The ExtraOptions Parameter to CSC 
  +     */
  +    protected String getExtraOptionsParameter() {
  +        if (_extraOptions!=null && _extraOptions.length()!=0)
  +            return _extraOptions;
  +        else
  +            return null;
  +    } 
  +    
       /** source directory upon which the search pattern is applied
        */
       private File _srcDir;
  -
  +    
       /**
        * Set the source dir to find the files to be compiled
  +     * @param  srcDirName  The new SrcDir value 
        */
       public void setSrcDir(String srcDirName){
           _srcDir = project.resolveFile(srcDirName);
       }
  -
  -    //=============================================================================        
  +    
       /** destination directory (null means use the source directory)
  -     */
  +    * NB: this is currently not used 
  +    */
       private File _destDir;
  -
  +    
       /**
  -     * Set the source dir to find the files to be compiled
  +     * Set the destination dir to find the files to be compiled
  +     * @param  dirName  The new DestDir value 
        */
       public void setDestDir(String dirName) {
           _destDir = project.resolveFile(dirName);
       }
  -        
  -
  -    //=============================================================================        
  +    
       /** type of target. Should be one of exe|library|module|winexe|(null)
  -        default is exe; the actual value (if not null) is fed to the command line.
  -        <br>See /target
  -    */
  +    default is exe; the actual value (if not null) is fed to the command line.
  +    <br>See /target
  +     */
       protected String _targetType;
  -
  +    
       /** define the target
  -     * param target. 
  -     * @throws BuildException if target is not one of exe|library|module|winexe 
  +     * @param  targetType          The new TargetType value 
  +     * @exception  BuildException  if target is not one of exe|library|module|winexe 
        */
  -
       public void setTargetType(String targetType)
           throws  BuildException {
           targetType=targetType.toLowerCase();
           if(targetType.equals("exe") || targetType.equals("library") ||
  -           targetType.equals("module") ||targetType.equals("winexe") ) {
  -            _targetType=targetType;        
  +            targetType.equals("module") ||targetType.equals("winexe") ) {
  +            _targetType=targetType; 
           }
           else 
               throw new BuildException("targetType " +targetType+" is not a valid type");
       }
  -
  +    
  +    /**
  +     *  Gets the TargetType attribute  
  +     *
  +     * @return    The TargetType value 
  +     */
       public String getTargetType() { 
  -        return _targetType;
  -    }         
  -
  -    /** get the argument or null for no argument needed
  +            return _targetType;
  +    }   
  +    
  +    /**
  +     *  get the argument or null for no argument needed 
  +     *
  +     * @return    The TargetType Parameter to CSC 
        */
       protected String getTargetTypeParameter() {
  -        if (_targetType!=null)
  +        if (notEmpty(_targetType)) 
               return "/target:"+_targetType;
           else
               return null;
  -    }        
  -
  -
  -    //=============================================================================        
  -    /* icon for incorporation into apps
  -     */
  - 
  -    protected File _win32icon;        
  -
  +    }   
  +    
  +    /** icon for incorporation into apps
  +     */     
  +    protected File _win32icon;  
  +    
       /**
        * Set the win32 icon 
  -     * @param path to the file. Can be relative, absolute, whatever.
  +     * @param fileName path to the file. Can be relative, absolute, whatever.
        */
       public void setWin32Icon(String fileName) {
           _win32icon = project.resolveFile(fileName);
       }
  -
  -    /** get the argument or null for no argument needed
  +    
  +    /**
  +     *  get the argument or null for no argument needed 
  +     *
  +     * @return    The Win32Icon Parameter to CSC 
        */
       protected String getWin32IconParameter() {
           if (_win32icon!=null)
  @@ -590,14 +621,12 @@
           else
               return null;
       }
  -
  -    //=============================================================================        
  -    /** defines list 'RELEASE;WIN32;NO_SANITY_CHECKS;;SOMETHING_ELSE'
  -     *
  -     */
  -
  +    
  +    /** defines list
  +    * something like 'RELEASE;WIN32;NO_SANITY_CHECKS;;SOMETHING_ELSE'
  +    */
       String _definitions;
  -
  +    
       /**
        * Set the definitions
        * @param list of definitions split by ; or , or even :
  @@ -605,22 +634,24 @@
       public void setDefinitions(String params) {
           _definitions=params;
       }
  -
  -    /** get the argument or null for no argument needed
  -     */
  +      
  +    /**
  +    *  get the argument or null for no argument needed 
  +    *
  +    * @return    The Definitions Parameter to CSC 
  +    */
       protected String getDefinitionsParameter() {
  -        if (_definitions==null || _definitions.length()==0)
  +        if (notEmpty(_definitions))
  +            return "/define:" + _definitions;
  +        else
               return null;
  -        else return "/DEFINE:"+_definitions;
       }
  -
  -    //=============================================================================        
  +    
       /** list of extra modules to refer to 
        *
  -     */
  -
  +    */    
       String _additionalModules;
  -
  +    
       /**
        * Set the definitions
        * @param list of definitions split by ; or , or even :
  @@ -628,22 +659,22 @@
       public void setAdditionalModules(String params) {
           _additionalModules=params;
       }
  -
  +    
       /** get the argument or null for no argument needed
  +    * @return    The AdditionalModules Parameter to CSC 
        */
       protected String getAdditionalModulesParameter() {
  -        if (_additionalModules==null || _additionalModules.length()==0)
  +        if (notEmpty(_additionalModules)) 
  +            return "/addmodule:" + _additionalModules;
  +        else 
               return null;
  -        else return "/addmodule:"+_additionalModules;
       }
  -
  -    //=============================================================================        
  +    
       /** output file. If not supplied this is derived from the
        *  source file
  -     */
  -
  +     */    
       protected String _outputFile;
  -
  +    
       /**
        * Set the definitions
        * @param list of definitions split by ; or , or even :
  @@ -651,37 +682,39 @@
       public void setOutputFile(String params) {
           _outputFile=params;
       }
  -
  +    
       /** get the argument or null for no argument needed
  -     */
  +    * @return    The OutputFile Parameter to CSC 
  +    */
       protected String getOutputFileParameter() {
  -        if (_outputFile==null || _outputFile.length()==0)
  +        if (notEmpty(_outputFile)) {
  +            File f=project.resolveFile(_outputFile);
  +            return "/out:"+f.toString();
  +        }
  +        else            
               return null;
  -        File f=project.resolveFile(_outputFile);
  -        return "/out:"+f.toString();
       }
  -
  -    //=============================================================================        
  +    
       /** flag to control action on execution trouble
  -     */
  -
  +    */
       protected boolean _failOnError;
  -
  +    
       /**set fail on error flag
  -     */
  +    * @param  b  The new FailOnError value 
  +    */
       public void setFailOnError(boolean b){
           _failOnError=b;
       }
  -
  +    
       /** query fail on error flag
  -     */
  +     * @return    The FailFailOnError value 
  +    */
       public boolean getFailFailOnError() {
  -        return _failOnError;
  +            return _failOnError;
       }
  -
  -    //=============================================================================        
  +    
       /** reset all contents. 
  -     */
  +    */
       public void Clear() {
           _targetType=null;
           _win32icon=null;
  @@ -698,18 +731,27 @@
           _failOnError=true;
           _definitions=null;
           _additionalModules=null;
  +        _includeDefaultReferences=true;
  +        _extraOptions=null;
       }
  -
  -
  -    //=============================================================================        
  -    /** do the work by building the command line and then calling it
  +    
  +    /**
  +     *  test for a string containing something useful 
  +     *
  +     * @param  s  string in 
  +     * @return    true if the argument is not null or empty 
        */
  -
  +    protected boolean notEmpty(String s) {
  +        return s != null && s.length() != 0;
  +    }
  +    
  +    /** do the work by building the command line and then calling it
  +    */
       public void execute() 
           throws BuildException {
           if (_srcDir == null)
               _srcDir=project.resolveFile(".");
  -
  +    
           NetCommand command=new NetCommand(this,"CSC",csc_exe_name);
           command.setFailOnError(getFailFailOnError());
           //DEBUG helper
  @@ -729,12 +771,10 @@
           command.addArgument(getWarnLevelParameter());
           command.addArgument(getWin32IconParameter());
           command.addArgument(getOutputFileParameter());   
  -        /* space for more argumentativeness
  -           command.addArgument();
  -           command.addArgument();
  -        */
  -
  -
  +        command.addArgument(getIncludeDefaultReferencesParameter());
  +        command.addArgument(getDefaultReferenceParameter());
  +        command.addArgument(getExtraOptionsParameter());
  +    
           //get dependencies list. 
           DirectoryScanner scanner = super.getDirectoryScanner(_srcDir);
           String[] dependencies = scanner.getIncludedFiles();
  @@ -746,11 +786,9 @@
               targetFile=baseDir+File.separator+targetFile;
               command.addArgument(targetFile);
           }
  -    
  +        
           //now run the command of exe + settings + files
           command.runCommand();
       } // end execute
  -
  -
  -
  +    
   } //end class
  
  
  

Mime
View raw message