2. remove the new standardlib flag needed to work around (1) 3. added a test for the jsharp compiler, and a fix to get the task to work. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275274 13f79535-47bb-0310-9956-ffa450edef68master
@@ -4,11 +4,11 @@ | |||
<property environment="env"/> | |||
<property name="build.dir" location="dotnet/build"/> | |||
<property name="src.dir" location="dotnet"/> | |||
<property name="out.csc" location="${src.dir}/out.cs"/> | |||
<property name="out.app" location="${build.dir}/out.exe"/> | |||
<property name="out.type" value="exe"/> | |||
<property name="out.type" value="exe"/> | |||
<target name="probe_for_apps" > | |||
<condition property="ilasm.found"> | |||
<or> | |||
@@ -26,15 +26,24 @@ | |||
</or> | |||
</condition> | |||
<echo> csc.found=${csc.found}</echo> | |||
<!-- <condition property="vbc.found"> | |||
<!-- visual basic compiler --> | |||
<condition property="vbc.found"> | |||
<or> | |||
<available file="vbc" filepath="${env.PATH}" /> | |||
<available file="vbc.exe" filepath="${env.PATH}" /> | |||
<available file="vbc.exe" filepath="${env.Path}" /> | |||
</or> | |||
</condition> | |||
</condition> | |||
<echo> vbc.found=${vbc.found}</echo> | |||
--> | |||
<!-- visual J# compiler --> | |||
<condition property="jsharp.found"> | |||
<or> | |||
<available file="vjc" filepath="${env.PATH}" /> | |||
<available file="vjc.exe" filepath="${env.PATH}" /> | |||
<available file="vjc.exe" filepath="${env.Path}" /> | |||
</or> | |||
</condition> | |||
<echo> jsharp.found=${jsharp.found}</echo> | |||
<!-- Mono C# compiler --> | |||
<condition property="mcs.found"> | |||
@@ -64,7 +73,7 @@ | |||
</or> | |||
</condition> | |||
<echo> ildasm.found=${ildasm.found}</echo> | |||
<condition property="dotnetapps.found"> | |||
<or> | |||
<and> | |||
@@ -88,31 +97,36 @@ | |||
</condition> | |||
<property name="mono.executable" value="mint"/> | |||
</target> | |||
<target name="init" depends="probe_for_apps"> | |||
<mkdir dir="${build.dir}"/> | |||
</target> | |||
<target name="teardown"> | |||
<delete dir="${build.dir}"/> | |||
</target> | |||
</target> | |||
<target name="validate_csc" depends="init"> | |||
<fail unless="c#.found">Needed C# compiler is missing</fail> | |||
</target> | |||
</target> | |||
<target name="validate_ilasm" depends="init"> | |||
<fail unless="ilasm.found">Needed ilasm is missing</fail> | |||
</target> | |||
</target> | |||
<target name="validate_jsharp" depends="init"> | |||
<fail unless="jsharp.found">No vjc on the path</fail> | |||
</target> | |||
<target name="testCSC" depends="testCSC-Mono,testCSC-MS"/> | |||
<target name="testCSC-MS" depends="validate_csc" if="csc.found"> | |||
<property name="testCSC.exe" | |||
<property name="testCSC.exe" | |||
location="${build.dir}/ExampleCsc.exe" /> | |||
<csc | |||
<csc | |||
destFile="${testCSC.exe}" | |||
targetType="exe" | |||
targetType="exe" | |||
> | |||
</csc> | |||
<available property="app.created" file="${testCSC.exe}"/> | |||
@@ -122,25 +136,24 @@ | |||
</target> | |||
<target name="testCSC-Mono" depends="validate_csc" if="mcs.found"> | |||
<property name="testCSC.exe" | |||
<property name="testCSC.exe" | |||
location="${build.dir}/ExampleCsc.exe" /> | |||
<csc | |||
<csc | |||
destFile="${testCSC.exe}" | |||
targetType="exe" | |||
targetType="exe" | |||
executable="mcs" | |||
includedefaultreferences="false" | |||
standardlib="true" | |||
> | |||
</csc> | |||
<available property="app.created" file="${testCSC.exe}"/> | |||
<fail unless="app.created">No app ${testCSC.exe} created</fail> | |||
<exec executable="${mono.executable}" failonerror="true"> | |||
<arg value="${testCSC.exe}"/> | |||
</exec> | |||
</exec> | |||
<delete file="${testCSC.exe}"/> | |||
</target> | |||
<target name="testCSCintrinsicFileset" | |||
<target name="testCSCintrinsicFileset" | |||
depends="testCSCintrinsicFileset-MS,testCSCintrinsicFileset-Mono"/> | |||
<target name="testCSCintrinsicFileset-MS" depends="validate_csc" if="csc.found"> | |||
@@ -167,14 +180,13 @@ | |||
srcDir="." | |||
executable="mcs" | |||
includedefaultreferences="false" | |||
standardlib="true" | |||
> | |||
</csc> | |||
<available property="app.created" file="${testCSC.exe}"/> | |||
<fail unless="app.created">No app ${testCSC.exe} created</fail> | |||
<exec executable="${mono.executable}" failonerror="true"> | |||
<arg value="${testCSC.exe}"/> | |||
</exec> | |||
</exec> | |||
<delete file="${testCSC.exe}"/> | |||
</target> | |||
@@ -183,7 +195,7 @@ | |||
<target name="testCSCdll-MS" depends="validate_csc" if="csc.found"> | |||
<property name="testCSC.dll" | |||
location="${build.dir}/Example2.dll" /> | |||
<csc | |||
<csc | |||
destFile="${testCSC.dll}" | |||
targetType="library" | |||
executable="csc" | |||
@@ -193,33 +205,32 @@ | |||
<available property="dll.created" file="${testCSC.dll}"/> | |||
<fail unless="dll.created">No file ${testCSC.dll} created</fail> | |||
</target> | |||
<target name="testCSCdll-Mono" depends="validate_csc" if="mcs.found"> | |||
<property name="testCSC.dll" | |||
location="${build.dir}/Example2.dll" /> | |||
<csc | |||
<csc | |||
destFile="${testCSC.dll}" | |||
targetType="library" | |||
executable="mcs" | |||
includedefaultreferences="false" | |||
standardlib="true" | |||
> | |||
<src dir="${src.dir}" includes="example2.cs"/> | |||
</csc> | |||
<available property="dll.created" file="${testCSC.dll}"/> | |||
<fail unless="dll.created">No file ${testCSC.dll} created</fail> | |||
</target> | |||
<target name="testCscReferences" | |||
depends="testCscReferences-MS,testCscReferences-Mono"/> | |||
<target name="testCscReferences-MS" depends="validate_csc,testCSCdll-MS" | |||
if="csc.found"> | |||
<property name="testCscReferences.exe" | |||
<property name="testCscReferences.exe" | |||
location="${build.dir}/ExampleCsc2.exe" /> | |||
<csc | |||
<csc | |||
destFile="${testCscReferences.exe}" | |||
targetType="exe" | |||
targetType="exe" | |||
> | |||
<src file="${src.dir}/example.cs"/> | |||
<reference file="${testCSC.dll}" /> | |||
@@ -231,17 +242,16 @@ | |||
<fail unless="refapp.created">No app ${testCscReferences.exe} created</fail> | |||
<exec executable="${testCscReferences.exe}" failonerror="true" /> | |||
</target> | |||
<target name="testCscReferences-Mono" depends="validate_csc,testCSCdll-Mono" | |||
if="mcs.found"> | |||
<property name="testCscReferences.exe" | |||
<property name="testCscReferences.exe" | |||
location="${build.dir}/ExampleCsc2.exe" /> | |||
<csc | |||
<csc | |||
destFile="${testCscReferences.exe}" | |||
targetType="exe" | |||
targetType="exe" | |||
executable="mcs" | |||
includedefaultreferences="false" | |||
standardlib="true" | |||
> | |||
<src file="${src.dir}/example.cs"/> | |||
<reference file="${testCSC.dll}" /> | |||
@@ -253,13 +263,13 @@ | |||
<fail unless="refapp.created">No app ${testCscReferences.exe} created</fail> | |||
<exec executable="${mono.executable}" failonerror="true"> | |||
<arg value="${testCscReferences.exe}"/> | |||
</exec> | |||
</exec> | |||
</target> | |||
<target name="testILASM" depends="validate_ilasm" if="ilasm.found"> | |||
<property name="testILASM.exe" | |||
<property name="testILASM.exe" | |||
location="${build.dir}/ExampleIlasm.exe" /> | |||
<ilasm | |||
<ilasm | |||
destFile="${testILASM.exe}" | |||
targetType="exe" | |||
> | |||
@@ -268,29 +278,29 @@ | |||
<available property="ilasm.created" file="${testILASM.exe}"/> | |||
<fail unless="ilasm.created">No app ${testILASM.exe} created</fail> | |||
<exec executable="${testILASM.exe}" failonerror="true" /> | |||
</target> | |||
</target> | |||
<!-- not including this in the test as it creates an exe in the src dir --> | |||
<target name="testIlasmNoDestFile" depends="validate_ilasm"> | |||
<ilasm | |||
targetType="exe" | |||
<ilasm | |||
targetType="exe" | |||
> | |||
<src dir="${src.dir}" includes="**/*.il"/> | |||
</ilasm> | |||
</target> | |||
</target> | |||
<!-- just here to look at fileset refid conversion by hand --> | |||
<target name="echoFileset"> | |||
<fileset id="ilasm" dir="${src.dir}" includes="**/*.il" /> | |||
<fileset id="ilasm" dir="${src.dir}" includes="**/*.il" /> | |||
<property name="ilasm.string" refid="ilasm"/> | |||
<echo>${ilasm.string}</echo> | |||
</target> | |||
<target name="testILDASM" depends="testILASM" if="ildasm.found"> | |||
<property name="testILDASM.il" | |||
<property name="testILDASM.il" | |||
location="${build.dir}/ExampleIldasm.il" /> | |||
<ildasm | |||
<ildasm | |||
srcFile="${testILASM.exe}" | |||
destFile="${testILDASM.il}" | |||
metadata="true" | |||
@@ -300,15 +310,25 @@ | |||
/> | |||
<available property="ildasm.created" file="${testILDASM.il}"/> | |||
<fail unless="ildasm.created">No file ${testILDASM.il} created</fail> | |||
</target> | |||
</target> | |||
<!-- this is an error --> | |||
<target name="testILDASM_empty" depends="validate_ilasm" > | |||
<ildasm/> | |||
</target> | |||
<target name="testILDASM_empty" depends="validate_ilasm" > | |||
<ildasm/> | |||
</target> | |||
<ildasm/> | |||
</target> | |||
<target name="jsharp" depends="init" if="jsharp.found" > | |||
<property name="jsharp.exe" | |||
location="${build.dir}/jsharp.exe" /> | |||
<jsharpc | |||
destFile="${jsharp.exe}" | |||
targetType="exe" | |||
> | |||
<src dir="dotnet" includes="*.java"/> | |||
</jsharpc> | |||
<exec executable="${jsharp.exe}" failonerror="true" /> | |||
</target> | |||
</project> | |||
@@ -0,0 +1,65 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2003 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions | |||
* are met: | |||
* | |||
* 1. Redistributions of source code must retain the above copyright | |||
* notice, this list of conditions and the following disclaimer. | |||
* | |||
* 2. Redistributions in binary form must reproduce the above copyright | |||
* notice, this list of conditions and the following disclaimer in | |||
* the documentation and/or other materials provided with the | |||
* distribution. | |||
* | |||
* 3. The end-user documentation included with the redistribution, if | |||
* any, must include the following acknowlegement: | |||
* "This product includes software developed by the | |||
* Apache Software Foundation (http://www.apache.org/)." | |||
* Alternately, this acknowlegement may appear in the software itself, | |||
* if and wherever such third-party acknowlegements normally appear. | |||
* | |||
* 4. The names "Ant" and "Apache Software | |||
* Foundation" must not be used to endorse or promote products derived | |||
* from this software without prior written permission. For written | |||
* permission, please contact apache@apache.org. | |||
* | |||
* 5. Products derived from this software may not be called "Apache" | |||
* nor may "Apache" appear in their names without prior written | |||
* permission of the Apache Group. | |||
* | |||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
* SUCH DAMAGE. | |||
* ==================================================================== | |||
* | |||
* This software consists of voluntary contributions made by many | |||
* individuals on behalf of the Apache Software Foundation. For more | |||
* information on the Apache Software Foundation, please see | |||
* <http://www.apache.org/>. | |||
*/ | |||
/** | |||
* this is a j# class, not a java one. | |||
*/ | |||
public class jsharp { | |||
public static void main(String args[]) { | |||
System.out.println("hello, I look like Java, but I'm really J#"); | |||
} | |||
} |
@@ -160,46 +160,6 @@ public abstract class DotnetCompile | |||
protected String executable; | |||
protected Boolean standardLib; | |||
/** | |||
* Fix .NET reference inclusion. .NET is really dumb in how it handles | |||
* inclusion. You have to list every 'assembly' -read DLL that is imported. | |||
* So already you are making a platform assumption -shared libraries have a | |||
* .dll;"+ extension and the poor developer has to know every library which | |||
* is included why the compiler cant find classes on the path or in a | |||
* directory, is a mystery. To reduce the need to be explicit, here is a | |||
* long list of the core libraries used in Beta-1 of .NET omitting the | |||
* blatantly non portable (MS.win32.interop) and the .designer libraries. | |||
* (ripping out Com was tempting) Casing is chosen to match that of the | |||
* file system <i>exactly</i> so may work on a unix box too. there is no | |||
* need to reference mscorlib.dll, because it is always there | |||
*/ | |||
protected static final String[] DEFAULT_REFERENCE_LIST_DOTNET_10 = {"Accessibility.dll", | |||
"cscompmgd.dll", | |||
"CustomMarshalers.dll", | |||
"Mscorcfg.dll", | |||
"System.Configuration.Install.dll", | |||
"System.Data.dll", | |||
"System.Design.dll", | |||
"System.DirectoryServices.dll", | |||
"System.EnterpriseServices.dll", | |||
"System.dll", | |||
"System.Drawing.Design.dll", | |||
"System.Drawing.dll", | |||
"System.Management.dll", | |||
"System.Messaging.dll", | |||
"System.Runtime.Remoting.dll", | |||
"System.Runtime.Serialization.Formatters.Soap.dll", | |||
"System.Security.dll", | |||
"System.ServiceProcess.dll", | |||
"System.Web.dll", | |||
"System.Web.RegularExpressions.dll", | |||
"System.Web.Services.dll", | |||
"System.Windows.Forms.dll", | |||
"System.XML.dll"}; | |||
protected static final String REFERENCE_OPTION = "/reference:"; | |||
/** | |||
@@ -348,22 +308,6 @@ public abstract class DotnetCompile | |||
} | |||
/** | |||
* get default reference list | |||
* | |||
*@return null or a string of references. | |||
*/ | |||
protected String getDefaultReferenceParameter() { | |||
if (includeDefaultReferences) { | |||
StringBuffer s = new StringBuffer("/reference:"); | |||
s.append(getDefaultReferenceList()); | |||
return new String(s); | |||
} else { | |||
return null; | |||
} | |||
} | |||
/** | |||
* If true, automatically includes the common assemblies | |||
* in dotnet, and tells the compiler to link in mscore.dll. | |||
@@ -394,11 +338,7 @@ public abstract class DotnetCompile | |||
*@return The Parameter to CSC | |||
*/ | |||
protected String getIncludeDefaultReferencesParameter() { | |||
if (standardLib == null) { | |||
return "/nostdlib" + (includeDefaultReferences ? "-" : "+"); | |||
} else { | |||
return null; | |||
} | |||
return "/nostdlib" + (includeDefaultReferences ? "-" : "+"); | |||
} | |||
@@ -826,29 +766,6 @@ public abstract class DotnetCompile | |||
this.executable = executable; | |||
} | |||
/** | |||
* turn standard lib support on or off. | |||
* Setting this in either direction overrides anything set in defaultreferences. | |||
* @param standardLib | |||
*/ | |||
public void setStandardLib(Boolean standardLib) { | |||
this.standardLib = standardLib; | |||
} | |||
/** | |||
* get the include default references flag or null for no argument needed | |||
* | |||
*@return The Parameter to CSC | |||
*/ | |||
protected String getStandardLibParameter() { | |||
if (standardLib != null) { | |||
return "/nostdlib" + (standardLib.booleanValue() ? "-" : "+"); | |||
} else { | |||
return null; | |||
} | |||
} | |||
/** | |||
* test for a string containing something useful | |||
* | |||
@@ -873,20 +790,6 @@ public abstract class DotnetCompile | |||
} | |||
} | |||
/** | |||
* Based on DEFAULT_REFERENCE_LIST and getReferenceDelimiter(), | |||
* build the appropriate reference string for the compiler. | |||
* @return The properly delimited reference list. | |||
*/ | |||
public String getDefaultReferenceList() { | |||
StringBuffer referenceList = new StringBuffer(); | |||
for (int index = 0; index < DEFAULT_REFERENCE_LIST_DOTNET_10.length; index++) { | |||
referenceList.append(DEFAULT_REFERENCE_LIST_DOTNET_10[index]); | |||
referenceList.append(getReferenceDelimiter()); | |||
} | |||
return referenceList.toString(); | |||
} | |||
/** | |||
* Get the pattern for files to compile. | |||
* @return The compilation file pattern. | |||
@@ -941,8 +844,6 @@ public abstract class DotnetCompile | |||
command.addArgument("/nologo"); | |||
command.addArgument(getAdditionalModulesParameter()); | |||
command.addArgument(getDebugParameter()); | |||
command.addArgument(getDefaultReferenceParameter()); | |||
command.addArgument(getStandardLibParameter()); | |||
command.addArgument(getDefinitionsParameter()); | |||
command.addArgument(getExtraOptionsParameter()); | |||
command.addArgument(getMainClassParameter()); | |||
@@ -136,7 +136,7 @@ public class JSharp extends DotnetCompile { | |||
*/ | |||
protected void addCompilerSpecificOptions(NetCommand command) { | |||
if (pureJava) { | |||
command.addArgument("/x"); | |||
command.addArgument("/x:all"); | |||
} | |||
if (secureScoping) { | |||
command.addArgument("/securescoping"); | |||
@@ -151,6 +151,11 @@ public class DotnetTest extends BuildFileTest { | |||
"invalid"); | |||
} | |||
/** | |||
* test we can handle jsharp (if found) | |||
*/ | |||
public void testJsharp() throws Exception { | |||
executeTarget("jsharp"); | |||
} | |||
} | |||