diff --git a/docs/dotnet.html b/docs/dotnet.html index e1a887fdd..b81bfa136 100644 --- a/docs/dotnet.html +++ b/docs/dotnet.html @@ -1,12 +1,13 @@
-@@ -44,9 +45,9 @@ removed from the build.xml files
+External changes +
+All parameters are optional: <csc/> 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. + +
+ +The task is a directory based task, so attributes like includes="**/*.cs" and +excludes="broken.cs" 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 'outfile' seems prudent. + +
+ +
Attribute | +Description | +Example Values | +
additionalModules + | Semicolon separated list of modules to refer to + | |
defaultexcludes | +indicates whether default excludes should be used or not + | +"true"(default) or "false" + |
definitions + | defined constants + | "RELEASE;BETA1" + |
debug + | include debug information + | "true"(default) or "false" + |
docFile + | name of file for documentation + | "doc.xml" + |
excludes | +comma separated list of patterns of files that must be + excluded. No files (except default excludes) are excluded when omitted. | +|
excludesfile | +the name of a file. Each line of this file is + taken to be an exclude pattern | +|
extraOptions | +Any extra options which aren't explicitly + supported by the CSharp task | +"/warnaserror+ /baseaddress:0x12840000" + |
failOnError + | Should a failed compile halt the build? + | "true"(default) or "false" + |
includes | +comma separated list of patterns of files that must be + included. All files are included when omitted. | +|
includeDefaultReferences | +Flag which when true automatically includes + the common assemblies in dotnet beta1, and tells the compiler to link in + mscore.dll + | +"true"(default) or "false" + |
includesfile | +the name of a file. Each line of this file is + taken to be an include pattern | +|
incremental + | Incremental build flag. Avoid till it works + | "true" or "false"(default) + |
mainClass + | name of main class for executables + | "com.example.project.entrypoint" + |
optimize + | optimisation flag + | "true" or "false"(default) + |
outputFile + | filename of output + | "example.exe" + |
references + | Semicolon separated list of dlls to refer to + | "mylib.dll;nunit.dll" | +
referenceFiles | +Ant Path descriptioon of references to include. + Wildcards should work. + | + |
srcDir + | source directory (default = project directory) + | "." | +
targetType + | Type of target + | "exe","module","winexe" or "library" + |
unsafe + | enable unsafe code + | "true" or "false"(default) + |
warnLevel + | level of warning currently between 1 and 4 with 4 + being the strictest. + | "1"-"4" + |
win32Icon + | filename of icon to include + | "res/myicon.ico" | +
+Example +
<csc + optimize="true" + debug="false" + docFile="documentation.xml" + warnLevel="4" + unsafe="false" + targetType="exe" + incremental="false" + definitions="RELEASE" + excludes="src/unicode_class.cs" + mainClass = "MainApp" + outputFile="NetApp.exe" + /> ++
+ +
+All parameters are optional: <il/> 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) + + +
+ +The task is a directory based task, so attributes like includes="*.il" and +excludes="broken.il" 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 outfile + +
+ +
Attribute | +Description | +Example | +
defaultexcludes | +indicates whether default excludes should be used or not + ("yes"/"no"). Default excludes are used when omitted. | +|
debug + | include debug information + | true (default) + |
excludes | +comma separated list of patterns of files that must be + excluded. No files (except default excludes) are excluded when omitted. | +|
excludesfile | +the name of a file. Each line of this file is + taken to be an exclude pattern | +|
extraOptions | +Any extra options which aren't explicitly + supported by the ilasm task | ++ |
failOnError + | Should a failed compile halt the build? + | "true"(default) + |
includes | +comma separated list of patterns of files that must be + included. All files are included when omitted. | +|
includesfile | +the name of a file. Each line of this file is + taken to be an include pattern | +|
listing + | Produce a listing (off by default). Listings go to the + current output stream + | "on", "off" (default) + |
outputFile + | filename of output + | "example.exe" + |
owner + | restrict disassembly by setting the 'owner' string + | "secret" + |
resourceFile + | name of resource file to include + | "resources.res" + |
srcDir + | source directory (default = project directory) + | + |
targetType + | Type of target. library means DLL is output. + | "exe"(default),"library" + |
verbose + | output progress messages + | "on", "off" (default) + |
+Example +
<ilasm + outputFile="app.exe" + verbose="on" + listing="on" + owner="secret" + /> ++
Copyright © 2000 Apache Software Foundation. All rights +Reserved.
- \ No newline at end of file + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java index a7ca03d75..e243fb650 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java @@ -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 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; // 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 @@ Specifying the output file with 'outfile' seems prudent.-
Attribute | -Description | -Example | -
additionalModules - | Semicolon separated list of modules to refer to - | |
defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -|
definitions - | defined constants - | "RELEASE;BETA1" - |
debug - | include debug information - | "true" or "false" - |
docFile - | name of file for documentation - | "doc.xml" - |
excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -|
excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -|
failOnError - | Should a failed compile halt the build? - | "true" or "false" - |
includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -|
includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -|
incremental - | Incremental build flag. Off by default - | "false" - |
mainClass - | name of main class for executables - | com.example.project.entrypoint - |
optimize - | optimisation flag - | "true" or "false" - |
outputFile - | filename of output - | "example.exe" - |
references - | Semicolon separated list of dlls to refer to - | |
srcDir - | source directory (default = project directory) - | - |
targetType - | Type of target - | "exe","module","winexe","library" - |
unsafe - | enable unsafe code - | "true" or "false" - |
warnLevel - | level of warning - | 1-4 - |
win32Icon - | filename of icon to include - | - |
-The first pass is just a proof of concept; enough to test.
TODO
History -
0.2 | -Slightly different | -Split command execution to a separate class; - |
0.1 | -"I can't believe it's so rudimentary" | -First pass; minimal builds only support; - |
0.3 | +Beta 1 edition | +To avoid having to remember which assemblies to include, + the task automatically refers to the main dotnet libraries in Beta1. + + |
0.2 | +Slightly different | +Split command execution to a separate class; + |
0.1 | +"I can't believe it's so rudimentary" | +First pass; minimal builds only support; + |
+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. +
-
- All parameters are optional: <il/> 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) +
+All parameters are optional: <il/> 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) -
- - The task is a directory based task, so attributes like includes="*.il" and - excludes="broken.il" 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 outfile - -
- -
Attribute | -Description | -Example | -
defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -|
debug - | include debug information - | true (default) - |
excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -|
excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -|
failOnError - | Should a failed compile halt the build? - | true(default) - |
includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -|
includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -|
listing - | Produce a listing (off by default) - | off (default) - |
outputFile - | filename of output - | "example.exe" - |
owner - | restrict disassembly by setting the 'owner' string - | "secret" - |
resourceFile - | name of resource file to include - | "resources.res" - |
srcDir - | source directory (default = project directory) - | - |
targetType - | Type of target. library means DLL is output. - | "exe","library" - |
verbose - | output progress messages - | off (default) - |
+The task is a directory based task, so attributes like includes="*.il" and
+excludes="broken.il" 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 outfile
+@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 @@ public class Ilasm
_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.
-
See /target
- */
+ default is exe; the actual value (if not null) is fed to the command line.
+
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 @@ public class Ilasm
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 class Ilasm
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 @@ public class Ilasm
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 @@ public class Ilasm
command.addArgument(getOwnerParameter());
command.addArgument(getResourceFileParameter());
command.addArgument(getVerboseParameter());
-
+ command.addArgument(getExtraOptionsParameter());
+
/* space for more argumentativeness
command.addArgument();
command.addArgument();
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
index 3c50226e5..3f67dee5f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
@@ -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.taskdefs.*;
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 @@ all the command line/exe construction stuff. However, it may be handy in future
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 @@ public class NetCommand {
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) {