From 3d052904a80b216d4bf8a68492a7026133df3fc1 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sun, 21 Sep 2003 22:29:54 +0000 Subject: [PATCH] 1. remove the default library stuff from csc & the compiler. 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-ffa450edef68 --- .../testcases/taskdefs/optional/dotnet.xml | 136 ++++++++++-------- .../taskdefs/optional/dotnet/jsharp.java | 65 +++++++++ .../optional/dotnet/DotnetCompile.java | 101 +------------ .../ant/taskdefs/optional/dotnet/JSharp.java | 2 +- .../ant/taskdefs/optional/DotnetTest.java | 7 +- 5 files changed, 151 insertions(+), 160 deletions(-) create mode 100644 src/etc/testcases/taskdefs/optional/dotnet/jsharp.java diff --git a/src/etc/testcases/taskdefs/optional/dotnet.xml b/src/etc/testcases/taskdefs/optional/dotnet.xml index 5aaadd883..2eed36971 100644 --- a/src/etc/testcases/taskdefs/optional/dotnet.xml +++ b/src/etc/testcases/taskdefs/optional/dotnet.xml @@ -4,11 +4,11 @@ - + - - + + @@ -26,15 +26,24 @@ csc.found=${csc.found} - + - + vbc.found=${vbc.found} - --> + + + + + + + + + jsharp.found=${jsharp.found} @@ -64,7 +73,7 @@ ildasm.found=${ildasm.found} - + @@ -88,31 +97,36 @@ - + - - + + Needed C# compiler is missing - - + + Needed ilasm is missing - - + + + + No vjc on the path + + + - - @@ -122,25 +136,24 @@ - - No app ${testCSC.exe} created - + - @@ -167,14 +180,13 @@ srcDir="." executable="mcs" includedefaultreferences="false" - standardlib="true" > No app ${testCSC.exe} created - + @@ -183,7 +195,7 @@ - No file ${testCSC.dll} created - + - No file ${testCSC.dll} created - + - - @@ -231,17 +242,16 @@ No app ${testCscReferences.exe} created - + - - @@ -253,13 +263,13 @@ No app ${testCscReferences.exe} created - + - - @@ -268,29 +278,29 @@ No app ${testILASM.exe} created - + - + - - - + + - + ${ilasm.string} - + - - No file ${testILDASM.il} created - + - - - - - - + + + + + + + + + + + + diff --git a/src/etc/testcases/taskdefs/optional/dotnet/jsharp.java b/src/etc/testcases/taskdefs/optional/dotnet/jsharp.java new file mode 100644 index 000000000..af90b6779 --- /dev/null +++ b/src/etc/testcases/taskdefs/optional/dotnet/jsharp.java @@ -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 + * . + */ + + +/** + * 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#"); + } + +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java index b4726de68..e6ab0ff9a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java @@ -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 exactly 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()); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java index 7a2056d74..65ce8f6fa 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/JSharp.java @@ -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"); diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java index 9ddf7bcdd..47857cec1 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java @@ -151,6 +151,11 @@ public class DotnetTest extends BuildFileTest { "invalid"); } - + /** + * test we can handle jsharp (if found) + */ + public void testJsharp() throws Exception { + executeTarget("jsharp"); + } }