|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.CSharp
Compiles C# source into executables or modules. The task will only work on win2K until other platforms support csc.exe or an equivalent. CSC.exe must be on the execute path too.
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.
TODO
History
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; |
Field Summary | |
protected boolean |
debug
debug flag. |
protected static java.lang.String |
DEFAULT_REFERENCE_LIST
Fix C# reference inclusion. |
protected java.lang.String |
extraOptions
any extra command options? |
protected java.lang.String |
mainClass
main class (or null for automatic choice) |
protected java.lang.String |
targetType
type of target. |
protected boolean |
unsafe
enable unsafe code flag. |
protected boolean |
utf8output
utf out 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 | |
CSharp()
constructor inits everything and set up the search pattern |
Method Summary | |
void |
Clear()
reset all contents. |
void |
execute()
do the work by building the command line and then calling it |
protected java.lang.String |
getAdditionalModulesParameter()
get the argument or null for no argument needed |
boolean |
getDebug()
query the debug flag |
protected java.lang.String |
getDebugParameter()
get the debug switch argument |
protected java.lang.String |
getDefaultReferenceParameter()
get default reference list |
protected java.lang.String |
getDefinitionsParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getDocFileParameter()
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 |
getFileAlignParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getFullPathsParameter()
Gets the fullPathsParameter attribute of the CSharp object |
boolean |
getIncludeDefaultReferences()
query automatic reference inclusion flag |
protected java.lang.String |
getIncludeDefaultReferencesParameter()
get the include default references flag or null for no argument needed |
boolean |
getIncremental()
query the incrementalflag |
protected java.lang.String |
getIncrementalParameter()
get the incremental build argument |
java.lang.String |
getMainClass()
Gets the MainClass attribute |
protected java.lang.String |
getMainClassParameter()
get the /main argument or null for no argument needed |
protected java.lang.String |
getNoConfigParameter()
Gets the noConfigParameter attribute of the CSharp object |
boolean |
getOptimize()
query the optimise flag |
protected java.lang.String |
getOptimizeParameter()
get the optimise flag or null for no argument needed |
protected java.lang.String |
getOutputFileParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getReferenceFilesParameter()
turn the path list into a list of files and a /references argument |
protected java.lang.String |
getReferencesParameter()
get the reference string or null for no argument needed |
java.lang.String |
getTargetType()
Gets the TargetType attribute |
protected java.lang.String |
getTargetTypeParameter()
get the argument or null for no argument needed |
boolean |
getUnsafe()
query the Unsafe attribute |
protected java.lang.String |
getUnsafeParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getUtf8OutputParameter()
Gets the utf8OutpuParameter attribute of the CSharp object |
int |
getWarnLevel()
query warn level |
protected java.lang.String |
getWarnLevelParameter()
get the warn level switch |
protected java.lang.String |
getWin32IconParameter()
get the argument or null for no argument needed |
protected java.lang.String |
getWin32ResParameter()
get the argument or null for no argument needed |
protected boolean |
notEmpty(java.lang.String s)
test for a string containing something useful |
void |
setAdditionalModules(java.lang.String params)
Semicolon separated list of modules to refer to. |
void |
setDebug(boolean f)
set the debug flag on or off. |
void |
setDefinitions(java.lang.String params)
Semicolon separated list of defined constants. |
void |
setDestDir(java.io.File dirName)
Set the destination directory of files to be compiled. |
void |
setDestFile(java.io.File file)
Set the name of exe/library to create. |
void |
setDocFile(java.io.File f)
file for generated XML documentation |
void |
setExtraOptions(java.lang.String extraOptions)
Any extra options which are not explicitly supported by this task. |
void |
setFailOnError(boolean b)
If true, fail on compilation errors. |
void |
setFileAlign(int fileAlign)
Set the file alignment. |
void |
setFullPaths(boolean enabled)
If true, print the full path of files on errors. |
void |
setIncludeDefaultReferences(boolean f)
If true, automatically includes the common assemblies in dotnet, and tells the compiler to link in mscore.dll. |
void |
setIncremental(boolean f)
set the incremental compilation flag on or off. |
void |
setMainClass(java.lang.String mainClass)
Sets the name of main class for executables. |
void |
setNoConfig(boolean enabled)
A flag that tells the compiler not to read in the compiler settings files 'csc.rsp' in its bin directory and then the local directory |
void |
setOptimize(boolean f)
If true, enables optimization flag. |
void |
setOutputFile(java.io.File params)
Set the output file |
void |
setReferenceFiles(Path path)
Path of references to include. |
void |
setReferences(java.lang.String s)
Semicolon separated list of DLLs to refer to. |
void |
setSrcDir(java.io.File srcDirName)
Set the source directory of the files to be compiled. |
void |
setTargetType(java.lang.String ttype)
Set the type of target. |
void |
setUnsafe(boolean unsafe)
If true, enables the unsafe keyword. |
void |
setUtf8Output(boolean enabled)
If true, require all compiler output to be in UTF8 format. |
void |
setWarnLevel(int warnLevel)
Level of warning currently between 1 and 4 with 4 being the strictest. |
void |
setWin32Icon(java.io.File fileName)
Set the filename of icon to include. |
void |
setWin32Res(java.io.File fileName)
Sets the filename of a win32 resource (.RES) file to include. |
protected void |
validate()
validation code |
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 |
protected static final java.lang.String DEFAULT_REFERENCE_LIST
protected boolean debug
protected boolean unsafe
protected java.lang.String mainClass
protected java.lang.String extraOptions
protected java.lang.String targetType
protected boolean utf8output
Constructor Detail |
public CSharp()
Method Detail |
public void setReferences(java.lang.String s)
s
- The new References valueprotected java.lang.String getReferencesParameter()
public void setReferenceFiles(Path path)
path
- another path to appendprotected java.lang.String getReferenceFilesParameter()
protected java.lang.String getDefaultReferenceParameter()
public void setIncludeDefaultReferences(boolean f)
f
- on/off flagpublic boolean getIncludeDefaultReferences()
protected java.lang.String getIncludeDefaultReferencesParameter()
public void setOptimize(boolean f)
f
- on/off flagpublic boolean getOptimize()
protected java.lang.String getOptimizeParameter()
public void setIncremental(boolean f)
f
- on/off flagpublic boolean getIncremental()
protected java.lang.String getIncrementalParameter()
public void setDebug(boolean f)
f
- on/off flagpublic boolean getDebug()
protected java.lang.String getDebugParameter()
public void setDocFile(java.io.File f)
f
- output fileprotected java.lang.String getDocFileParameter()
public void setWarnLevel(int warnLevel)
warnLevel
- warn level -see .net docs for valid range (probably
0-4)public int getWarnLevel()
protected java.lang.String getWarnLevelParameter()
public void setUnsafe(boolean unsafe)
unsafe
- The new Unsafe valuepublic boolean getUnsafe()
protected java.lang.String getUnsafeParameter()
public void setMainClass(java.lang.String mainClass)
mainClass
- The new MainClass valuepublic java.lang.String getMainClass()
protected java.lang.String getMainClassParameter()
public void setExtraOptions(java.lang.String extraOptions)
extraOptions
- The new ExtraOptions valuepublic java.lang.String getExtraOptions()
protected java.lang.String getExtraOptionsParameter()
public void setSrcDir(java.io.File srcDirName)
srcDirName
- The new SrcDir valuepublic void setDestDir(java.io.File dirName)
dirName
- The new DestDir valuepublic void setTargetType(java.lang.String ttype) throws BuildException
ttype
- The new TargetType value
BuildException
- if target is not one of
exe|library|module|winexepublic java.lang.String getTargetType()
protected java.lang.String getTargetTypeParameter()
public void setWin32Icon(java.io.File fileName)
fileName
- path to the file. Can be relative, absolute, whatever.protected java.lang.String getWin32IconParameter()
public void setWin32Res(java.io.File fileName)
fileName
- path to the file. Can be relative, absolute, whatever.protected java.lang.String getWin32ResParameter()
public void setUtf8Output(boolean enabled)
enabled
- The new utf8Output valueprotected java.lang.String getUtf8OutputParameter()
public void setNoConfig(boolean enabled)
enabled
- The new noConfig valueprotected java.lang.String getNoConfigParameter()
public void setFullPaths(boolean enabled)
enabled
- The new fullPaths valueprotected java.lang.String getFullPathsParameter()
public void setDefinitions(java.lang.String params)
params
- The new definitions valueprotected java.lang.String getDefinitionsParameter()
public void setAdditionalModules(java.lang.String params)
params
- The new additionalModules valueprotected java.lang.String getAdditionalModulesParameter()
public void setOutputFile(java.io.File params)
params
- The new outputFile valuepublic void setDestFile(java.io.File file)
file
- The new outputFile valueprotected java.lang.String getOutputFileParameter()
public void setFailOnError(boolean b)
b
- The new FailOnError valuepublic boolean getFailOnError()
public void setFileAlign(int fileAlign)
protected java.lang.String getFileAlignParameter()
public void Clear()
protected boolean notEmpty(java.lang.String s)
s
- string in
protected void validate() throws BuildException
BuildException
- if validation failedpublic void execute() throws BuildException
execute
in class Task
BuildException
- if validation or execution failed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |