(a) so you can refer to versions off the path (useful for multiple versions) (b) so you can use other implementations than the windows one. Specifically, Mono Csharp compiler, msc, apparently uses the same syntax as csc if desired. We will have to test this... I suppose we could test Rotor too, but I cant be bothered git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275000 13f79535-47bb-0310-9956-ffa450edef68master
@@ -67,20 +67,35 @@ | |||||
destFile="${testCSC.exe}" | destFile="${testCSC.exe}" | ||||
targetType="exe" | targetType="exe" | ||||
> | > | ||||
<src dir="${src.dir}" includes="**/*.cs"/> | |||||
</csc> | </csc> | ||||
<available property="app.created" file="${testCSC.exe}"/> | <available property="app.created" file="${testCSC.exe}"/> | ||||
<fail unless="app.created">No app ${testCSC.exe} created</fail> | <fail unless="app.created">No app ${testCSC.exe} created</fail> | ||||
<exec executable="${testCSC.exe}" failonerror="true" /> | <exec executable="${testCSC.exe}" failonerror="true" /> | ||||
<delete file="${testCSC.exe}"/> | |||||
</target> | </target> | ||||
<target name="testCSCintrinsicFileset" depends="init"> | |||||
<property name="testCSC.exe" | |||||
location="${build.dir}/ExampleCsc.exe"/> | |||||
<csc | |||||
destFile="${testCSC.exe}" | |||||
targetType="exe" | |||||
srcDir="." | |||||
> | |||||
</csc> | |||||
<available property="app.created" file="${testCSC.exe}"/> | |||||
<fail unless="app.created">No app ${testCSC.exe} created</fail> | |||||
<exec executable="${testCSC.exe}" failonerror="true"/> | |||||
<delete file="${testCSC.exe}"/> | |||||
</target> | |||||
<target name="testCSCdll" depends="init"> | <target name="testCSCdll" depends="init"> | ||||
<property name="testCSC.dll" | |||||
<property name="testCSC.dll" | |||||
location="${build.dir}/Example2.dll" /> | location="${build.dir}/Example2.dll" /> | ||||
<csc | <csc | ||||
destFile="${testCSC.dll}" | destFile="${testCSC.dll}" | ||||
targetType="library" | |||||
targetType="library" | |||||
executable="csc" | |||||
> | > | ||||
<src dir="${src.dir}" includes="example2.cs"/> | <src dir="${src.dir}" includes="example2.cs"/> | ||||
</csc> | </csc> | ||||
@@ -199,6 +199,7 @@ public class CSharp extends DotnetCompile { | |||||
*/ | */ | ||||
public CSharp() { | public CSharp() { | ||||
clear(); | |||||
} | } | ||||
/** | /** | ||||
@@ -213,7 +214,7 @@ public class CSharp extends DotnetCompile { | |||||
unsafe = false; | unsafe = false; | ||||
noconfig = false; | noconfig = false; | ||||
definitions = null; | definitions = null; | ||||
setExecutable("csc"); | |||||
} | } | ||||
@@ -426,13 +427,6 @@ public class CSharp extends DotnetCompile { | |||||
return ";"; | return ";"; | ||||
} | } | ||||
/** | |||||
* compiler is 'csc' | |||||
* @return | |||||
*/ | |||||
public String getCompilerExeName() { | |||||
return "csc"; | |||||
} | |||||
/** | /** | ||||
* extension is '.cs' | * extension is '.cs' | ||||
@@ -137,7 +137,7 @@ public class DotnetBaseMatchingTask extends MatchingTask { | |||||
= getSrcDir() != null || filesets.size() == 0; | = getSrcDir() != null || filesets.size() == 0; | ||||
if (scanImplicitFileset) { | if (scanImplicitFileset) { | ||||
//scan for an implicit fileset if there was a srcdir set | //scan for an implicit fileset if there was a srcdir set | ||||
//or there was no srcDir set but the @ | |||||
//or there was no srcDir set but there was no contained classes | |||||
if (getSrcDir() == null) { | if (getSrcDir() == null) { | ||||
//if there is no src dir here, set it | //if there is no src dir here, set it | ||||
setSrcDir(getProject().resolveFile(".")); | setSrcDir(getProject().resolveFile(".")); | ||||
@@ -154,6 +154,12 @@ public abstract class DotnetCompile | |||||
*/ | */ | ||||
protected Vector resources = new Vector(); | protected Vector resources = new Vector(); | ||||
/** | |||||
* executable | |||||
*/ | |||||
protected String executable; | |||||
/** | /** | ||||
* Fix .NET reference inclusion. .NET is really dumb in how it handles | * Fix .NET reference inclusion. .NET is really dumb in how it handles | ||||
* inclusion. You have to list every 'assembly' -read DLL that is imported. | * inclusion. You have to list every 'assembly' -read DLL that is imported. | ||||
@@ -790,6 +796,26 @@ public abstract class DotnetCompile | |||||
resources.add(resource); | resources.add(resource); | ||||
} | } | ||||
/** | |||||
* what is the executable? | |||||
* @return | |||||
*/ | |||||
protected String getExecutable() { | |||||
return executable; | |||||
} | |||||
/** | |||||
* set the name of the program, overriding the defaults. | |||||
* Can be used to set the full path to a program, or to switch | |||||
* to an alternate implementation of the command, such as the Mono or Rotor | |||||
* versions -provided they use the same command line arguments as the | |||||
* .NET framework edition | |||||
* @param executable | |||||
*/ | |||||
public void setExecutable(String executable) { | |||||
this.executable = executable; | |||||
} | |||||
/** | /** | ||||
* test for a string containing something useful | * test for a string containing something useful | ||||
* | * | ||||
@@ -809,6 +835,9 @@ public abstract class DotnetCompile | |||||
if (outputFile != null && outputFile.isDirectory()) { | if (outputFile != null && outputFile.isDirectory()) { | ||||
throw new BuildException("destFile cannot be a directory"); | throw new BuildException("destFile cannot be a directory"); | ||||
} | } | ||||
if(getExecutable()==null) { | |||||
throw new BuildException("There is no executable defined for this task"); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -862,12 +891,6 @@ public abstract class DotnetCompile | |||||
*/ | */ | ||||
public abstract String getReferenceDelimiter(); | public abstract String getReferenceDelimiter(); | ||||
/** | |||||
* Get the name of the compiler executable. | |||||
* @return The name of the compiler executable. | |||||
*/ | |||||
public abstract String getCompilerExeName() ; | |||||
/** | /** | ||||
* Get the extension of filenames to compile. | * Get the extension of filenames to compile. | ||||
* @return The string extension of files to compile. | * @return The string extension of files to compile. | ||||
@@ -963,7 +986,7 @@ public abstract class DotnetCompile | |||||
* @return a command prefilled with the exe name and task name | * @return a command prefilled with the exe name and task name | ||||
*/ | */ | ||||
protected NetCommand createNetCommand() { | protected NetCommand createNetCommand() { | ||||
NetCommand command = new NetCommand(this, getTaskName(), getCompilerExeName()); | |||||
NetCommand command = new NetCommand(this, getTaskName(), getExecutable()); | |||||
return command; | return command; | ||||
} | } | ||||
@@ -84,7 +84,11 @@ public class JSharp extends DotnetCompile { | |||||
*/ | */ | ||||
boolean secureScoping = false; | boolean secureScoping = false; | ||||
public JSharp() { | |||||
setExecutable("vjc"); | |||||
} | |||||
public void setBaseAddress(String baseAddress) { | public void setBaseAddress(String baseAddress) { | ||||
this.baseAddress = baseAddress; | this.baseAddress = baseAddress; | ||||
} | } | ||||
@@ -116,13 +120,7 @@ public class JSharp extends DotnetCompile { | |||||
return ";"; | return ";"; | ||||
} | } | ||||
/** | |||||
* Get the name of the compiler executable. | |||||
* @return The name of the compiler executable. | |||||
*/ | |||||
public String getCompilerExeName() { | |||||
return "vjc"; | |||||
} | |||||
/** | /** | ||||
* Get the extension of filenames to compile. | * Get the extension of filenames to compile. | ||||
@@ -107,7 +107,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||||
* Constructor for VisualBasicCompile. | * Constructor for VisualBasicCompile. | ||||
*/ | */ | ||||
public VisualBasicCompile() { | public VisualBasicCompile() { | ||||
super(); | |||||
clear(); | |||||
} | } | ||||
/** | /** | ||||
@@ -121,6 +121,7 @@ public class VisualBasicCompile extends DotnetCompile { | |||||
optionExplicit = false; | optionExplicit = false; | ||||
optionStrict = false; | optionStrict = false; | ||||
removeIntChecks = false; | removeIntChecks = false; | ||||
setExecutable("vbc"); | |||||
} | } | ||||
/** | /** | ||||
@@ -349,14 +350,6 @@ public class VisualBasicCompile extends DotnetCompile { | |||||
return resource.getVbStyleParameter(); | return resource.getVbStyleParameter(); | ||||
} | } | ||||
/** | |||||
* Get the name of the compiler executable. | |||||
* @return The name of the compiler executable. | |||||
*/ | |||||
public String getCompilerExeName() { | |||||
return "vbc"; | |||||
} | |||||
/** | /** | ||||
* validation code | * validation code | ||||
* @throws BuildException if validation failed | * @throws BuildException if validation failed | ||||
@@ -106,6 +106,14 @@ public class DotnetTest extends BuildFileTest { | |||||
} | } | ||||
/** | |||||
* A unit test for JUnit | |||||
*/ | |||||
public void testCSCintrinsicFileset() throws Exception { | |||||
executeTarget("testCSCintrinsicFileset"); | |||||
} | |||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||