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

java.lang.Object
  |
  +--org.apache.tools.ant.Task
        |
        +--org.apache.tools.ant.taskdefs.MatchingTask
              |
              +--org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm

public class Ilasm
extends MatchingTask

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)

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.2
Author:
Steve Loughran steve_l@iseran.com

Field Summary
protected  boolean _debug
          debug flag.
protected  java.lang.String _extraOptions
          any extra command options?
protected  boolean _failOnError
          flag to control action on execution trouble
protected  boolean _listing
          listing flag
protected  java.lang.String _outputFile
          output file.
protected  java.lang.String _owner
          owner string is a slightly trivial barrier to disassembly
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
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 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
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset, useDefaultExcludes
 
Fields inherited from class org.apache.tools.ant.Task
description, location, project, target, taskName, taskType, wrapper
 
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 getListingParameter()
          turn the listing flag into a parameter for ILASM
protected  java.lang.String getOutputFileParameter()
          get the output file
protected  java.lang.String getOwnerParameter()
          Gets the Owner switch for ilasm
protected  java.lang.String getResourceFileParameter()
           
 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)
          Sets the ExtraOptions attribute
 void setFailOnError(boolean b)
          set fail on error flag
 void setListing(boolean b)
          enable/disable listing
 void setOutputFile(java.lang.String params)
          Set the definitions
 void setOwner(java.lang.String s)
          Sets the Owner attribute
 void setResourceFile(java.lang.String fileName)
          Set the resource file
 void setSrcDir(java.lang.String srcDirName)
          Set the source dir to find the files to be compiled
 void setTargetType(java.lang.String targetType)
          define the target
 void setVerbose(boolean b)
          enable/disable verbose ILASM output
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
createExclude, createInclude, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
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

file_ext

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

file_pattern

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

exe_title

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

_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

_owner

protected java.lang.String _owner
owner string is a slightly trivial barrier to disassembly

_verbose

protected boolean _verbose
verbose flag

_listing

protected boolean _listing
listing flag

_outputFile

protected java.lang.String _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.lang.String srcDirName)
Set the source dir to find the files to be compiled
Parameters:
srcDirName - The new SrcDir value

setTargetType

public void setTargetType(java.lang.String targetType)
                   throws BuildException
define the target
Parameters:
targetType - one of exe|library|
Throws:
BuildException - if target is not one of exe|library|module|winexe

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

getOwnerParameter

protected java.lang.String getOwnerParameter()
Gets the Owner switch for ilasm
Returns:
The Owner string

notEmpty

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

setVerbose

public void setVerbose(boolean b)
enable/disable 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)
enable/disable listing
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.lang.String params)
Set the definitions
Parameters:
list - of definitions split by ; or , or even :

getOutputFileParameter

protected java.lang.String getOutputFileParameter()
get the output file
Returns:
the argument string or null for no argument

setResourceFile

public void setResourceFile(java.lang.String fileName)
Set the resource file
Parameters:
fileName - path to the file. Can be relative, absolute, whatever.

getResourceFileParameter

protected java.lang.String getResourceFileParameter()

setFailOnError

public void setFailOnError(boolean b)
set fail on error flag

getFailFailOnError

public boolean getFailFailOnError()
query fail on error flag

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

setExtraOptions

public void setExtraOptions(java.lang.String extraOptions)
Sets the ExtraOptions attribute
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 Apache Software Foundation. All Rights Reserved.