|
|
|
|
@ -23,138 +23,6 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -23,138 +23,6 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
/// </summary>
|
|
|
|
|
sealed class BuildEngine |
|
|
|
|
{ |
|
|
|
|
#region Building in the SharpDevelop GUI
|
|
|
|
|
/*static CancellationTokenSource guiBuildCancellation; |
|
|
|
|
static IAnalyticsMonitorTrackedFeature guiBuildTrackedFeature; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts to run a build inside the SharpDevelop GUI.
|
|
|
|
|
/// Only one build can run inside the GUI at one time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="project">The project/solution to build.</param>
|
|
|
|
|
/// <param name="options">The build options.</param>
|
|
|
|
|
public static void BuildInGui(IBuildable project, BuildOptions options) |
|
|
|
|
{ |
|
|
|
|
if (project == null) |
|
|
|
|
throw new ArgumentNullException("project"); |
|
|
|
|
if (options == null) |
|
|
|
|
throw new ArgumentNullException("options"); |
|
|
|
|
WorkbenchSingleton.AssertMainThread(); |
|
|
|
|
if (guiBuildCancellation != null) { |
|
|
|
|
BuildResults results = new BuildResults(); |
|
|
|
|
SD.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")); |
|
|
|
|
BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")); |
|
|
|
|
results.Add(error); |
|
|
|
|
TaskService.Add(new SDTask(error)); |
|
|
|
|
results.Result = BuildResultCode.MSBuildAlreadyRunning; |
|
|
|
|
if (options.Callback != null) { |
|
|
|
|
options.Callback(results); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
guiBuildCancellation = new CancellationTokenSource(); |
|
|
|
|
IProgressMonitor progressMonitor = SD.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token); |
|
|
|
|
guiBuildTrackedFeature = SD.AnalyticsMonitor.TrackFeature("ICSharpCode.SharpDevelop.Project.BuildEngine.Build"); |
|
|
|
|
SD.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}...")); |
|
|
|
|
ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options)); |
|
|
|
|
StartBuild(project, options, |
|
|
|
|
new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, SD.StatusBar)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets whether there is a build currently running inside the SharpDevelop GUI.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static bool IsGuiBuildRunning { |
|
|
|
|
get { |
|
|
|
|
WorkbenchSingleton.AssertMainThread(); |
|
|
|
|
return guiBuildCancellation != null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cancels the build currently running inside the SharpDevelop GUI.
|
|
|
|
|
/// This method does nothing if no build is running.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void CancelGuiBuild() |
|
|
|
|
{ |
|
|
|
|
WorkbenchSingleton.AssertMainThread(); |
|
|
|
|
if (guiBuildCancellation != null) { |
|
|
|
|
guiBuildCancellation.Cancel(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This error message sink is used for GUI builds.
|
|
|
|
|
/// </summary>
|
|
|
|
|
sealed class MessageViewSink : IBuildFeedbackSink |
|
|
|
|
{ |
|
|
|
|
MessageViewCategory messageView; |
|
|
|
|
IProgressMonitor progressMonitor; |
|
|
|
|
IStatusBarService statusBarService; |
|
|
|
|
|
|
|
|
|
public MessageViewSink(MessageViewCategory messageView, IProgressMonitor progressMonitor, IStatusBarService statusBarService) |
|
|
|
|
{ |
|
|
|
|
Debug.Assert(messageView != null); |
|
|
|
|
Debug.Assert(progressMonitor != null); |
|
|
|
|
Debug.Assert(statusBarService != null); |
|
|
|
|
|
|
|
|
|
this.messageView = messageView; |
|
|
|
|
this.progressMonitor = progressMonitor; |
|
|
|
|
this.statusBarService = statusBarService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IProgressMonitor ProgressMonitor { |
|
|
|
|
get { return progressMonitor; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void ReportError(BuildError error) |
|
|
|
|
{ |
|
|
|
|
WorkbenchSingleton.SafeThreadAsyncCall( |
|
|
|
|
delegate { |
|
|
|
|
TaskService.Add(new SDTask(error)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void ReportMessage(string message) |
|
|
|
|
{ |
|
|
|
|
messageView.AppendLine(message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Done(bool success) |
|
|
|
|
{ |
|
|
|
|
throw new InvalidOperationException("The Done(IBuildable,BuildOptions,BuildResults) method should be called instead."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Done(IBuildable buildable, BuildOptions options, BuildResults results) |
|
|
|
|
{ |
|
|
|
|
WorkbenchSingleton.SafeThreadAsyncCall( |
|
|
|
|
delegate { |
|
|
|
|
guiBuildCancellation = null; |
|
|
|
|
if (guiBuildTrackedFeature != null) { |
|
|
|
|
guiBuildTrackedFeature.EndTracking(); |
|
|
|
|
guiBuildTrackedFeature = null; |
|
|
|
|
} |
|
|
|
|
string message; |
|
|
|
|
if (results.Result == BuildResultCode.Cancelled) { |
|
|
|
|
message = "${res:MainWindow.CompilerMessages.BuildCancelled}"; |
|
|
|
|
} else { |
|
|
|
|
if (results.Result == BuildResultCode.Success) |
|
|
|
|
message = "${res:MainWindow.CompilerMessages.BuildFinished}"; |
|
|
|
|
else |
|
|
|
|
message = "${res:MainWindow.CompilerMessages.BuildFailed}"; |
|
|
|
|
|
|
|
|
|
if (results.ErrorCount > 0) |
|
|
|
|
message += " " + results.ErrorCount + " error(s)"; |
|
|
|
|
if (results.WarningCount > 0) |
|
|
|
|
message += " " + results.WarningCount + " warning(s)"; |
|
|
|
|
} |
|
|
|
|
statusBarService.SetMessage(message); |
|
|
|
|
ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region StartBuild
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts to run a build.
|
|
|
|
|
|