2009-08-18 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / mcs / driver.cs
index 4ced388bb77938693e2797efbae806c97919207a..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" +                         
@@ -289,8 +297,6 @@ namespace Mono.CSharp
 
                public static int Main (string[] args)
                {
-                       RootContext.Version = LanguageVersion.Default;
-
                        Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
 
                        Driver d = Driver.Create (args, true);
@@ -301,12 +307,14 @@ namespace Mono.CSharp
                                if (Report.Warnings > 0) {
                                        Console.WriteLine ("Compilation succeeded - {0} warning(s)", Report.Warnings);
                                }
+                               Environment.Exit (0);
                                return 0;
                        }
                        
                        
                        Console.WriteLine("Compilation failed: {0} error(s), {1} warnings",
                                Report.Errors, Report.Warnings);
+                       Environment.Exit (1);
                        return 1;
                }
 
@@ -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
@@ -1341,6 +1351,11 @@ namespace Mono.CSharp
                                return true;
                                
                        case "/debug":
+                               if (value == "full" || value == "")
+                                       want_debugging_support = true;
+
+                               return true;
+                               
                        case "/debug+":
                                want_debugging_support = true;
                                return true;
@@ -1424,6 +1439,33 @@ 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":
+                               return true;
+                               
                        case "/help2":
                                OtherFlags ();
                                Environment.Exit(0);
@@ -1489,16 +1531,18 @@ namespace Mono.CSharp
                                        RootContext.AddConditional ("__V2__");
 #endif
                                        return true;
-#if GMCS_SOURCE
                                case "iso-2":
                                        RootContext.Version = LanguageVersion.ISO_2;
                                        return true;
+                               case "3":
+                                       RootContext.Version = LanguageVersion.V_3;
+                                       return true;
                                case "future":
                                        RootContext.Version = LanguageVersion.Future;
                                        return true;
-#endif
                                }
-                               Report.Error (1617, "Invalid option `{0}' for /langversion. It must be either `ISO-1', `ISO-2' or `Default'", value);
+
+                               Report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', `3' or `Default'", value);
                                return true;
 
                        case "/codepage":
@@ -1788,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 ();
@@ -1797,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 });
                                }