Google

Ilasm (Apache Ant API)

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


java.lang.Object

  |

  +--org.apache.tools.ant.ProjectComponent

        |

        +--org.apache.tools.ant.Task

              |

              +--org.apache.tools.ant.taskdefs.MatchingTask

                    |

                    +--org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm

All Implemented Interfaces:
SelectorContainer

public class Ilasm
extends MatchingTask

Assembles .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)

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

Version:
0.5
Author:
Steve Loughran steve_l@iseran.com

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.io.File outputFile
          output file.
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.MatchingTask
fileset, useDefaultExcludes
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Ilasm()
          constructor inits everything and set up the search pattern
 
Method Summary
 void Clear()
          reset all contents.
 void execute()
          This is the execution entry point.
 void executeOneFile(java.lang.String targetFile)
          do the work for one file by building the command line then calling it
 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 getFailFailOnError()
          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  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 setOutputFile(java.io.File params)
          Set the output file.
 void setOwner(java.lang.String s)
          Sets the Owner attribute.
 void setResourceFile(java.io.File fileName)
          name of resource file to include.
 void setSrcDir(java.io.File srcDirName)
          Set the source directory containing the files to be compiled.
 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.MatchingTask
addAnd, addContains, addCustom, addDate, addDepend, addDepth, addFilename, addMajority, addNone, addNot, addOr, addPresent, addSelector, addSize, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject
 
Methods inherited from class java.lang.Object
clone, 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


outputFile


protected java.io.File outputFile
output file. If not supplied this is derived from the source file


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?

Constructor Detail

Ilasm


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

Method Detail

Clear


public void Clear()
reset all contents.


setSrcDir


public void setSrcDir(java.io.File srcDirName)
Set the source directory containing the files to be compiled.

Parameters:
srcDirName - The new SrcDir value

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.

Parameters:
params - The new outputFile value

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

getFailFailOnError


public boolean getFailFailOnError()
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

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

executeOneFile


public void executeOneFile(java.lang.String targetFile)
                    throws BuildException
do the work for one file by building the command line then calling it

Parameters:
targetFile - name of the the file to assemble
Throws:
BuildException - if the assembly failed and FailOnError is true


Copyright 2000-2002 Apache Software Foundation. All Rights Reserved.