Browse Source

Rewrite 67cdb99 to make more sense and don't regress

Marek Safar 9 years ago
parent
commit
97ede66a07

+ 3 - 3
mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs

@@ -231,10 +231,10 @@ namespace System.Web.Compilation
 		string SetAlPath (ProcessStartInfo info)
 		{			
 			if (RuntimeHelpers.RunningOnWindows) {
-				info.FileName = MonoExeLocator.MonoPath;
-				return MonoExeLocator.AlPath + " ";
+				info.FileName = MonoToolsLocator.Mono;
+				return MonoToolsLocator.AssemblyLinker + " ";
 			} else {
-				info.FileName = MonoExeLocator.AlPath;
+				info.FileName = MonoToolsLocator.AssemblyLinker;
 				return String.Empty;
 			}
 		}

+ 1 - 1
mcs/class/System.Windows.Forms/System.Windows.Forms/Application.cs

@@ -560,7 +560,7 @@ namespace System.Windows.Forms
 			if (Assembly.GetEntryAssembly () == null)
 				throw new NotSupportedException ("The method 'Restart' is not supported by this application type.");
 
-			string mono_path = MonoExeLocator.MonoPath;
+			string mono_path = MonoToolsLocator.Mono;
 
 			//Get command line arguments
 			StringBuilder argsBuilder = new StringBuilder ();

+ 3 - 3
mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs

@@ -132,10 +132,10 @@ namespace Mono.CSharp
 
 			// FIXME: these lines had better be platform independent.
 			if (Path.DirectorySeparatorChar == '\\') {
-				mcs.StartInfo.FileName = MonoExeLocator.MonoPath;
-				mcs.StartInfo.Arguments = "\"" + MonoExeLocator.McsPath + "\" ";
+				mcs.StartInfo.FileName = MonoToolsLocator.Mono;
+				mcs.StartInfo.Arguments = "\"" + MonoToolsLocator.CSharpCompiler + "\" ";
 			} else {
-				mcs.StartInfo.FileName = MonoExeLocator.McsPath;
+				mcs.StartInfo.FileName = MonoToolsLocator.CSharpCompiler;
 			}
 
 			mcs.StartInfo.Arguments += BuildArgs (options, fileNames, ProviderOptions);

+ 3 - 3
mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs

@@ -216,10 +216,10 @@ namespace Microsoft.VisualBasic
 			string[] vbnc_output_lines;
 			// FIXME: these lines had better be platform independent.
 			if (Path.DirectorySeparatorChar == '\\') {
-				vbnc.StartInfo.FileName = MonoExeLocator.MonoPath;
-				vbnc.StartInfo.Arguments = MonoExeLocator.VbncPath + ' ' + BuildArgs (options, fileNames);
+				vbnc.StartInfo.FileName = MonoToolsLocator.Mono;
+				vbnc.StartInfo.Arguments = MonoToolsLocator.VBCompiler + ' ' + BuildArgs (options, fileNames);
 			} else {
-				vbnc.StartInfo.FileName = MonoExeLocator.VbncPath;
+				vbnc.StartInfo.FileName = MonoToolsLocator.VBCompiler;
 				vbnc.StartInfo.Arguments = BuildArgs (options, fileNames);
 			}
 			//Console.WriteLine (vbnc.StartInfo.Arguments);

+ 46 - 54
mcs/class/System/System/MonoExeLocator.cs

@@ -1,4 +1,5 @@
-using System;
+#if !MOBILE
+
 using System.Diagnostics;
 using System.IO;
 using System.Reflection;
@@ -6,88 +7,79 @@ using System.Runtime.InteropServices;
 
 namespace System {
 
-	internal static class MonoExeLocator {
-
-		public static string GacPath { get; private set; }
-		public static string MonoPath { get; private set; }
-		public static string McsPath { get; private set; }
-		public static string VbncPath { get; private set; }
-		public static string AlPath { get; private set; }
-
-		static MonoExeLocator () {
-
-			PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static | BindingFlags.NonPublic);
-			MethodInfo getGacMethod = gac.GetGetMethod (true);
-			GacPath = Path.GetDirectoryName ((string) getGacMethod.Invoke (null, null));
+	static class MonoToolsLocator
+	{
+		public static readonly string Mono;
+		public static readonly string CSharpCompiler;
+		public static readonly string VBCompiler;
+		public static readonly string AssemblyLinker;
 
-			string monoPath = null;
-			string mcsPath = null;
-			string vbncPath = null;
-			string alPath = null;
+		// TODO: Should be lazy
+		static MonoToolsLocator ()
+		{
+			var gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static | BindingFlags.NonPublic);
+			var getGacMethod = gac.GetGetMethod (true);
+			var GacPath = Path.GetDirectoryName ((string) getGacMethod.Invoke (null, null));
 
 			if (Path.DirectorySeparatorChar == '\\') {
 				string processExe = Process.GetCurrentProcess ().MainModule.FileName;
 				if (processExe != null) {
 					string fileName = Path.GetFileName (processExe);
 					if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
-						monoPath = processExe;
+						Mono = processExe;
 				}
 
-				if (!File.Exists (monoPath))
-					monoPath = Path.Combine (
+				if (!File.Exists (Mono))
+					Mono = Path.Combine (
 						Path.GetDirectoryName (
 							Path.GetDirectoryName (GacPath)),
 						"bin\\mono.exe");
 
-				if (!File.Exists (monoPath))
-					monoPath = Path.Combine (
+				if (!File.Exists (Mono))
+					Mono = Path.Combine (
 						Path.GetDirectoryName (
 							Path.GetDirectoryName (
 								Path.GetDirectoryName (GacPath))),
 						"mono\\mini\\mono.exe");
 
-				if (!File.Exists (monoPath))
-					throw new FileNotFoundException ("Windows mono path not found: " + monoPath);
+				//if (!File.Exists (Mono))
+				//	throw new FileNotFoundException ("Windows mono path not found: " + Mono);
 
-				mcsPath = Path.Combine (GacPath, "4.5\\mcs.exe");
-				if (!File.Exists (mcsPath))
-					mcsPath = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\build\\mcs.exe");
+				CSharpCompiler = Path.Combine (GacPath, "4.5\\mcs.exe");
+				if (!File.Exists (CSharpCompiler))
+					CSharpCompiler = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\build\\mcs.exe");
 
-				if (!File.Exists (mcsPath))
-					throw new FileNotFoundException ("Windows mcs path not found: " + mcsPath);
+				//if (!File.Exists (CSharpCompiler))
+				//	throw new FileNotFoundException ("C# compiler not found at " + CSharpCompiler);
 
-				vbncPath = Path.Combine (GacPath,  "4.5\\vbnc.exe");
-				vbncPath = Path.Combine (GacPath,  "4.5\\vbnc.exe");
-				alPath = Path.Combine (GacPath, "4.5\\al.exe");
+				VBCompiler = Path.Combine (GacPath,  "4.5\\vbnc.exe");
+				AssemblyLinker = Path.Combine (GacPath, "4.5\\al.exe");
 
-				if (!File.Exists (alPath)) {
-					alPath = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\net_4_x\\al.exe");
-					if (!File.Exists (alPath))
-						throw new FileNotFoundException ("Windows al path not found: " + alPath);
+				if (!File.Exists (AssemblyLinker)) {
+					AssemblyLinker = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\net_4_x\\al.exe");
+				//	if (!File.Exists (AssemblyLinker))
+				//		throw new FileNotFoundException ("Windows al path not found: " + AssemblyLinker);
 				}
 			} else {
-				monoPath = Path.Combine (GacPath, "bin/mono");
-				if (!File.Exists (MonoPath))
-					monoPath = "mono";
+				Mono = Path.Combine (GacPath, "bin", "mono");
+				if (!File.Exists (Mono))
+					Mono = "mono";
 
 				var mscorlibPath = new Uri (typeof (object).Assembly.CodeBase).LocalPath;
-				mcsPath = Path.GetFullPath( Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "mcs"));
-				if (!File.Exists (mcsPath))
-					mcsPath = "mcs";
+				CSharpCompiler = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "mcs"));
+				if (!File.Exists (CSharpCompiler))
+					CSharpCompiler = "mcs";
 
-				vbncPath = Path.Combine (Path.GetDirectoryName (mcsPath), "vbnc");
-				if (!File.Exists (vbncPath))
-					vbncPath = "vbnc";
+				VBCompiler = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "vbnc"));
+				if (!File.Exists (VBCompiler))
+					VBCompiler = "vbnc";
 
-				alPath = "al";
+				AssemblyLinker = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "al"));
+				if (!File.Exists (AssemblyLinker))
+					AssemblyLinker = "al";
 			}
-
-			McsPath = mcsPath;
-			MonoPath = monoPath;
-			VbncPath = vbncPath;
-			AlPath = alPath;
 		}
-
-		
 	}
 }
+
+#endif