using System;
using System.Collections.Generic;
+using System.Linq;
namespace Microsoft.Build.Execution
{
public class BuildResult
{
+ public BuildResult ()
+ {
+ ResultsByTarget = new Dictionary<string, TargetResult> ();
+ }
+
public void AddResultsForTarget (string target, TargetResult result)
{
- throw new NotImplementedException ();
+ ResultsByTarget.Add (target, result);
}
public bool HasResultsForTarget (string target)
{
- throw new NotImplementedException ();
+ return ResultsByTarget.ContainsKey (target);
}
public void MergeResults (BuildResult results)
{
- throw new NotImplementedException ();
+ if (ConfigurationId != results.ConfigurationId)
+ throw new InvalidOperationException ("Argument BuildResults have inconsistent ConfigurationId.");
+ if (GlobalRequestId != results.GlobalRequestId)
+ throw new InvalidOperationException ("Argument BuildResults have inconsistent GlobalRequestId.");
+ if (NodeRequestId != results.NodeRequestId)
+ throw new InvalidOperationException ("Argument BuildResults have inconsistent NodeRequestId.");
+ if (ParentGlobalRequestId != results.ParentGlobalRequestId)
+ throw new InvalidOperationException ("Argument BuildResults have inconsistent ParentGlobalRequestId.");
+ if (SubmissionId != results.SubmissionId)
+ throw new InvalidOperationException ("Argument BuildResults have inconsistent SubmissionId.");
+
+ CircularDependency |= results.CircularDependency;
+ Exception = Exception ?? results.Exception;
+ foreach (var p in results.ResultsByTarget)
+ ResultsByTarget.Add (p.Key, p.Value);
}
- public bool CircularDependency {
- get { throw new NotImplementedException (); }
- }
+ public bool CircularDependency { get; internal set; }
- public int ConfigurationId {
- get { throw new NotImplementedException (); }
- }
+ public int ConfigurationId { get; internal set; }
- public Exception Exception {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
+ public Exception Exception { get; set; }
- public int GlobalRequestId {
- get { throw new NotImplementedException (); }
- }
+ public int GlobalRequestId { get; internal set; }
public ITargetResult this [string target] {
- get { throw new NotImplementedException (); }
+ get { return ResultsByTarget [target]; }
}
- public int NodeRequestId {
- get { throw new NotImplementedException (); }
- }
+ public int NodeRequestId { get; internal set; }
+ BuildResultCode? overall_result;
public BuildResultCode OverallResult {
- get { throw new NotImplementedException (); }
+ get {
+ if (overall_result == null)
+ throw new InvalidOperationException ("Build has not finished");
+ return overall_result.Value;
+ }
+ internal set { overall_result = value; }
}
- public int ParentGlobalRequestId {
- get { throw new NotImplementedException (); }
- }
+ public int ParentGlobalRequestId { get; internal set; }
- public IDictionary<string, TargetResult> ResultsByTarget {
- get { throw new NotImplementedException (); }
- }
+ public IDictionary<string, TargetResult> ResultsByTarget { get; private set; }
- public int SubmissionId {
- get { throw new NotImplementedException (); }
- }
+ public int SubmissionId { get; internal set; }
}
}
//
// Author:
// Rolf Bjarne Kvinge (rolf@xamarin.com)
+// Atsushi Enomoto (atsushi@xamarin.com)
//
-// Copyright (C) 2011 Xamarin Inc.
+// Copyright (C) 2011,2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
using System;
using System.Threading;
using System.Threading.Tasks;
+using System.Linq;
+using Microsoft.Build.Framework;
namespace Microsoft.Build.Execution
{
BuildRequestData request;
BuildSubmissionCompleteCallback callback;
bool is_started, is_completed, is_canceled;
+ ManualResetEvent wait_handle = new ManualResetEvent (false);
public object AsyncContext { get; private set; }
public BuildManager BuildManager { get; private set; }
}
public int SubmissionId { get; private set; }
public WaitHandle WaitHandle {
- get { throw new NotImplementedException (); }
+ get {
+ if (!is_started)
+ throw new InvalidOperationException ("Build has not started yet");
+ return wait_handle;
+ }
}
internal void Cancel ()
public BuildResult Execute ()
{
- throw new NotImplementedException ();
+ var result = new BuildResult ();
+ result.SubmissionId = this.SubmissionId;
+
+ // null targets -> success. empty targets -> success(!)
+ if (request.TargetNames == null)
+ result.OverallResult = BuildResultCode.Success;
+ else {
+ foreach (var targetName in request.TargetNames.Where (t => t != null)) {
+ ProjectTargetInstance target;
+ // null key is allowed and regarded as blind success(!)
+ if (!request.ProjectInstance.Targets.TryGetValue (targetName, out target))
+ result.AddResultsForTarget (targetName, new TargetResult (new ITaskItem [0], TargetResultCode.Failure));
+ else
+ throw new NotImplementedException ();
+ }
+
+ result.OverallResult = result.ResultsByTarget.Select (p => p.Value).Any (r => r.ResultCode == TargetResultCode.Failure) ? BuildResultCode.Failure : BuildResultCode.Success;
+ }
+
+ BuildResult = result;
+ wait_handle.Set ();
+ if (callback != null)
+ callback (this);
+ return BuildResult;
}
public void ExecuteAsync (BuildSubmissionCompleteCallback callback, object context)