X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMicrosoft.Build.Engine%2FMicrosoft.Build.BuildEngine%2FTarget.cs;h=b039112044481ba408352640fecd09baf3127f28;hb=d531a7515eaad9fb1c2ca9fff160851fa70aa168;hp=7f53ecf5022174d21cd4a8b44b38b8d836ddece0;hpb=c1d2670d6f4713c48c143da4c2216baf2c269db5;p=mono.git diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs index 7f53ecf5022..b0391120444 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs @@ -37,7 +37,7 @@ using Microsoft.Build.Utilities; namespace Microsoft.Build.BuildEngine { public class Target : IEnumerable { - BatchingImpl batchingImpl; + TargetBatchingImpl batchingImpl; BuildState buildState; Engine engine; ImportedProject importedProject; @@ -64,7 +64,7 @@ namespace Microsoft.Build.BuildEngine { this.onErrorElements = new List (); this.buildState = BuildState.NotStarted; this.buildTasks = new List (); - this.batchingImpl = new BatchingImpl (project, this.targetElement); + this.batchingImpl = new TargetBatchingImpl (project, this.targetElement); bool onErrorFound = false; foreach (XmlNode xn in targetElement.ChildNodes) { @@ -128,7 +128,8 @@ namespace Microsoft.Build.BuildEngine { buildState = BuildState.Finished; // FIXME: log it - } catch (Exception) { + } catch (Exception e) { + LogError ("Error building target {0}: {1}", Name, e.ToString ()); return false; } @@ -171,26 +172,20 @@ namespace Microsoft.Build.BuildEngine { bool DoBuild () { - bool executeOnErrors = false; + bool executeOnErrors; bool result = true; + + if (BuildTasks.Count == 0) + // nothing to do + return true; - LogTargetStarted (); - - if (batchingImpl.BuildNeeded ()) { - foreach (BuildTask bt in buildTasks) { - result = batchingImpl.BatchBuildTask (bt); - - if (!result && !bt.ContinueOnError) { - executeOnErrors = true; - break; - } - } - } else { - LogTargetSkipped (); + try { + result = batchingImpl.Build (this, out executeOnErrors); + } catch (Exception e) { + LogError ("Error building target {0}: {1}", Name, e.ToString ()); + throw; } - LogTargetFinished (result); - if (executeOnErrors == true) ExecuteOnErrors (); @@ -209,28 +204,15 @@ namespace Microsoft.Build.BuildEngine { } } - void LogTargetSkipped () - { - BuildMessageEventArgs bmea; - bmea = new BuildMessageEventArgs (String.Format ("Skipping target \"{0}\" because its outputs are up-to-date.", - name), null, "MSBuild", MessageImportance.Normal); - engine.EventSource.FireMessageRaised (this, bmea); - } - - void LogTargetStarted () + void LogError (string message, params object [] messageArgs) { - TargetStartedEventArgs tsea; - string projectFile = project.FullFileName; - tsea = new TargetStartedEventArgs (String.Format ("Target {0} started.", name), null, name, projectFile, null); - engine.EventSource.FireTargetStarted (this, tsea); - } - - void LogTargetFinished (bool succeeded) - { - TargetFinishedEventArgs tfea; - string projectFile = project.FullFileName; - tfea = new TargetFinishedEventArgs (String.Format ("Target {0} finished.", name), null, name, projectFile, null, succeeded); - engine.EventSource.FireTargetFinished (this, tfea); + if (message == null) + throw new ArgumentException ("message"); + + BuildErrorEventArgs beea = new BuildErrorEventArgs ( + null, null, null, 0, 0, 0, 0, String.Format (message, messageArgs), + null, null); + engine.EventSource.FireErrorRaised (this, beea); } public string Condition { @@ -254,12 +236,19 @@ namespace Microsoft.Build.BuildEngine { internal Project Project { get { return project; } } + + internal List BuildTasks { + get { return buildTasks; } + } + + internal Engine Engine { + get { return engine; } + } internal BuildState BuildState { get { return buildState; } } - // FIXME: implement batching internal ITaskItem [] Outputs { get { string outputs = targetElement.GetAttribute ("Outputs"); @@ -269,11 +258,7 @@ namespace Microsoft.Build.BuildEngine { Expression e = new Expression (); e.Parse (outputs, true); - string [] outputFiles = (string []) e.ConvertTo (project, typeof (string [])); - ITaskItem [] outputItems = new ITaskItem [outputFiles.Length]; - for (int i = 0; i < outputFiles.Length; i++) - outputItems [i] = new TaskItem (outputFiles [i]); - return outputItems; + return (ITaskItem []) e.ConvertTo (project, typeof (ITaskItem [])); } } }