org.apache.tools.ant.taskdefs.optional.dotnet
Class Ilasm

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by org.apache.tools.ant.taskdefs.optional.dotnet.DotnetBaseMatchingTask
                  extended by org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm
All Implemented Interfaces:
java.lang.Cloneable, SelectorContainer

public class Ilasm
extends DotnetBaseMatchingTask

Assembles .NET Intermediate Language files. ilasm.exe must be on the execute path, unless another executable or the full path to that executable is specified in the executable parameter

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. You can also use nested <src> filesets to refer to source.


Nested Class Summary
static class Ilasm.TargetTypes
          Target types to build.
 
Field Summary
protected  boolean debug
          debug flag.
protected static java.lang.String exe_name
          Name of the executable.
protected static java.lang.String exe_title
          title of task for external presentation
protected  java.lang.String extraOptions
          any extra command options?
protected  boolean failOnError
          flag to control action on execution trouble
protected static java.lang.String file_ext
          what is the file extension we search on?
protected static java.lang.String file_pattern
          and now derive the search pattern from the extension
protected  boolean listing
          listing flag
protected  java.util.Vector referenceFilesets
          filesets of references
protected  java.io.File resourceFile
          resource file (.res format) to include in the app.
protected  java.lang.String targetType
          type of target.
protected  boolean verbose
          verbose flag
 
Fields inherited from class org.apache.tools.ant.taskdefs.optional.dotnet.DotnetBaseMatchingTask
filesets, isWindows, outputFile, srcDir
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
Ilasm()
          constructor inits everything and set up the search pattern
 
Method Summary
 void addReference(FileSet reference)
          add a new reference fileset to the compilation
 void Clear()
          reset all contents.
 void execute()
          This is the execution entry point.
 boolean getDebug()
          query the debug flag
protected  java.lang.String getDebugParameter()
          get the argument or null for no argument needed
 java.lang.String getExtraOptions()
          Gets the ExtraOptions attribute
protected  java.lang.String getExtraOptionsParameter()
          get any extra options or null for no argument needed
 boolean getFailOnError()
          query fail on error flag
protected  java.lang.String getKeyfileParameter()
          get the argument or null for no argument needed
protected  java.lang.String getListingParameter()
          turn the listing flag into a parameter for ILASM
protected  java.lang.String getOutputFileParameter()
          get the output file
protected  java.lang.String getResourceFileParameter()
          Gets the resourceFileParameter attribute of the Ilasm task
 java.lang.String getTargetType()
          accessor method for target type
protected  java.lang.String getTargetTypeParameter()
          g get the target type or null for no argument needed
protected  java.lang.String getVerboseParameter()
          turn the verbose flag into a parameter for ILASM
protected static boolean isFileManagedBinary(java.io.File file)
          test for a file being managed or not
protected  boolean notEmpty(java.lang.String s)
          test for a string containing something useful
 void setDebug(boolean f)
          set the debug flag on or off.
 void setExtraOptions(java.lang.String extraOptions)
          Any extra options which are not explicitly supported by this task.
 void setFailOnError(boolean b)
          If true, fails if ilasm tool fails.
 void setKeyfile(java.io.File keyfile)
          the name of a file containing a private key.
 void setListing(boolean b)
          If true, produce a listing (off by default).
 void setMono(boolean b)
          Explicitly override the Mono auto-detection.
 void setOutputFile(java.io.File params)
          Set the output file; identical to setDestFile
 void setOwner(java.lang.String s)
          Sets the Owner attribute.
 void setResourceFile(java.io.File fileName)
          name of resource file to include.
 void setTargetType(Ilasm.TargetTypes targetType)
          set the target type to one of exe|library
 void setTargetType(java.lang.String targetType)
          Sets the type of target, either "exe" or "library".
 void setVerbose(boolean b)
          If true, enable verbose ILASM output.
 
Methods inherited from class org.apache.tools.ant.taskdefs.optional.dotnet.DotnetBaseMatchingTask
addFilesAndExecute, addFilesToCommand, addSrc, buildFileList, getDestFile, getOutputFileTimestamp, getSrcDir, setDestFile, setSrcDir
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exe_name

protected static final java.lang.String exe_name
Name of the executable. The .exe suffix is deliberately not included in anticipation of the unix version

See Also:
Constant Field Values

file_ext

protected static final java.lang.String file_ext
what is the file extension we search on?

See Also:
Constant Field Values

file_pattern

protected static final java.lang.String file_pattern
and now derive the search pattern from the extension

See Also:
Constant Field Values

exe_title

protected static final java.lang.String exe_title
title of task for external presentation

See Also:
Constant Field Values

targetType

protected java.lang.String targetType
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


verbose

protected boolean verbose
verbose flag


listing

protected boolean listing
listing flag


resourceFile

protected java.io.File resourceFile
resource file (.res format) to include in the app.


failOnError

protected boolean failOnError
flag to control action on execution trouble


debug

protected boolean debug
debug flag. Controls generation of debug information.


extraOptions

protected java.lang.String extraOptions
any extra command options?


referenceFilesets

protected java.util.Vector referenceFilesets
filesets of references

Constructor Detail

Ilasm

public Ilasm()
constructor inits everything and set up the search pattern

Method Detail

Clear

public void Clear()
reset all contents.


setTargetType

public void setTargetType(java.lang.String targetType)
                   throws BuildException
Sets the type of target, either "exe" or "library".

Parameters:
targetType - one of exe|library|
Throws:
BuildException - if target is not one of exe|library

getTargetType

public java.lang.String getTargetType()
accessor method for target type

Returns:
the current target option

getTargetTypeParameter

protected java.lang.String getTargetTypeParameter()
g get the target type or null for no argument needed

Returns:
The TargetTypeParameter value

setOwner

public void setOwner(java.lang.String s)
Sets the Owner attribute.

Parameters:
s - The new Owner value

notEmpty

protected boolean notEmpty(java.lang.String s)
test for a string containing something useful

Parameters:
s - any string
Returns:
true if the argument is not null or empty

setVerbose

public void setVerbose(boolean b)
If true, enable verbose ILASM output.

Parameters:
b - flag set to true for verbose on

getVerboseParameter

protected java.lang.String getVerboseParameter()
turn the verbose flag into a parameter for ILASM

Returns:
null or the appropriate command line string

setListing

public void setListing(boolean b)
If true, produce a listing (off by default).

Parameters:
b - flag set to true for listing on

getListingParameter

protected java.lang.String getListingParameter()
turn the listing flag into a parameter for ILASM

Returns:
the appropriate string from the state of the listing flag

setOutputFile

public void setOutputFile(java.io.File params)
Set the output file; identical to setDestFile

Parameters:
params - The new outputFile value
See Also:
DotnetBaseMatchingTask.setDestFile(java.io.File)

getOutputFileParameter

protected java.lang.String getOutputFileParameter()
get the output file

Returns:
the argument string or null for no argument

setResourceFile

public void setResourceFile(java.io.File fileName)
name of resource file to include.

Parameters:
fileName - path to the file. Can be relative, absolute, whatever.

getResourceFileParameter

protected java.lang.String getResourceFileParameter()
Gets the resourceFileParameter attribute of the Ilasm task

Returns:
The resourceFileParameter value

setFailOnError

public void setFailOnError(boolean b)
If true, fails if ilasm tool fails.

Parameters:
b - The new failOnError value

getFailOnError

public boolean getFailOnError()
query fail on error flag

Returns:
The failFailOnError value

setDebug

public void setDebug(boolean f)
set the debug flag on or off.

Parameters:
f - on/off flag

getDebug

public boolean getDebug()
query the debug flag

Returns:
true if debug is turned on

getDebugParameter

protected java.lang.String getDebugParameter()
get the argument or null for no argument needed

Returns:
The debugParameter value

setKeyfile

public void setKeyfile(java.io.File keyfile)
the name of a file containing a private key.

Parameters:
keyfile - The new keyfile value

getKeyfileParameter

protected java.lang.String getKeyfileParameter()
get the argument or null for no argument needed

Returns:
The keyfileParameter value

setExtraOptions

public void setExtraOptions(java.lang.String extraOptions)
Any extra options which are not explicitly supported by this task.

Parameters:
extraOptions - The new ExtraOptions value

getExtraOptions

public java.lang.String getExtraOptions()
Gets the ExtraOptions attribute

Returns:
The ExtraOptions value

getExtraOptionsParameter

protected java.lang.String getExtraOptionsParameter()
get any extra options or null for no argument needed

Returns:
The ExtraOptions Parameter to CSC

setTargetType

public void setTargetType(Ilasm.TargetTypes targetType)
set the target type to one of exe|library

Parameters:
targetType - the enumerated value.

setMono

public void setMono(boolean b)
Explicitly override the Mono auto-detection.

Defaults to false on Windows and true on any other platform.

Parameters:
b - a boolean value.
Since:
Ant 1.7

execute

public void execute()
             throws BuildException
This is the execution entry point. Build a list of files and call ilasm on each of them.

Overrides:
execute in class Task
Throws:
BuildException - if the assembly failed and FailOnError is true

addReference

public void addReference(FileSet reference)
add a new reference fileset to the compilation

Parameters:
reference - the fileset to use.

isFileManagedBinary

protected static boolean isFileManagedBinary(java.io.File file)
test for a file being managed or not

Parameters:
file - the file to test.
Returns:
true if we think this is a managed executable, and thus OK for linking
To do:
look at the PE header of the exe and see if it is managed or not.