~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
using MonoDevelop.CSharp.Project;
39
39
using System.Threading;
40
40
using MonoDevelop.Ide;
 
41
using MonoDevelop.Core.ProgressMonitoring;
41
42
 
42
43
 
43
44
namespace MonoDevelop.CSharp
123
124
                        foreach (ProjectReference lib in projectItems.GetAll <ProjectReference> ()) {
124
125
                                if (lib.ReferenceType == ReferenceType.Project && !(lib.OwnerProject.ParentSolution.FindProjectByName (lib.Reference) is DotNetProject))
125
126
                                        continue;
 
127
                                string refPrefix = string.IsNullOrEmpty (lib.Aliases) ? "" : lib.Aliases + "=";
126
128
                                foreach (string fileName in lib.GetReferencedFileNames (configSelector)) {
127
129
                                        switch (lib.ReferenceType) {
128
130
                                        case ReferenceType.Package:
134
136
                                                }
135
137
 
136
138
                                                if (alreadyAddedReference.Add (fileName))
137
 
                                                        AppendQuoted (sb, "/r:", fileName);
 
139
                                                        AppendQuoted (sb, "/r:", refPrefix + fileName);
138
140
                                                
139
141
                                                if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
140
142
                                                        gacRoots.Add (pkg.GacRoot);
152
154
                                                break;
153
155
                                        default:
154
156
                                                if (alreadyAddedReference.Add (fileName))
155
 
                                                        AppendQuoted (sb, "/r:", fileName);
 
157
                                                        AppendQuoted (sb, "/r:", refPrefix + fileName);
156
158
                                                break;
157
159
                                        }
158
160
                                }
172
174
                        if (configuration.SignAssembly) {
173
175
                                if (File.Exists (configuration.AssemblyKeyFile))
174
176
                                        AppendQuoted (sb, "/keyfile:", configuration.AssemblyKeyFile);
175
 
                        }
176
 
                        
177
 
                        if (configuration.DebugMode) {
178
 
//                              sb.AppendLine ("/debug:+");
179
 
                                sb.AppendLine ("/debug:full");
180
 
                        }
181
 
                        
182
 
                        switch (compilerParameters.LangVersion) {
183
 
                        case LangVersion.Default:
184
 
                                break;
185
 
                        case LangVersion.ISO_1:
186
 
                                sb.AppendLine ("/langversion:ISO-1");
187
 
                                break;
188
 
                        case LangVersion.ISO_2:
189
 
                                sb.AppendLine ("/langversion:ISO-2");
190
 
                                break;
191
 
                        default:
192
 
                                string message = "Invalid LangVersion enum value '" + compilerParameters.LangVersion.ToString () + "'";
193
 
                                monitor.ReportError (message, null);
194
 
                                LoggingService.LogError (message);
195
 
                                return null;
 
177
                                if (configuration.DelaySign)
 
178
                                        sb.AppendLine ("/delaySign");
 
179
                        }
 
180
 
 
181
                        var debugType = compilerParameters.DebugType;
 
182
                        if (string.IsNullOrEmpty (debugType)) {
 
183
                                debugType = configuration.DebugMode ? "full" : "none";
 
184
                        } else if (string.Equals (debugType, "pdbonly", StringComparison.OrdinalIgnoreCase)) {
 
185
                                //old Mono compilers don't support pdbonly
 
186
                                if (monoRuntime != null && !monoRuntime.HasMultitargetingMcs)
 
187
                                        debugType = "full";
 
188
                        }
 
189
                        if (!string.Equals (debugType, "none", StringComparison.OrdinalIgnoreCase)) {
 
190
                                        sb.AppendLine ("/debug:" + debugType);
 
191
                        }
 
192
 
 
193
                        if (compilerParameters.LangVersion != LangVersion.Default) {
 
194
                                var langVersionString = CSharpCompilerParameters.TryLangVersionToString (compilerParameters.LangVersion);
 
195
                                if (langVersionString == null) {
 
196
                                        string message = "Invalid LangVersion enum value '" + compilerParameters.LangVersion.ToString () + "'";
 
197
                                        monitor.ReportError (message, null);
 
198
                                        LoggingService.LogError (message);
 
199
                                        return null;
 
200
                                }
 
201
                                sb.AppendLine ("/langversion:" + langVersionString);
196
202
                        }
197
203
                        
198
204
                        // mcs default is + but others might not be
329
335
                        ExecutionEnvironment envVars = runtime.GetToolsExecutionEnvironment (project.TargetFramework);
330
336
                        string cargs = "/noconfig @\"" + responseFileName + "\"";
331
337
 
332
 
                        int exitCode = DoCompilation (compilerName, cargs, workingDir, envVars, gacRoots, ref output, ref error);
 
338
                        int exitCode = DoCompilation (monitor, compilerName, cargs, workingDir, envVars, gacRoots, ref output, ref error);
333
339
                        
334
340
                        BuildResult result = ParseOutput (output, error);
335
341
                        if (result.CompilerOutput.Trim ().Length != 0)
411
417
                        return result;
412
418
                }
413
419
                
414
 
                static int DoCompilation (string compilerName, string compilerArgs, string working_dir, ExecutionEnvironment envVars, List<string> gacRoots, ref string output, ref string error) 
 
420
                static int DoCompilation (IProgressMonitor monitor, string compilerName, string compilerArgs, string working_dir, ExecutionEnvironment envVars, List<string> gacRoots, ref string output, ref string error)
415
421
                {
416
 
                        output = Path.GetTempFileName();
417
 
                        error = Path.GetTempFileName();
 
422
                        output = Path.GetTempFileName ();
 
423
                        error = Path.GetTempFileName ();
418
424
                        
419
425
                        StreamWriter outwr = new StreamWriter (output);
420
426
                        StreamWriter errwr = new StreamWriter (error);
438
444
                        pinfo.UseShellExecute = false;
439
445
                        pinfo.RedirectStandardOutput = true;
440
446
                        pinfo.RedirectStandardError = true;
441
 
                        
 
447
 
442
448
                        MonoDevelop.Core.Execution.ProcessWrapper pw = Runtime.ProcessService.StartProcess (pinfo, outwr, errwr, null);
443
 
                        pw.WaitForOutput();
 
449
                        using (var mon = new AggregatedOperationMonitor (monitor, pw)) {
 
450
                                pw.WaitForOutput ();
 
451
                        }
444
452
                        int exitCode = pw.ExitCode;
445
 
                        outwr.Close();
446
 
                        errwr.Close();
 
453
                        outwr.Close ();
 
454
                        errwr.Close ();
447
455
                        pw.Dispose ();
448
456
                        return exitCode;
449
457
                }
450
458
                
451
459
                // Snatched from our codedom code, with some changes to make it compatible with csc
452
460
                // (the line+column group is optional is csc)
453
 
                static Regex regexError = new Regex (@"^(\s*(?<file>[^\(]+)(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))?:\s+)*(?<level>\w+)\s+(?<number>..\d+):\s*(?<message>.*)", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
 
461
                static Regex regexError = new Regex (@"^(\s*(?<file>.+[^)])(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))?:\s+)*(?<level>\w+)\s+(?<number>..\d+):\s*(?<message>.*)", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
454
462
                static BuildError CreateErrorFromString (string error_string)
455
463
                {
456
464
                        // When IncludeDebugInformation is true, prevents the debug symbols stats from braeking this.