FileDocCategorySizeDatePackage
Ilasm.javaAPI DocApache Ant 1.7013809Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.dotnet

Ilasm

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.

ant.task
name="ilasm" category="dotnet"

Fields Summary
protected static final String
exe_name
Name of the executable. The .exe suffix is deliberately not included in anticipation of the unix version
protected static final String
file_ext
what is the file extension we search on?
protected static final String
file_pattern
and now derive the search pattern from the extension
protected static final String
exe_title
title of task for external presentation
protected 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
protected boolean
verbose
verbose flag
protected boolean
listing
listing flag
protected File
resourceFile
resource file (.res format) to include in the app.
protected boolean
failOnError
flag to control action on execution trouble
protected boolean
debug
debug flag. Controls generation of debug information.
private File
keyfile
file containing private key
protected String
extraOptions
any extra command options?
protected Vector
referenceFilesets
filesets of references
private boolean
isMono
Constructors Summary
public Ilasm()
constructor inits everything and set up the search pattern


                   
      
        Clear();
        setIncludes(file_pattern);
    
Methods Summary
public voidClear()
reset all contents.

        targetType = null;
        srcDir = null;
        listing = false;
        verbose = false;
        debug = true;
        outputFile = null;
        failOnError = true;
        resourceFile = null;
        extraOptions = null;
    
public voidaddReference(org.apache.tools.ant.types.FileSet reference)
add a new reference fileset to the compilation

param
reference the fileset to use.

        referenceFilesets.add(reference);
    
private NetCommandbuildIlasmCommand()
build up our ilasm command

return

        NetCommand command = new NetCommand(this, exe_title, exe_name);
        command.setFailOnError(getFailOnError());
        //fill in args
        command.addArgument(getDebugParameter());
        command.addArgument(getTargetTypeParameter());
        command.addArgument(getListingParameter());
        command.addArgument(getOutputFileParameter());
        command.addArgument(getResourceFileParameter());
        command.addArgument(getVerboseParameter());
        command.addArgument(getKeyfileParameter());
        command.addArgument(getExtraOptionsParameter());

        /*
         *  space for more argumentativeness
         *  command.addArgument();
         *  command.addArgument();
         */
        return command;
    
public voidexecute()
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

        log("This task is deprecated and will be removed in a future version\n"
            + "of Ant.  It is now part of the .NET Antlib:\n"
            + "http://ant.apache.org/antlibs/dotnet/index.html",
            Project.MSG_WARN);
        NetCommand command = buildIlasmCommand();

        addFilesAndExecute(command, false);

    
public booleangetDebug()
query the debug flag

return
true if debug is turned on

        return debug;
    
protected java.lang.StringgetDebugParameter()
get the argument or null for no argument needed

return
The debugParameter value

        return debug ? "/debug" : null;
    
public java.lang.StringgetExtraOptions()
Gets the ExtraOptions attribute

return
The ExtraOptions value

        return this.extraOptions;
    
protected java.lang.StringgetExtraOptionsParameter()
get any extra options or null for no argument needed

return
The ExtraOptions Parameter to CSC

        if (extraOptions != null && extraOptions.length() != 0) {
            return extraOptions;
        } else {
            return null;
        }
    
public booleangetFailOnError()
query fail on error flag

return
The failFailOnError value

        return failOnError;
    
protected java.lang.StringgetKeyfileParameter()
get the argument or null for no argument needed

return
The keyfileParameter value

        if (keyfile != null) {
            return "/keyfile:" + keyfile.toString();
        } else {
            return null;
        }
    
protected java.lang.StringgetListingParameter()
turn the listing flag into a parameter for ILASM

return
the appropriate string from the state of the listing flag

        if (!isMono) {
            return listing ? "/listing" : "/nolisting";
        }
        return null;
    
protected java.lang.StringgetOutputFileParameter()
get the output file

return
the argument string or null for no argument

        if (outputFile == null) {
            return null;
        }
        return "/output=" + outputFile.toString();
    
protected java.lang.StringgetResourceFileParameter()
Gets the resourceFileParameter attribute of the Ilasm task

return
The resourceFileParameter value

        if (resourceFile != null) {
            return "/resource=" + resourceFile.toString();
        } else {
            return null;
        }
    
public java.lang.StringgetTargetType()
accessor method for target type

return
the current target option

        return targetType;
    
protected java.lang.StringgetTargetTypeParameter()
g get the target type or null for no argument needed

return
The TargetTypeParameter value

        if (!notEmpty(targetType)) {
            return null;
        }
        if (targetType.equals("exe")) {
            return "/exe";
        } else if (targetType.equals("library")) {
            return "/dll";
        } else {
            return null;
        }
    
protected java.lang.StringgetVerboseParameter()
turn the verbose flag into a parameter for ILASM

return
null or the appropriate command line string

        return verbose ? null : "/quiet";
    
protected static booleanisFileManagedBinary(java.io.File file)
test for a file being managed or not

param
file the file to test.
return
true if we think this is a managed executable, and thus OK for linking
todo
look at the PE header of the exe and see if it is managed or not.

        String filename = file.toString().toLowerCase();
        return filename.endsWith(".exe") || filename.endsWith(".dll")
                || filename.endsWith(".netmodule");
    
protected booleannotEmpty(java.lang.String s)
test for a string containing something useful

param
s any string
return
true if the argument is not null or empty

        return s != null && s.length() != 0;
    
public voidsetDebug(boolean f)
set the debug flag on or off.

param
f on/off flag

        debug = f;
    
public voidsetExtraOptions(java.lang.String extraOptions)
Any extra options which are not explicitly supported by this task.

param
extraOptions The new ExtraOptions value

        this.extraOptions = extraOptions;
    
public voidsetFailOnError(boolean b)
If true, fails if ilasm tool fails.

param
b The new failOnError value

        failOnError = b;
    
public voidsetKeyfile(java.io.File keyfile)
the name of a file containing a private key.

param
keyfile The new keyfile value

        this.keyfile = keyfile;
    
public voidsetListing(boolean b)
If true, produce a listing (off by default).

param
b flag set to true for listing on

        listing = b;
    
public voidsetMono(boolean b)
Explicitly override the Mono auto-detection.

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

param
b a boolean value.
since
Ant 1.7

        isMono = b;
    
public voidsetOutputFile(java.io.File params)
Set the output file; identical to setDestFile

see
DotnetBaseMatchingTask#setDestFile
param
params The new outputFile value

        outputFile = params;
    
public voidsetOwner(java.lang.String s)
Sets the Owner attribute.

param
s The new Owner value
ant.attribute
ignore="true"

        log("This option is not supported by ILASM as of Beta-2, "
            + "and will be ignored", Project.MSG_WARN);
    
public voidsetResourceFile(java.io.File fileName)
name of resource file to include.

param
fileName path to the file. Can be relative, absolute, whatever.

        resourceFile = fileName;
    
public voidsetTargetType(org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm$TargetTypes targetType)
set the target type to one of exe|library

param
targetType the enumerated value.

        this.targetType = targetType.getValue();
    
public voidsetTargetType(java.lang.String targetType)
Sets the type of target, either "exe" or "library".

param
targetType one of exe|library|
exception
BuildException if target is not one of exe|library

        this.targetType = targetType.toLowerCase();
        if (!targetType.equals("exe") && !targetType.equals("library")) {
            throw new BuildException("targetType " + targetType + " is not a valid type");
        }
    
public voidsetVerbose(boolean b)
If true, enable verbose ILASM output.

param
b flag set to true for verbose on

        verbose = b;