2009-08-18 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / mcs / driver.cs
index c7a648aee14401258dde0b5262971bc1f61c2754..f688846d991d93787f8598985831232e4503fdda 100644 (file)
@@ -26,6 +26,12 @@ namespace Mono.CSharp
        public enum Target {
                Library, Exe, Module, WinExe
        };
+
+#if GMCS_SOURCE
+       enum Platform {
+               AnyCPU, X86, X64, IA64
+       };
+#endif
        
        /// <summary>
        ///    The compiler driver.
@@ -248,6 +254,8 @@ namespace Mono.CSharp
 #if !SMCS_SOURCE
                                "   -pkg:P1[,Pn]         References packages P1..Pn\n" + 
 #endif
+                               "   -platform:ARCH       Specifies the target platform of the output assembly\n" +
+                               "                        ARCH can be one of: anycpu, x86, x64 or itanium\n" +
                                "   -recurse:SPEC        Recursively compiles files according to SPEC pattern\n" + 
                                "   -reference:A1[,An]   Imports metadata from the specified assembly (short: -r)\n" +
                                "   -reference:ALIAS=A   Imports metadata using specified extern alias (short: -r)\n" +                         
@@ -780,6 +788,8 @@ namespace Mono.CSharp
 
                        if (RootContext.Version > LanguageVersion.ISO_2)
                                soft_references.Add ("System.Core");
+                       if (RootContext.Version > LanguageVersion.V_3)
+                               soft_references.Add ("Microsoft.CSharp");
                }
 
                public static string OutputFile
@@ -1429,10 +1439,31 @@ namespace Mono.CSharp
                                load_default_config = false;
                                return true;
 
+                       case "/platform":
+#if GMCS_SOURCE
+                               switch (value.ToLower (CultureInfo.InvariantCulture)) {
+                               case "anycpu":
+                                       RootContext.Platform = Platform.AnyCPU;
+                                       break;
+                               case "x86":
+                                       RootContext.Platform = Platform.X86;
+                                       break;
+                               case "x64":
+                                       RootContext.Platform = Platform.X64;
+                                       break;
+                               case "itanium":
+                                       RootContext.Platform = Platform.IA64;
+                                       break;
+                               default:
+                                       Report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'");
+                                       break;
+                               }
+#endif
+                               return true;
+
                                // We just ignore this.
                        case "/errorreport":
                        case "/filealign":
-                       case "/platform":
                                return true;
                                
                        case "/help2":
@@ -1500,7 +1531,6 @@ namespace Mono.CSharp
                                        RootContext.AddConditional ("__V2__");
 #endif
                                        return true;
-#if GMCS_SOURCE
                                case "iso-2":
                                        RootContext.Version = LanguageVersion.ISO_2;
                                        return true;
@@ -1510,8 +1540,8 @@ namespace Mono.CSharp
                                case "future":
                                        RootContext.Version = LanguageVersion.Future;
                                        return true;
-#endif
                                }
+
                                Report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or `Default'", value);
                                return true;
 
@@ -1802,7 +1832,7 @@ namespace Mono.CSharp
                                try {
                                        CodeGen.Assembly.Builder.DefineUnmanagedResource (win32ResourceFile);
                                } catch (ArgumentException) {
-                                       Report.RuntimeMissingSupport (Location.Null, "resource embeding");
+                                       Report.RuntimeMissingSupport (Location.Null, "resource embedding ");
                                }
                        } else {
                                CodeGen.Assembly.Builder.DefineVersionInfoResource ();
@@ -1811,7 +1841,7 @@ namespace Mono.CSharp
                        if (win32IconFile != null) {
                                MethodInfo define_icon = typeof (AssemblyBuilder).GetMethod ("DefineIconResource", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                                if (define_icon == null) {
-                                       Report.RuntimeMissingSupport (Location.Null, "resource embeding");
+                                       Report.RuntimeMissingSupport (Location.Null, "resource embedding");
                                } else {
                                        define_icon.Invoke (CodeGen.Assembly.Builder, new object [] { win32IconFile });
                                }
@@ -1863,28 +1893,6 @@ namespace Mono.CSharp
 
                class EmbededResource : IResource
                {
-#if GMCS_SOURCE
-                       string name;
-                       string file;
-                       ResourceAttributes attributes;
-
-                       public EmbededResource (string name, string file, bool isPrivate)
-                       {
-                               this.name = name;
-                               this.file = file;
-                               this.attributes = isPrivate ? ResourceAttributes.Private : ResourceAttributes.Public;
-                       }
-
-                       public void Emit ()
-                       {
-                               RootContext.ToplevelTypes.Builder.DefineManifestResource (
-                                       name, new FileStream (file, FileMode.Open, FileAccess.Read), attributes);
-                       }
-
-                       public string FileName {
-                               get { return file; }
-                       }
-#else
                        static MethodInfo embed_res;
 
                        static EmbededResource () {
@@ -1921,7 +1929,6 @@ namespace Mono.CSharp
                                        return (string)args [1];
                                }
                        }
-#endif
                }
 
                class LinkedResource : IResource