X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FMicrosoft.CSharp%2FCSharpCodeCompiler.cs;h=2b987b11482fe13041749a3a448b333a1e57d2bd;hb=df39947352df2c8e6d544763cafed84d23a23b7a;hp=48662a02e2e22f76cc19c1525cc18476ea81d20f;hpb=18751d4475cda0456b25597c3d4f9634c14f8a68;p=mono.git diff --git a/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs b/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs index 48662a02e2e..2b987b11482 100644 --- a/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs +++ b/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs @@ -48,46 +48,9 @@ namespace Mono.CSharp internal class CSharpCodeCompiler : CSharpCodeGenerator, ICodeCompiler { - static string windowsMcsPath; - static string windowsMonoPath; - Mutex mcsOutMutex; StringCollection mcsOutput; - static CSharpCodeCompiler () - { - if (Path.DirectorySeparatorChar == '\\') { - PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic); - MethodInfo get_gac = gac.GetGetMethod (true); - string p = Path.GetDirectoryName ( - (string) get_gac.Invoke (null, null)); - windowsMonoPath = Path.Combine ( - Path.GetDirectoryName ( - Path.GetDirectoryName (p)), - "bin\\mono.bat"); - if (!File.Exists (windowsMonoPath)) - windowsMonoPath = Path.Combine ( - Path.GetDirectoryName ( - Path.GetDirectoryName (p)), - "bin\\mono.exe"); - if (!File.Exists (windowsMonoPath)) - windowsMonoPath = Path.Combine ( - Path.GetDirectoryName ( - Path.GetDirectoryName ( - Path.GetDirectoryName (p))), - "mono\\mono\\mini\\mono.exe"); - if (!File.Exists (windowsMonoPath)) - throw new FileNotFoundException ("Windows mono path not found: " + windowsMonoPath); - - windowsMcsPath = Path.Combine (p, "4.5\\mcs.exe"); - if (!File.Exists (windowsMcsPath)) - windowsMcsPath = Path.Combine(Path.GetDirectoryName (p), "lib\\build\\mcs.exe"); - - if (!File.Exists (windowsMcsPath)) - throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath); - } - } - // // Constructors // @@ -169,14 +132,14 @@ namespace Mono.CSharp // FIXME: these lines had better be platform independent. if (Path.DirectorySeparatorChar == '\\') { - mcs.StartInfo.FileName = windowsMonoPath; - mcs.StartInfo.Arguments = "\"" + windowsMcsPath + "\" " + - BuildArgs (options, fileNames, ProviderOptions); + mcs.StartInfo.FileName = MonoExeLocator.MonoPath; + mcs.StartInfo.Arguments = "\"" + MonoExeLocator.McsPath + "\" "; } else { - mcs.StartInfo.FileName="mcs"; - mcs.StartInfo.Arguments=BuildArgs(options, fileNames, ProviderOptions); + mcs.StartInfo.FileName = MonoExeLocator.McsPath; } + mcs.StartInfo.Arguments += BuildArgs (options, fileNames, ProviderOptions); + mcsOutput = new StringCollection (); mcsOutMutex = new Mutex (); /* @@ -207,6 +170,10 @@ namespace Mono.CSharp mcs.StartInfo.RedirectStandardOutput=true; mcs.StartInfo.RedirectStandardError=true; mcs.ErrorDataReceived += new DataReceivedEventHandler (McsStderrDataReceived); + + // Use same text decoder as mcs and not user set values in Console + mcs.StartInfo.StandardOutputEncoding = + mcs.StartInfo.StandardErrorEncoding = Encoding.UTF8; try { mcs.Start(); @@ -358,7 +325,7 @@ namespace Mono.CSharp } } - args.Append("/sdk:4.5"); + args.Append ("/noconfig "); args.Append (" -- "); foreach (string source in fileNames) @@ -379,6 +346,12 @@ namespace Mono.CSharp \s* (?.*)$"; + static readonly Regex RelatedSymbolsRegex = new Regex( + @" + \(Location\ of\ the\ symbol\ related\ to\ previous\ (warning|error)\) + ", + RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); + private static CompilerError CreateErrorFromString(string error_string) { if (error_string.StartsWith ("BETA")) @@ -391,11 +364,17 @@ namespace Mono.CSharp Regex reg = new Regex (ErrorRegexPattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); Match match=reg.Match(error_string); if (!match.Success) { - // We had some sort of runtime crash - error.ErrorText = error_string; - error.IsWarning = false; - error.ErrorNumber = ""; - return error; + match = RelatedSymbolsRegex.Match (error_string); + if (!match.Success) { + // We had some sort of runtime crash + error.ErrorText = error_string; + error.IsWarning = false; + error.ErrorNumber = ""; + return error; + } else { + // This line is a continuation of previous warning of error + return null; + } } if (String.Empty != match.Result("${file}")) error.FileName=match.Result("${file}");