summaryrefslogtreecommitdiff
path: root/mcs/class/Microsoft.Build/Microsoft.Build.Execution
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/Microsoft.Build/Microsoft.Build.Execution')
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildManager.cs176
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildParameters.cs239
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildRequestData.cs92
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildResult.cs126
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmission.cs96
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmissionCompleteCallback.cs5
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/HostServices.cs109
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/NodeEngineShutdownReason.cs47
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/OutOfProcNode.cs48
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs308
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemDefinitionInstance.cs30
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskInstance.cs82
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskItemInstance.cs95
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskMetadataInstance.cs58
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemInstance.cs324
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectMetadataInstance.cs30
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectOnErrorInstance.cs82
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskInstance.cs82
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskPropertyInstance.cs61
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyInstance.cs39
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstance.cs85
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstanceChild.cs52
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstance.cs108
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstanceChild.cs16
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputItemInstance.cs42
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputPropertyInstance.cs43
-rw-r--r--mcs/class/Microsoft.Build/Microsoft.Build.Execution/TargetResult.cs44
27 files changed, 1990 insertions, 529 deletions
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildManager.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildManager.cs
index 3b4384b2f6..0c179afa48 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildManager.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildManager.cs
@@ -2,8 +2,9 @@
//
// 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
@@ -26,66 +27,143 @@
//
using Microsoft.Build.Evaluation;
-
using System;
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.Build.Internal;
+using System.Linq;
namespace Microsoft.Build.Execution
{
- public class BuildManager
- {
- public BuildManager ()
- {
- throw new NotImplementedException ();
- }
+ public class BuildManager
+ {
+ static BuildManager default_manager = new BuildManager ();
- public BuildManager (string hostName)
- {
- throw new NotImplementedException ();
- }
+ public static BuildManager DefaultBuildManager {
+ get { return default_manager; }
+ }
+
+ public BuildManager ()
+ {
+ }
- public void BeginBuild (BuildParameters parameters)
- {
- throw new NotImplementedException ();
- }
+ public BuildManager (string hostName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Dispose ()
+ {
+ WaitHandle.WaitAll (submissions.Select (s => s.WaitHandle).ToArray ());
+ BuildNodeManager.Stop ();
+ }
- public BuildResult Build (BuildParameters parameters, BuildRequestData requestData)
- {
- throw new NotImplementedException ();
- }
+ ~BuildManager ()
+ {
+ // maybe processes created by out-of-process nodes should be signaled.
+ BuildNodeManager.Stop ();
+ }
- public BuildResult BuildRequest (BuildRequestData requestData)
- {
- throw new NotImplementedException ();
- }
+ readonly List<BuildSubmission> submissions = new List<BuildSubmission> ();
+
+ BuildParameters ongoing_build_parameters;
+
+ internal BuildParameters OngoingBuildParameters {
+ get { return ongoing_build_parameters; }
+ }
- public void CancelAllSubmissions ()
- {
- throw new NotImplementedException ();
- }
+ public void BeginBuild (BuildParameters parameters)
+ {
+ if (ongoing_build_parameters != null)
+ throw new InvalidOperationException ("There is already ongoing build");
+ ongoing_build_parameters = parameters.Clone ();
+ }
- public void EndBuild ()
- {
- throw new NotImplementedException ();
- }
+ public BuildResult Build (BuildParameters parameters, BuildRequestData requestData)
+ {
+ BeginBuild (parameters);
+ var ret = BuildRequest (requestData);
+ EndBuild ();
+ return ret;
+ }
- public ProjectInstance GetProjectInstanceForBuild (Project project)
- {
- throw new NotImplementedException ();
- }
+ public BuildResult BuildRequest (BuildRequestData requestData)
+ {
+ var sub = PendBuildRequest (requestData);
+ sub.Execute ();
+ return sub.BuildResult;
+ }
+
+ public void CancelAllSubmissions ()
+ {
+ foreach (var sub in submissions) {
+ try {
+ if (!sub.IsCompleted)
+ sub.Cancel ();
+ } catch (InvalidOperationException) {
+ // some submissions could be already done during this iteration. Ignore that.
+ }
+ }
+ submissions.Clear ();
+ }
- public BuildSubmission PendBuildRequest (BuildRequestData requestData)
- {
- throw new NotImplementedException ();
- }
+ public void EndBuild ()
+ {
+ if (ongoing_build_parameters == null)
+ throw new InvalidOperationException ("Build has not started");
+ if (submissions.Count > 0)
+ WaitHandle.WaitAll (submissions.Select (s => s.WaitHandle).ToArray ());
+ BuildNodeManager.Stop ();
+ ongoing_build_parameters = null;
+ }
+
+ Dictionary<Project,ProjectInstance> instances = new Dictionary<Project, ProjectInstance> ();
- public void ResetCaches ()
- {
- throw new NotImplementedException ();
- }
+ public ProjectInstance GetProjectInstanceForBuild (Project project)
+ {
+ if (project == null)
+ throw new ArgumentNullException ("project");
+ if (project.FullPath == null)
+ throw new ArgumentNullException ("project", "FullPath parameter in the project cannot be null.");
+ if (project.FullPath == string.Empty)
+ throw new ArgumentException ("FullPath parameter in the project cannot be empty.", "project");
+ // other than that, any invalid path character is accepted...
+
+ return GetProjectInstanceForBuildInternal (project);
+ }
+
+ internal ProjectInstance GetProjectInstanceForBuildInternal (Project project)
+ {
+ if (!instances.ContainsKey (project))
+ instances [project] = project.CreateProjectInstance ();
+ return instances [project];
+ }
- public static BuildManager DefaultBuildManager {
- get { throw new NotImplementedException (); }
- }
- }
-}
+ public BuildSubmission PendBuildRequest (BuildRequestData requestData)
+ {
+ if (ongoing_build_parameters == null)
+ throw new InvalidOperationException ("This method cannot be called before calling BeginBuild method.");
+ var sub = new BuildSubmission (this, requestData);
+ submissions.Add (sub);
+ return sub;
+ }
+ public void ResetCaches ()
+ {
+ if (OngoingBuildParameters != null)
+ throw new InvalidOperationException ("Cannot reset caches while builds are in progress.");
+
+ BuildNodeManager.ResetCaches ();
+ }
+
+ BuildNodeManager build_node_manager;
+
+ internal BuildNodeManager BuildNodeManager {
+ get {
+ if (build_node_manager == null)
+ build_node_manager = new BuildNodeManager (this);
+ return build_node_manager;
+ }
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildParameters.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildParameters.cs
index 26944910f9..61f8393cda 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildParameters.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildParameters.cs
@@ -2,8 +2,9 @@
//
// 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
@@ -28,132 +29,128 @@
using Microsoft.Build.Evaluation;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging;
-
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.Linq;
using System.Threading;
+using System.Collections;
namespace Microsoft.Build.Execution
{
- public class BuildParameters
- {
- public BuildParameters ()
- {
- throw new NotImplementedException ();
- }
-
- public BuildParameters (ProjectCollection projectCollection)
- {
- throw new NotImplementedException ();
- }
-
- public BuildParameters Clone ()
- {
- throw new NotImplementedException ();
- }
-
- public Toolset GetToolset (string toolsVersion)
- {
- throw new NotImplementedException ();
- }
-
- public ThreadPriority BuildThreadPriority {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public CultureInfo Culture {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public string DefaultToolsVersion {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool DetailedSummary {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool EnableNodeReuse {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public IDictionary<string, string> EnvironmentProperties {
- get { throw new NotImplementedException (); }
- }
-
- public IEnumerable<ForwardingLoggerRecord> ForwardingLoggers {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public IDictionary<string, string> GlobalProperties {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public HostServices HostServices {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool LegacyThreadingSemantics { get; set; }
-
- public IEnumerable<ILogger> Loggers {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public int MaxNodeCount {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public int MemoryUseLimit {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public string NodeExeLocation {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool OnlyLogCriticalEvents {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool ResetCaches { get; set; }
-
- public bool SaveOperatingEnvironment {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public ToolsetDefinitionLocations ToolsetDefinitionLocations {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public ICollection<Toolset> Toolsets {
- get { throw new NotImplementedException (); }
- }
-
- public CultureInfo UICulture {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public bool UseSynchronousLogging {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
- }
+ public class BuildParameters
+ {
+ public BuildParameters ()
+ : this (new ProjectCollection ())
+ {
+ }
+
+ public BuildParameters (ProjectCollection projectCollection)
+ {
+ if (projectCollection == null)
+ throw new ArgumentNullException ("projectCollection");
+ projects = projectCollection;
+
+ EnableNodeReuse = true;
+ Culture = CultureInfo.CurrentCulture;
+ UICulture = CultureInfo.CurrentUICulture;
+ MaxNodeCount = projectCollection.MaxNodeCount;
+
+ // these properties are copied, while some members (such as Loggers) are not.
+ this.DefaultToolsVersion = projectCollection.DefaultToolsVersion;
+ this.ToolsetDefinitionLocations = projectCollection.ToolsetLocations;
+ this.GlobalProperties = projectCollection.GlobalProperties;
+ environment_properties = new Dictionary<string,string> ();
+ foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
+ environment_properties [(string) p.Key] = (string) p.Value;
+ }
+
+ readonly ProjectCollection projects;
+ Dictionary<string,string> environment_properties;
+
+ internal ProjectCollection ProjectCollection {
+ get { return projects; }
+ }
+
+ public BuildParameters Clone ()
+ {
+ var ret = (BuildParameters) MemberwiseClone ();
+ ret.ForwardingLoggers = ForwardingLoggers == null ? null : ForwardingLoggers.ToArray ();
+ ret.GlobalProperties = GlobalProperties == null ? null : GlobalProperties.ToDictionary (p => p.Key, p => p.Value);
+ ret.Loggers = Loggers == null ? null : new List<ILogger> (Loggers);
+ ret.environment_properties = new Dictionary<string, string> (environment_properties);
+ return ret;
+ }
+
+ public Toolset GetToolset (string toolsVersion)
+ {
+ // can return null.
+ return projects.Toolsets.FirstOrDefault (t => t.ToolsVersion == toolsVersion);
+ }
+
+ [MonoTODO]
+ public ThreadPriority BuildThreadPriority { get; set; }
+
+ [MonoTODO]
+ public CultureInfo Culture { get; set; }
+
+ public string DefaultToolsVersion { get; set; }
+
+ [MonoTODO]
+ public bool DetailedSummary { get; set; }
+
+ public bool EnableNodeReuse { get; set; }
+
+ [MonoTODO]
+ public IDictionary<string, string> EnvironmentProperties {
+ get { return environment_properties; }
+ }
+
+ [MonoTODO]
+ public IEnumerable<ForwardingLoggerRecord> ForwardingLoggers { get; set; }
+
+ [MonoTODO]
+ public IDictionary<string, string> GlobalProperties { get; set; }
+
+ public HostServices HostServices { get; set; }
+
+ [MonoTODO]
+ public bool LegacyThreadingSemantics { get; set; }
+
+ [MonoTODO]
+ public IEnumerable<ILogger> Loggers { get; set; }
+
+ [MonoTODO]
+ public int MaxNodeCount { get; set; }
+
+ [MonoTODO]
+ public int MemoryUseLimit { get; set; }
+
+ [MonoTODO]
+ public string NodeExeLocation { get; set; }
+
+ [MonoTODO]
+ public bool OnlyLogCriticalEvents { get; set; }
+
+ [MonoTODO]
+ public bool ResetCaches { get; set; }
+
+ [MonoTODO]
+ public bool SaveOperatingEnvironment { get; set; }
+
+ [MonoTODO]
+ public ToolsetDefinitionLocations ToolsetDefinitionLocations { get; set; }
+
+ [MonoTODO]
+ public ICollection<Toolset> Toolsets {
+ get { return projects.Toolsets; }
+ }
+
+ [MonoTODO]
+ public CultureInfo UICulture { get; set; }
+
+ [MonoTODO]
+ public bool UseSynchronousLogging { get; set; }
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildRequestData.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildRequestData.cs
index 2380077e51..bd5edffd7c 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildRequestData.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildRequestData.cs
@@ -3,8 +3,9 @@
//
// 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
@@ -27,50 +28,69 @@
//
using System;
+using System.Linq;
using System.Collections.Generic;
namespace Microsoft.Build.Execution
{
- public class BuildRequestData
- {
- public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild)
- : this (projectInstance, targetsToBuild, null, BuildRequestDataFlags.None)
- {
- }
+ public class BuildRequestData
+ {
+ public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild)
+ : this (projectInstance, targetsToBuild, null, BuildRequestDataFlags.None)
+ {
+ }
- public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices)
- : this (projectInstance, targetsToBuild, hostServices, BuildRequestDataFlags.None)
- {
- }
+ public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices)
+ : this (projectInstance, targetsToBuild, hostServices, BuildRequestDataFlags.None)
+ {
+ }
- public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices,
- BuildRequestDataFlags flags)
- {
- throw new NotImplementedException ();
- }
+ public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices,
+ BuildRequestDataFlags flags)
+ {
+ ProjectInstance = projectInstance;
+ TargetNames = targetsToBuild;
+ HostServices = hostServices;
+ Flags = flags;
+ }
- public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties,
- string toolsVersion, string[] targetsToBuild, HostServices hostServices)
- : this (projectFullPath, globalProperties, toolsVersion, targetsToBuild, hostServices, BuildRequestDataFlags.None)
- {
- }
+ public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties,
+ string toolsVersion, string[] targetsToBuild, HostServices hostServices)
+ : this (projectFullPath, globalProperties, toolsVersion, targetsToBuild, hostServices, BuildRequestDataFlags.None)
+ {
+ }
- public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties,
- string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags)
- {
- throw new NotImplementedException ();
- }
+ public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties,
+ string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags)
+ : this (new ProjectInstance (projectFullPath, globalProperties, toolsVersion), targetsToBuild, hostServices, flags)
+ {
+ ExplicitlySpecifiedToolsVersion = toolsVersion;
+ }
- public string ExplicitlySpecifiedToolsVersion { get; private set; }
- public BuildRequestDataFlags Flags { get; private set; }
- public HostServices HostServices { get; private set; }
- public string ProjectFullPath { get; private set; }
- public ProjectInstance ProjectInstance { get; private set; }
- public ICollection<string> TargetNames { get; private set; }
+ public string ExplicitlySpecifiedToolsVersion { get; private set; }
- ICollection<ProjectPropertyInstance> GlobalProperties {
- get { throw new NotImplementedException (); }
- }
- }
+ [MonoTODO ("unused")]
+ public BuildRequestDataFlags Flags { get; private set; }
+
+ [MonoTODO ("unused")]
+ public HostServices HostServices { get; private set; }
+
+ public string ProjectFullPath {
+ get { return ProjectInstance.FullPath; }
+ }
+
+ [MonoTODO ("unused")]
+ public ProjectInstance ProjectInstance { get; private set; }
+
+ [MonoTODO]
+ public IEnumerable<string> PropertiesToTransfer { get; private set; }
+
+ [MonoTODO]
+ public ICollection<string> TargetNames { get; private set; }
+
+ ICollection<ProjectPropertyInstance> GlobalProperties {
+ get { return ProjectInstance.Properties.Where (p => ProjectInstance.GlobalProperties.Any (i => i.Key == p.Name)).ToArray (); } // we can use == as it should be identical match there.
+ }
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildResult.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildResult.cs
index 7286a247d2..479b137a4f 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildResult.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildResult.cs
@@ -27,67 +27,75 @@
using System;
using System.Collections.Generic;
+using System.Linq;
namespace Microsoft.Build.Execution
{
- public class BuildResult
- {
- public void AddResultsForTarget (string target, TargetResult result)
- {
- throw new NotImplementedException ();
- }
-
- public bool HasResultsForTarget (string target)
- {
- throw new NotImplementedException ();
- }
-
- public void MergeResults (BuildResult results)
- {
- throw new NotImplementedException ();
- }
-
- public bool CircularDependency {
- get { throw new NotImplementedException (); }
- }
-
- public int ConfigurationId {
- get { throw new NotImplementedException (); }
- }
-
- public Exception Exception {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public int GlobalRequestId {
- get { throw new NotImplementedException (); }
- }
-
- public ITargetResult this [string target] {
- get { throw new NotImplementedException (); }
- }
-
- public int NodeRequestId {
- get { throw new NotImplementedException (); }
- }
-
- public BuildResultCode OverallResult {
- get { throw new NotImplementedException (); }
- }
-
- public int ParentGlobalRequestId {
- get { throw new NotImplementedException (); }
- }
-
- public IDictionary<string, TargetResult> ResultsByTarget {
- get { throw new NotImplementedException (); }
- }
-
- public int SubmissionId {
- get { throw new NotImplementedException (); }
- }
-
- }
+ public class BuildResult
+ {
+ public BuildResult ()
+ {
+ ResultsByTarget = new Dictionary<string, TargetResult> ();
+ }
+
+ public void AddResultsForTarget (string target, TargetResult result)
+ {
+ ResultsByTarget.Add (target, result);
+ }
+
+ public bool HasResultsForTarget (string target)
+ {
+ return ResultsByTarget.ContainsKey (target);
+ }
+
+ public void MergeResults (BuildResult results)
+ {
+ 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; internal set; }
+
+ public int ConfigurationId { get; internal set; }
+
+ public Exception Exception { get; set; }
+
+ public int GlobalRequestId { get; internal set; }
+
+ public ITargetResult this [string target] {
+ get { return ResultsByTarget [target]; }
+ }
+
+ public int NodeRequestId { get; internal set; }
+
+ BuildResultCode? overall_result;
+ public BuildResultCode OverallResult {
+ 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; internal set; }
+
+ public IDictionary<string, TargetResult> ResultsByTarget { get; private set; }
+
+ public int SubmissionId { get; internal set; }
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmission.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmission.cs
index 3a8a612b93..91a9823ce8 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmission.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmission.cs
@@ -2,8 +2,9 @@
//
// 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
@@ -26,15 +27,94 @@
//
using System;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Linq;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Internal;
+using System.Collections.Generic;
namespace Microsoft.Build.Execution
{
- public class BuildSubmission
- {
- private BuildSubmission ()
- {
- throw new NotImplementedException ();
- }
- }
+ public class BuildSubmission
+ {
+ static Random rnd = new Random ();
+
+ internal BuildSubmission (BuildManager build, BuildRequestData requestData)
+ {
+ BuildManager = build;
+ this.request = requestData;
+ SubmissionId = rnd.Next ();
+ }
+
+ BuildRequestData request;
+ BuildSubmissionCompleteCallback callback;
+ bool is_started, is_completed, is_canceled;
+ ManualResetEvent wait_handle = new ManualResetEvent (true);
+
+ public object AsyncContext { get; private set; }
+ public BuildManager BuildManager { get; private set; }
+ public BuildResult BuildResult { get; set; }
+ public bool IsCompleted {
+ get { return is_completed; }
+ }
+ public int SubmissionId { get; private set; }
+ public WaitHandle WaitHandle {
+ get { return wait_handle; }
+ }
+
+ internal BuildRequestData BuildRequest {
+ get { return this.request; }
+ }
+
+ internal void Cancel ()
+ {
+ if (is_canceled)
+ throw new InvalidOperationException ("Build has already canceled");
+ is_canceled = true;
+ }
+
+ public BuildResult Execute ()
+ {
+ ExecuteAsync (null, null);
+ WaitHandle.WaitOne ();
+ return BuildResult;
+ }
+
+ internal BuildResult InternalExecute ()
+ {
+ BuildResult = new BuildResult () { SubmissionId = SubmissionId };
+ try {
+ var engine = new BuildEngine4 (this);
+ string toolsVersion = request.ExplicitlySpecifiedToolsVersion ?? request.ProjectInstance.ToolsVersion ?? BuildManager.OngoingBuildParameters.DefaultToolsVersion;
+ var outputs = new Dictionary<string,string> ();
+ engine.BuildProject (() => is_canceled, BuildResult, request.ProjectInstance, request.TargetNames, BuildManager.OngoingBuildParameters.GlobalProperties, outputs, toolsVersion);
+ } catch (Exception ex) {
+ BuildResult.Exception = ex;
+ BuildResult.OverallResult = BuildResultCode.Failure;
+ }
+ is_completed = true;
+ if (callback != null)
+ callback (this);
+ wait_handle.Set ();
+ return BuildResult;
+ }
+
+ public void ExecuteAsync (BuildSubmissionCompleteCallback callback, object context)
+ {
+ if (is_completed)
+ throw new InvalidOperationException ("Build has already completed");
+ if (is_canceled)
+ throw new InvalidOperationException ("Build has already canceled");
+ if (is_started)
+ throw new InvalidOperationException ("Build has already started");
+ is_started = true;
+ this.AsyncContext = context;
+ this.callback = callback;
+ wait_handle.Reset ();
+
+ BuildManager.BuildNodeManager.Enqueue (this);
+ }
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmissionCompleteCallback.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmissionCompleteCallback.cs
new file mode 100644
index 0000000000..fba101a2fd
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/BuildSubmissionCompleteCallback.cs
@@ -0,0 +1,5 @@
+namespace Microsoft.Build.Execution
+{
+ public delegate void BuildSubmissionCompleteCallback (BuildSubmission submission);
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/HostServices.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/HostServices.cs
index 2389bdf330..e68755affe 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/HostServices.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/HostServices.cs
@@ -26,42 +26,95 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using Microsoft.Build.Framework;
using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Framework;
namespace Microsoft.Build.Execution
{
- public class HostServices
- {
- public ITaskHost GetHostObject (string projectFile, string targetName, string taskName)
- {
- throw new NotImplementedException ();
- }
+ public class HostServices
+ {
+ class HostObjectRegistration
+ {
+ public string ProjectFile { get; set; }
+ public string TargetName { get; set; }
+ public string TaskName { get; set; }
+ public ITaskHost HostObject { get; set; }
+ }
+
+ readonly List<HostObjectRegistration> hosts = new List<HostObjectRegistration> ();
+ readonly Dictionary<string,NodeAffinity> node_affinities = new Dictionary<string, NodeAffinity> ();
+
+ HostObjectRegistration GetHostRegistration (string projectFile, string targetName, string taskName)
+ {
+ if (projectFile == null)
+ throw new ArgumentNullException ("projectFile");
+ if (targetName == null)
+ throw new ArgumentNullException ("targetName");
+ if (taskName == null)
+ throw new ArgumentNullException ("taskName");
+ return hosts.FirstOrDefault (h =>
+ string.Equals (projectFile, h.ProjectFile, StringComparison.OrdinalIgnoreCase) &&
+ string.Equals (targetName, h.TargetName, StringComparison.OrdinalIgnoreCase) &&
+ string.Equals (taskName, h.TaskName, StringComparison.OrdinalIgnoreCase));
+ }
+
+ public ITaskHost GetHostObject (string projectFile, string targetName, string taskName)
+ {
+ var reg = GetHostRegistration (projectFile, targetName, taskName);
+ return reg != null ? reg.HostObject : null;
+ }
- public NodeAffinity GetNodeAffinity (string projectFile)
- {
- throw new NotImplementedException ();
- }
+ public NodeAffinity GetNodeAffinity (string projectFile)
+ {
+ if (projectFile == null)
+ throw new ArgumentNullException ("projectFile");
+ NodeAffinity na;
+ return node_affinities.TryGetValue (projectFile, out na) ? na : NodeAffinity.Any;
+ }
+
+ IEnumerable<HostObjectRegistration> GetRegistrationsByProject (string project)
+ {
+ return hosts.Where (h => string.Equals (project, h.ProjectFile, StringComparison.OrdinalIgnoreCase));
+ }
- public void OnRenameProject (string oldFullPath, string newFullPath)
- {
- throw new NotImplementedException ();
- }
+ public void OnRenameProject (string oldFullPath, string newFullPath)
+ {
+ if (oldFullPath == null)
+ throw new ArgumentNullException ("oldFullPath");
+ if (newFullPath == null)
+ throw new ArgumentNullException ("newFullPath");
+ foreach (var reg in GetRegistrationsByProject (oldFullPath))
+ reg.ProjectFile = newFullPath;
+ }
- public void RegisterHostObject (string projectFile, string targetName, string taskName, ITaskHost hostObject)
- {
- throw new NotImplementedException ();
- }
+ public void RegisterHostObject (string projectFile, string targetName, string taskName, ITaskHost hostObject)
+ {
+ if (hostObject == null)
+ throw new ArgumentNullException ("hostObject");
+ var reg = GetHostRegistration (projectFile, targetName, taskName);
+ if (reg != null)
+ reg.HostObject = hostObject;
+ else
+ hosts.Add (new HostObjectRegistration () { ProjectFile = projectFile, TargetName = targetName, TaskName = taskName, HostObject = hostObject });
+ }
- public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity)
- {
- throw new NotImplementedException ();
- }
+ public void SetNodeAffinity (string projectFile, NodeAffinity nodeAffinity)
+ {
+ if (projectFile == null)
+ throw new ArgumentNullException ("projectFile");
+ node_affinities [projectFile] = nodeAffinity;
+ }
- public void UnregisterProject (string projectFullPath)
- {
- throw new NotImplementedException ();
- }
- }
+ public void UnregisterProject (string projectFullPath)
+ {
+ if (projectFullPath == null)
+ throw new ArgumentNullException ("projectFullPath");
+ var removed = GetRegistrationsByProject (projectFullPath).ToArray ();
+ foreach (var r in removed)
+ hosts.Remove (r);
+ }
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/NodeEngineShutdownReason.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/NodeEngineShutdownReason.cs
new file mode 100644
index 0000000000..b88423f2a8
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/NodeEngineShutdownReason.cs
@@ -0,0 +1,47 @@
+//
+// NodeEngineShutdownReason.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// Copyright (C) 2013 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Microsoft.Build.BuildEngine;
+using Microsoft.Build.Execution;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Evaluation;
+using System.Linq;
+using System.IO;
+
+namespace Microsoft.Build.Internal
+{
+ public enum NodeEngineShutdownReason
+ {
+ BuildComplete,
+ BuildCompleteReuse,
+ ConnectionFailed,
+ Error,
+ }
+}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/OutOfProcNode.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/OutOfProcNode.cs
new file mode 100644
index 0000000000..7237052d19
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/OutOfProcNode.cs
@@ -0,0 +1,48 @@
+//
+// OutOfProcNode.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// Copyright (C) 2013 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Microsoft.Build.BuildEngine;
+using Microsoft.Build.Execution;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Evaluation;
+using System.Linq;
+using System.IO;
+
+namespace Microsoft.Build.Internal
+{
+ // from MSDN: this class has deprecated and there is no alternative.
+ public class OutOfProcNode
+ {
+ public NodeEngineShutdownReason Run (out Exception shutdownException)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs
index 4661496222..91ce68a040 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectInstance.cs
@@ -3,8 +3,9 @@
//
// 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
@@ -27,13 +28,34 @@
//
using System;
+using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Framework;
+using Microsoft.Build.Internal.Expressions;
using Microsoft.Build.Logging;
+//
+// It is not always consistent to reuse Project and its evaluation stuff mostly because
+// both BuildParameters.ctor() and Project.ctor() takes arbitrary ProjectCollection, which are not very likely eqivalent
+// (as BuildParameters.ctor(), unlike Project.ctor(...), is known to create a new ProjectCollection instance).
+//
+// However, that inconsistency could happen even if you only use ProjectInstance and BuildParameters.
+// They both have constructors that take ProjectCollection and there is no guarantee that the arguments are the same.
+// BuildManager.Build() does not fail because of inconsistent ProjectCollection instance on .NET.
+//
+// Anyhow, I'm not going to instantiate Project within ProjectInstance code for another reason:
+// ProjectCollection.GetLoadedProject() does not return any Project instnace for corresponding ProjectInstance
+// (or I should say, ProjectRootElement for both).
+using Microsoft.Build.Internal;
+using System.Xml;
+using Microsoft.Build.Exceptions;
+using System.IO;
+
+
namespace Microsoft.Build.Execution
{
public class ProjectInstance
@@ -59,35 +81,210 @@ namespace Microsoft.Build.Execution
public ProjectInstance (ProjectRootElement xml, IDictionary<string, string> globalProperties,
string toolsVersion, ProjectCollection projectCollection)
{
- InitializeProperties ();
-
- throw new NotImplementedException ();
+ projects = projectCollection;
+ global_properties = globalProperties ?? new Dictionary<string, string> ();
+ tools_version = !string.IsNullOrEmpty (toolsVersion) ? toolsVersion :
+ !string.IsNullOrEmpty (xml.ToolsVersion) ? xml.ToolsVersion :
+ projects.DefaultToolsVersion;
+ InitializeProperties (xml, null);
}
public ProjectInstance (string projectFile, IDictionary<string, string> globalProperties,
string toolsVersion, ProjectCollection projectCollection)
+ : this (ProjectRootElement.Create (projectFile), globalProperties, toolsVersion, projectCollection)
+ {
+ }
+
+ ProjectCollection projects;
+ IDictionary<string, string> global_properties;
+
+ string full_path, directory;
+ #if NET_4_5
+ ElementLocation location;
+ #endif
+
+ Dictionary<string, ProjectItemDefinitionInstance> item_definitions;
+ List<ResolvedImport> raw_imports; // maybe we don't need this...
+ List<ProjectItemInstance> all_evaluated_items;
+ List<ProjectItemInstance> raw_items;
+ List<ProjectPropertyInstance> properties;
+ Dictionary<string, ProjectTargetInstance> targets;
+ string tools_version;
+
+ List<string> GetDefaultTargets (ProjectRootElement xml)
{
- InitializeProperties ();
+ var ret = xml.DefaultTargets.Split (item_target_sep, StringSplitOptions.RemoveEmptyEntries).Select (s => s.Trim ()).ToList ();
+ if (ret.Count == 0 && xml.Targets.Any ())
+ ret.Add (xml.Targets.First ().Name);
+ return ret;
+ }
+
+ void InitializeProperties (ProjectRootElement xml, ProjectInstance parent)
+ {
+ #if NET_4_5
+ location = xml.Location;
+ #endif
+ full_path = xml.FullPath;
+ directory = string.IsNullOrWhiteSpace (xml.DirectoryPath) ? System.IO.Directory.GetCurrentDirectory () : xml.DirectoryPath;
+ DefaultTargets = GetDefaultTargets (xml);
+ InitialTargets = xml.InitialTargets.Split (item_target_sep, StringSplitOptions.RemoveEmptyEntries).Select (s => s.Trim ()).ToList ();
+
+ raw_imports = new List<ResolvedImport> ();
+ item_definitions = new Dictionary<string, ProjectItemDefinitionInstance> ();
+ targets = new Dictionary<string, ProjectTargetInstance> ();
+ raw_items = new List<ProjectItemInstance> ();
- throw new NotImplementedException ();
+ // FIXME: this is likely hack. Test ImportedProject.Properties to see what exactly should happen.
+ if (parent != null) {
+ properties = parent.properties;
+ } else {
+ properties = new List<ProjectPropertyInstance> ();
+
+ foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
+ // FIXME: this is kind of workaround for unavoidable issue that PLATFORM=* is actually given
+ // on some platforms and that prevents setting default "PLATFORM=AnyCPU" property.
+ if (!string.Equals ("PLATFORM", (string) p.Key, StringComparison.OrdinalIgnoreCase))
+ this.properties.Add (new ProjectPropertyInstance ((string) p.Key, false, (string) p.Value));
+ foreach (var p in global_properties)
+ this.properties.Add (new ProjectPropertyInstance (p.Key, false, p.Value));
+ var tools = projects.GetToolset (tools_version) ?? projects.GetToolset (projects.DefaultToolsVersion);
+ foreach (var p in projects.GetReservedProperties (tools, this, xml))
+ this.properties.Add (p);
+ foreach (var p in ProjectCollection.GetWellKnownProperties (this))
+ this.properties.Add (p);
+ }
+
+ ProcessXml (parent, xml);
}
- void InitializeProperties ()
+ static readonly char [] item_target_sep = {';'};
+
+ void ProcessXml (ProjectInstance parent, ProjectRootElement xml)
{
- DefaultTargets = new List<string> ();
- InitialTargets = new List<string> ();
+ TaskDatabase = new BuildTaskDatabase (this, xml);
+
+ // this needs to be initialized here (regardless of that items won't be evaluated at property evaluation;
+ // Conditions could incorrectly reference items and lack of this list causes NRE.
+ all_evaluated_items = new List<ProjectItemInstance> ();
+
+ // property evaluation happens couple of times.
+ // At first step, all non-imported properties are evaluated TOO, WHILE those properties are being evaluated.
+ // This means, Include and IncludeGroup elements with Condition attribute MAY contain references to
+ // properties and they will be expanded.
+ var elements = EvaluatePropertiesAndImports (xml.Children).ToArray (); // ToArray(): to not lazily evaluate elements.
+
+ // next, evaluate items
+ EvaluateItems (xml, elements);
+
+ // finally, evaluate targets and tasks
+ EvaluateTasks (elements);
}
- Dictionary<string, string> global_properties = new Dictionary<string, string> ();
+ IEnumerable<ProjectElement> EvaluatePropertiesAndImports (IEnumerable<ProjectElement> elements)
+ {
+ // First step: evaluate Properties
+ foreach (var child in elements) {
+ yield return child;
+ var pge = child as ProjectPropertyGroupElement;
+ if (pge != null && EvaluateCondition (pge.Condition))
+ foreach (var p in pge.Properties)
+ // do not allow overwriting reserved or well-known properties by user
+ if (!this.properties.Any (_ => (_.IsImmutable) && _.Name.Equals (p.Name, StringComparison.InvariantCultureIgnoreCase)))
+ if (EvaluateCondition (p.Condition))
+ this.properties.Add (new ProjectPropertyInstance (p.Name, false, ExpandString (p.Value)));
+
+ var ige = child as ProjectImportGroupElement;
+ if (ige != null && EvaluateCondition (ige.Condition)) {
+ foreach (var incc in ige.Imports) {
+ foreach (var e in Import (incc))
+ yield return e;
+ }
+ }
+ var inc = child as ProjectImportElement;
+ if (inc != null && EvaluateCondition (inc.Condition))
+ foreach (var e in Import (inc))
+ yield return e;
+ }
+ }
+ internal IEnumerable<T> GetAllItems<T> (string include, string exclude, Func<string,T> creator, Func<string,ITaskItem> taskItemCreator, Func<string,bool> itemTypeCheck, Action<T,string> assignRecurse)
+ {
+ return ProjectCollection.GetAllItems<T> (ExpandString, include, exclude, creator, taskItemCreator, Directory, assignRecurse,
+ t => all_evaluated_items.Any (i => i.EvaluatedInclude == t.ItemSpec && itemTypeCheck (i.ItemType)));
+ }
+
+ void EvaluateItems (ProjectRootElement xml, IEnumerable<ProjectElement> elements)
+ {
+ foreach (var child in elements) {
+ var ige = child as ProjectItemGroupElement;
+ if (ige != null) {
+ foreach (var p in ige.Items) {
+ if (!EvaluateCondition (ige.Condition) || !EvaluateCondition (p.Condition))
+ continue;
+ Func<string,ProjectItemInstance> creator = s => new ProjectItemInstance (this, p.ItemType, p.Metadata.Select (m => new KeyValuePair<string,string> (m.Name, m.Value)).ToList (), s);
+ foreach (var item in GetAllItems (p.Include, p.Exclude, creator, s => new ProjectTaskItem (p, s), it => string.Equals (it, p.ItemType, StringComparison.OrdinalIgnoreCase), (t, s) => t.RecursiveDir = s)) {
+ raw_items.Add (item);
+ all_evaluated_items.Add (item);
+ }
+ }
+ }
+ var def = child as ProjectItemDefinitionGroupElement;
+ if (def != null) {
+ foreach (var p in def.ItemDefinitions) {
+ if (EvaluateCondition (p.Condition)) {
+ ProjectItemDefinitionInstance existing;
+ if (!item_definitions.TryGetValue (p.ItemType, out existing))
+ item_definitions.Add (p.ItemType, (existing = new ProjectItemDefinitionInstance (p)));
+ existing.AddItems (p);
+ }
+ }
+ }
+ }
+ all_evaluated_items.Sort ((p1, p2) => string.Compare (p1.ItemType, p2.ItemType, StringComparison.OrdinalIgnoreCase));
+ }
+
+ void EvaluateTasks (IEnumerable<ProjectElement> elements)
+ {
+ foreach (var child in elements) {
+ var te = child as ProjectTargetElement;
+ if (te != null)
+ this.targets.Add (te.Name, new ProjectTargetInstance (te));
+ }
+ }
+
+ IEnumerable<ProjectElement> Import (ProjectImportElement import)
+ {
+ string dir = projects.GetEvaluationTimeThisFileDirectory (() => FullPath);
+ string path = WindowsCompatibilityExtensions.NormalizeFilePath (ExpandString (import.Project));
+ path = Path.IsPathRooted (path) ? path : dir != null ? Path.Combine (dir, path) : Path.GetFullPath (path);
+ if (projects.OngoingImports.Contains (path))
+ throw new InvalidProjectFileException (import.Location, null, string.Format ("Circular imports was detected: {0} is already on \"importing\" stack", path));
+ projects.OngoingImports.Push (path);
+ try {
+ using (var reader = XmlReader.Create (path)) {
+ var root = ProjectRootElement.Create (reader, projects);
+ if (DefaultTargets.Count == 0)
+ DefaultTargets.AddRange (GetDefaultTargets (root));
+ raw_imports.Add (new ResolvedImport (import, root, true));
+ return this.EvaluatePropertiesAndImports (root.Children).ToArray ();
+ }
+ } finally {
+ projects.OngoingImports.Pop ();
+ }
+ }
+
+ internal IEnumerable<ProjectItemInstance> AllEvaluatedItems {
+ get { return all_evaluated_items; }
+ }
+
public List<string> DefaultTargets { get; private set; }
public string Directory {
- get { throw new NotImplementedException (); }
+ get { return directory; }
}
public string FullPath {
- get { throw new NotImplementedException (); }
+ get { return full_path; }
}
public IDictionary<string, string> GlobalProperties {
@@ -103,33 +300,33 @@ namespace Microsoft.Build.Execution
#endif
public IDictionary<string, ProjectItemDefinitionInstance> ItemDefinitions {
- get { throw new NotImplementedException (); }
+ get { return item_definitions; }
}
public ICollection<ProjectItemInstance> Items {
- get { throw new NotImplementedException (); }
+ get { return all_evaluated_items; }
}
public ICollection<string> ItemTypes {
- get { throw new NotImplementedException (); }
+ get { return all_evaluated_items.Select (i => i.ItemType).Distinct ().ToArray (); }
}
#if NET_4_5
public ElementLocation ProjectFileLocation {
- get { throw new NotImplementedException (); }
+ get { return location; }
}
#endif
public ICollection<ProjectPropertyInstance> Properties {
- get { throw new NotImplementedException (); }
+ get { return properties; }
}
public IDictionary<string, ProjectTargetInstance> Targets {
- get { throw new NotImplementedException (); }
+ get { return targets; }
}
public string ToolsVersion {
- get { throw new NotImplementedException (); }
+ get { return tools_version; }
}
public ProjectItemInstance AddItem (string itemType, string evaluatedInclude)
@@ -139,7 +336,10 @@ namespace Microsoft.Build.Execution
public ProjectItemInstance AddItem (string itemType, string evaluatedInclude, IEnumerable<KeyValuePair<string, string>> metadata)
{
- throw new NotImplementedException ();
+ var item = new ProjectItemInstance (this, itemType, metadata, evaluatedInclude);
+ raw_items.Add (item);
+ all_evaluated_items.Add (item);
+ return item;
}
public bool Build ()
@@ -154,7 +354,7 @@ namespace Microsoft.Build.Execution
public bool Build (IEnumerable<ILogger> loggers, IEnumerable<ForwardingLoggerRecord> remoteLoggers)
{
- return Build ((string []) null, loggers, remoteLoggers);
+ return Build (DefaultTargets.ToArray (), loggers, remoteLoggers);
}
public bool Build (string target, IEnumerable<ILogger> loggers)
@@ -180,12 +380,20 @@ namespace Microsoft.Build.Execution
public bool Build (string[] targets, IEnumerable<ILogger> loggers, out IDictionary<string, TargetResult> targetOutputs)
{
- return Build (targets, loggers, new ForwardingLoggerRecord [0], out targetOutputs);
+ return Build (targets, loggers, new ForwardingLoggerRecord [0], out targetOutputs);
}
public bool Build (string[] targets, IEnumerable<ILogger> loggers, IEnumerable<ForwardingLoggerRecord> remoteLoggers, out IDictionary<string, TargetResult> targetOutputs)
{
- throw new NotImplementedException ();
+ var manager = new BuildManager ();
+ var parameters = new BuildParameters (projects) {
+ ForwardingLoggers = remoteLoggers,
+ Loggers = loggers,
+ };
+ var requestData = new BuildRequestData (this, targets);
+ var result = manager.Build (parameters, requestData);
+ targetOutputs = result.ResultsByTarget;
+ return result.OverallResult == BuildResultCode.Success;
}
public ProjectInstance DeepCopy ()
@@ -200,17 +408,22 @@ namespace Microsoft.Build.Execution
public bool EvaluateCondition (string condition)
{
- throw new NotImplementedException ();
+ return string.IsNullOrWhiteSpace (condition) || new ExpressionEvaluator (this, null).EvaluateAsBoolean (condition);
}
public string ExpandString (string unexpandedValue)
{
- throw new NotImplementedException ();
+ return ExpandString (unexpandedValue, null);
+ }
+
+ string ExpandString (string unexpandedValue, string replacementForMissingStuff)
+ {
+ return new ExpressionEvaluator (this, replacementForMissingStuff).Evaluate (unexpandedValue);
}
public ICollection<ProjectItemInstance> GetItems (string itemType)
{
- throw new NotImplementedException ();
+ return new CollectionFromEnumerable<ProjectItemInstance> (Items.Where (p => p.ItemType.Equals (itemType, StringComparison.OrdinalIgnoreCase)));
}
public IEnumerable<ProjectItemInstance> GetItemsByItemTypeAndEvaluatedInclude (string itemType, string evaluatedInclude)
@@ -220,27 +433,36 @@ namespace Microsoft.Build.Execution
public ProjectPropertyInstance GetProperty (string name)
{
- throw new NotImplementedException ();
+ return properties.FirstOrDefault (p => p.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
}
public string GetPropertyValue (string name)
{
- throw new NotImplementedException ();
+ var prop = GetProperty (name);
+ return prop != null ? prop.EvaluatedValue : string.Empty;
}
public bool RemoveItem (ProjectItemInstance item)
{
- throw new NotImplementedException ();
+ // yeah, this raw_items should vanish...
+ raw_items.Remove (item);
+ return all_evaluated_items.Remove (item);
}
public bool RemoveProperty (string name)
{
- throw new NotImplementedException ();
+ var removed = properties.FirstOrDefault (p => p.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
+ if (removed == null)
+ return false;
+ properties.Remove (removed);
+ return true;
}
public ProjectPropertyInstance SetProperty (string name, string evaluatedValue)
{
- throw new NotImplementedException ();
+ var p = new ProjectPropertyInstance (name, false, evaluatedValue);
+ properties.Add (p);
+ return p;
}
public ProjectRootElement ToProjectRootElement ()
@@ -259,32 +481,46 @@ namespace Microsoft.Build.Execution
public static string GetEvaluatedItemIncludeEscaped (ProjectItemDefinitionInstance item)
{
+ // ?? ItemDefinition does not have Include attribute. What's the point here?
throw new NotImplementedException ();
}
public static string GetEvaluatedItemIncludeEscaped (ProjectItemInstance item)
{
- throw new NotImplementedException ();
+ return ProjectCollection.Escape (item.EvaluatedInclude);
}
public static string GetMetadataValueEscaped (ProjectMetadataInstance metadatum)
{
- throw new NotImplementedException ();
+ return ProjectCollection.Escape (metadatum.EvaluatedValue);
}
public static string GetMetadataValueEscaped (ProjectItemDefinitionInstance item, string name)
{
- throw new NotImplementedException ();
+ var md = item.Metadata.FirstOrDefault (m => m.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
+ return md != null ? ProjectCollection.Escape (md.EvaluatedValue) : null;
}
public static string GetMetadataValueEscaped (ProjectItemInstance item, string name)
{
- throw new NotImplementedException ();
+ var md = item.Metadata.FirstOrDefault (m => m.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
+ return md != null ? ProjectCollection.Escape (md.EvaluatedValue) : null;
}
public static string GetPropertyValueEscaped (ProjectPropertyInstance property)
{
- throw new NotImplementedException ();
+ // WTF happens here.
+ //return ProjectCollection.Escape (property.EvaluatedValue);
+ return property.EvaluatedValue;
+ }
+
+ internal BuildTaskDatabase TaskDatabase { get; private set; }
+
+ internal string GetFullPath (string pathRelativeToProject)
+ {
+ if (Path.IsPathRooted (pathRelativeToProject))
+ return pathRelativeToProject;
+ return Path.GetFullPath (Path.Combine (Directory, pathRelativeToProject));
}
}
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemDefinitionInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemDefinitionInstance.cs
index 4641a951ce..fb10ceec17 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemDefinitionInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemDefinitionInstance.cs
@@ -4,7 +4,7 @@
// Author:
// Atsushi Enomoto (atsushi@veritas-vos-liberabit.com)
//
-// Copyright (C) 2012 Xamarin Inc.
+// Copyright (C) 2012,2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,29 +29,43 @@
using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
+using Microsoft.Build.Construction;
+using System.Linq;
namespace Microsoft.Build.Execution
{
public class ProjectItemDefinitionInstance
{
- internal ProjectItemDefinitionInstance ()
+ internal ProjectItemDefinitionInstance (ProjectItemDefinitionElement xml)
{
+ ItemType = xml.ItemType;
+ AddItems (xml);
}
- public string ItemType {
- get { throw new NotImplementedException (); }
- }
+ List<ProjectMetadataInstance> metadata = new List<ProjectMetadataInstance> ();
+
+ public string ItemType { get; private set; }
public ICollection<ProjectMetadataInstance> Metadata {
- get { throw new NotImplementedException (); }
+ get { return metadata; }
}
public int MetadataCount {
- get { throw new NotImplementedException (); }
+ get { return metadata.Count; }
}
public IEnumerable<string> MetadataNames {
- get { throw new NotImplementedException (); }
+ get { return metadata.Select (m => m.Name).ToArray (); }
+ }
+
+ internal void AddItems (ProjectItemDefinitionElement xml)
+ {
+ foreach (var item in xml.Metadata) {
+ var existing = metadata.FirstOrDefault (i => i.Name == item.Name);
+ if (existing != null)
+ metadata.Remove (existing);
+ metadata.Add (new ProjectMetadataInstance (item.Name, item.Value));
+ }
}
}
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskInstance.cs
new file mode 100644
index 0000000000..bf9d03f05f
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskInstance.cs
@@ -0,0 +1,82 @@
+//
+// ProjectItemGroupTaskInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public sealed class ProjectItemGroupTaskInstance : ProjectTargetInstanceChild
+ {
+ internal ProjectItemGroupTaskInstance (ProjectItemGroupElement xml)
+ {
+ condition = xml.Condition;
+ condition_location = xml.ConditionLocation;
+ //this.FullPath = fullPath;
+ location = xml.Location;
+
+ Items = xml.Items.Select (item => new ProjectItemGroupTaskItemInstance (item)).ToArray ();
+ }
+
+ readonly string condition;
+ readonly ElementLocation condition_location, location;
+
+ public override string Condition {
+ get { return condition; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation Location {
+ get { return location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ ElementLocation ExecuteTargetsLocation { get; private set; }
+
+ public ICollection<ProjectItemGroupTaskItemInstance> Items { get; private set; }
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskItemInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskItemInstance.cs
new file mode 100644
index 0000000000..8d947b72ba
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskItemInstance.cs
@@ -0,0 +1,95 @@
+//
+// ProjectItemGroupTaskItemInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using Microsoft.Build.Construction;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Microsoft.Build.Execution
+{
+ public class ProjectItemGroupTaskItemInstance
+ {
+ internal ProjectItemGroupTaskItemInstance (ProjectItemElement xml)
+ {
+ Condition = xml.Condition;
+ Exclude = xml.Exclude;
+ Include = xml.Include;
+ ItemType = xml.ItemType;
+ Metadata = xml.Metadata.Select (m => new ProjectItemGroupTaskMetadataInstance (m)).ToArray ();
+ Remove = xml.Remove;
+ #if NET_4_5
+ KeepDuplicates = xml.KeepDuplicates;
+ KeepMetadata = xml.KeepMetadata;
+ RemoveMetadata = xml.RemoveMetadata;
+
+ ConditionLocation = xml.ConditionLocation;
+ ExcludeLocation = xml.ExcludeLocation;
+ IncludeLocation = xml.IncludeLocation;
+ Location = xml.Location;
+ KeepDuplicatesLocation = xml.KeepDuplicatesLocation;
+ RemoveLocation = xml.RemoveLocation;
+ RemoveMetadataLocation = xml.RemoveMetadataLocation;
+ #endif
+ }
+
+ public string Condition { get; private set; }
+
+ public string Exclude { get; private set; }
+
+ public string Include { get; private set; }
+
+ public string ItemType { get; private set; }
+
+ public string KeepDuplicates { get; private set; }
+
+ public string KeepMetadata { get; private set; }
+
+ public ICollection<ProjectItemGroupTaskMetadataInstance> Metadata { get; private set; }
+
+ public string Remove { get; private set; }
+
+ public string RemoveMetadata { get; private set; }
+ #if NET_4_5
+ public ElementLocation ConditionLocation { get; private set; }
+
+ public ElementLocation ExcludeLocation { get; private set; }
+
+ public ElementLocation IncludeLocation { get; private set; }
+
+ public ElementLocation KeepDuplicatesLocation { get; private set; }
+
+ public ElementLocation KeepMetadataLocation { get; private set; }
+
+ public ElementLocation Location { get; private set; }
+
+ public ElementLocation RemoveLocation { get; private set; }
+
+ public ElementLocation RemoveMetadataLocation { get; private set; }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskMetadataInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskMetadataInstance.cs
new file mode 100644
index 0000000000..ad871731c5
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemGroupTaskMetadataInstance.cs
@@ -0,0 +1,58 @@
+//
+// ProjectItemGroupTaskMetadataInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public sealed class ProjectItemGroupTaskMetadataInstance
+ {
+ internal ProjectItemGroupTaskMetadataInstance (ProjectMetadataElement xml)
+ {
+ Condition = xml.Condition;
+ Name = xml.Name;
+ Value = xml.Value;
+ #if NET_4_5
+ ConditionLocation = xml.ConditionLocation;
+ Location = xml.Location;
+ #endif
+ }
+ public string Condition { get; private set; }
+
+ public string Name { get; private set; }
+
+ public string Value { get; private set; }
+ #if NET_4_5
+ public ElementLocation ConditionLocation { get; private set; }
+
+ public ElementLocation Location { get; private set; }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemInstance.cs
index 0e27811ef8..720c4b32b1 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectItemInstance.cs
@@ -3,8 +3,9 @@
//
// 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
@@ -26,152 +27,191 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Evaluation;
+using System.Collections;
+using Microsoft.Build.Construction;
+using System.Globalization;
+using System.IO;
namespace Microsoft.Build.Execution
{
- public class ProjectItemInstance
+ public class ProjectItemInstance
: ITaskItem2
- {
- private ProjectItemInstance ()
- {
- throw new NotImplementedException ();
- }
-
- public ProjectMetadataInstance GetMetadata (string name)
- {
- throw new NotImplementedException ();
- }
-
- public string GetMetadataValue (string name)
- {
- throw new NotImplementedException ();
- }
-
- public bool HasMetadata (string name)
- {
- throw new NotImplementedException ();
- }
-
- public void RemoveMetadata (string metadataName)
- {
- throw new NotImplementedException ();
- }
-
- public void SetMetadata (IEnumerable<KeyValuePair<string, string>> metadataDictionary)
- {
- throw new NotImplementedException ();
- }
-
- public ProjectMetadataInstance SetMetadata (string name, string evaluatedValue)
- {
- throw new NotImplementedException ();
- }
-
- public int DirectMetadataCount {
- get { throw new NotImplementedException (); }
- }
-
- public string EvaluatedInclude {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public string ItemType {
- get { throw new NotImplementedException (); }
- }
-
- public IEnumerable<ProjectMetadataInstance> Metadata {
- get { throw new NotImplementedException (); }
- }
-
- public int MetadataCount {
- get { throw new NotImplementedException (); }
- }
-
- public ICollection<string> MetadataNames {
- get { throw new NotImplementedException (); }
- }
-
- public ProjectInstance Project {
- get { throw new NotImplementedException (); }
- }
-
- #region ITaskItem2 implementation
- string ITaskItem2.GetMetadataValueEscaped (string metadataName)
- {
- throw new NotImplementedException ();
- }
-
- void ITaskItem2.SetMetadataValueLiteral (string metadataName, string metadataValue)
- {
- throw new NotImplementedException ();
- }
-
- System.Collections.IDictionary ITaskItem2.CloneCustomMetadataEscaped ()
- {
- throw new NotImplementedException ();
- }
-
- string ITaskItem2.EvaluatedIncludeEscaped {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
- #endregion
-
- #region ITaskItem implementation
- System.Collections.IDictionary ITaskItem.CloneCustomMetadata ()
- {
- throw new NotImplementedException ();
- }
-
- void ITaskItem.CopyMetadataTo (ITaskItem destinationItem)
- {
- throw new NotImplementedException ();
- }
-
- string ITaskItem.GetMetadata (string metadataName)
- {
- throw new NotImplementedException ();
- }
-
- void ITaskItem.RemoveMetadata (string metadataName)
- {
- throw new NotImplementedException ();
- }
-
- void ITaskItem.SetMetadata (string metadataName, string metadataValue)
- {
- throw new NotImplementedException ();
- }
-
- string ITaskItem.ItemSpec {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
-
- int ITaskItem.MetadataCount {
- get {
- throw new NotImplementedException ();
- }
- }
-
- System.Collections.ICollection ITaskItem.MetadataNames {
- get {
- throw new NotImplementedException ();
- }
- }
- #endregion
- }
+ {
+ internal ProjectItemInstance (ProjectInstance project, string itemType, IEnumerable<KeyValuePair<string,string>> metadata, string evaluatedInclude)
+ {
+ this.project = project;
+ this.evaluated_include = evaluatedInclude;
+ this.item_type = itemType;
+ this.metadata = new List<ProjectMetadataInstance> ();
+ SetMetadata (metadata);
+ }
+
+ readonly ProjectInstance project;
+ readonly string item_type;
+ string evaluated_include;
+ readonly List<ProjectMetadataInstance> metadata;
+
+ public ProjectMetadataInstance GetMetadata (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ // This does not return any Well Known metadata
+ return Metadata.FirstOrDefault (m => m.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
+ }
+
+ public string GetMetadataValue (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ var wk = ProjectCollection.GetWellKnownMetadata (name, EvaluatedInclude, project.GetFullPath, RecursiveDir);
+ if (wk != null)
+ return wk;
+ var m = GetMetadata (name);
+ return m != null ? m.EvaluatedValue : null;
+ }
+
+ public bool HasMetadata (string name)
+ {
+ return GetMetadata (name) != null;
+ }
+
+ public void RemoveMetadata (string metadataName)
+ {
+ var m = GetMetadata (metadataName);
+ if (m != null)
+ metadata.Remove (m);
+ }
+
+ public void SetMetadata (IEnumerable<KeyValuePair<string, string>> metadataDictionary)
+ {
+ foreach (var p in metadataDictionary)
+ SetMetadata (p.Key, p.Value);
+ }
+
+ public ProjectMetadataInstance SetMetadata (string name, string evaluatedValue)
+ {
+ var m = metadata.FirstOrDefault (_ => _.Name.Equals (name, StringComparison.OrdinalIgnoreCase));
+ if (m != null)
+ metadata.Remove (m);
+ m = new ProjectMetadataInstance (name, evaluatedValue);
+ metadata.Add (m);
+ return m;
+ }
+
+ public int DirectMetadataCount {
+ get { throw new NotImplementedException (); }
+ }
+
+ public string EvaluatedInclude {
+ get { return evaluated_include; }
+ set {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ evaluated_include = value;
+ }
+ }
+
+ public string ItemType {
+ get { return item_type; }
+ }
+
+ public IEnumerable<ProjectMetadataInstance> Metadata {
+ get { return metadata; }
+ }
+
+ public int MetadataCount {
+ get { return metadata.Count; }
+ }
+
+ public ICollection<string> MetadataNames {
+ get { return metadata.Select (m => m.Name).ToArray (); }
+ }
+
+ public ProjectInstance Project {
+ get { return project; }
+ }
+
+ internal string RecursiveDir { get; set; }
+
+ #region ITaskItem2 implementation
+
+ string ITaskItem2.GetMetadataValueEscaped (string metadataName)
+ {
+ return ProjectCollection.Escape (GetMetadataValue (metadataName));
+ }
+
+ void ITaskItem2.SetMetadataValueLiteral (string metadataName, string metadataValue)
+ {
+ SetMetadata (metadataName, metadataValue);
+ }
+
+ System.Collections.IDictionary ITaskItem2.CloneCustomMetadataEscaped ()
+ {
+ var dic = ((ITaskItem) this).CloneCustomMetadata ();
+ foreach (DictionaryEntry p in dic)
+ dic [p.Key] = ProjectCollection.Escape ((string) p.Value);
+ return dic;
+ }
+
+ string ITaskItem2.EvaluatedIncludeEscaped {
+ get { return ProjectCollection.Escape (EvaluatedInclude); }
+ set { EvaluatedInclude = ProjectCollection.Unescape (value); }
+ }
+
+ #endregion
+
+ #region ITaskItem implementation
+
+ IDictionary ITaskItem.CloneCustomMetadata ()
+ {
+ var dic = new Hashtable ();
+ foreach (var md in Metadata)
+ dic [md.Name] = md.EvaluatedValue;
+ return dic;
+ }
+
+ void ITaskItem.CopyMetadataTo (ITaskItem destinationItem)
+ {
+ if (destinationItem == null)
+ throw new ArgumentNullException ("destinationItem");
+ foreach (var md in Metadata)
+ destinationItem.SetMetadata (md.Name, md.EvaluatedValue);
+ }
+
+ string ITaskItem.GetMetadata (string metadataName)
+ {
+ return GetMetadataValue (metadataName);
+ }
+
+ void ITaskItem.RemoveMetadata (string metadataName)
+ {
+ RemoveMetadata (metadataName);
+ }
+
+ void ITaskItem.SetMetadata (string metadataName, string metadataValue)
+ {
+ SetMetadata (metadataName, ProjectCollection.Unescape (metadataValue));
+ }
+
+ string ITaskItem.ItemSpec {
+ get { return EvaluatedInclude; }
+ set { EvaluatedInclude = value; }
+ }
+
+ int ITaskItem.MetadataCount {
+ get { return MetadataCount; }
+ }
+
+ ICollection ITaskItem.MetadataNames {
+ get { return MetadataNames.ToArray (); }
+ }
+
+ #endregion
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectMetadataInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectMetadataInstance.cs
index b0386fe28a..c94fe8740d 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectMetadataInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectMetadataInstance.cs
@@ -27,15 +27,29 @@
//
using System;
+using Microsoft.Build.Construction;
namespace Microsoft.Build.Execution
{
- public class ProjectMetadataInstance
- {
- private ProjectMetadataInstance ()
- {
- throw new NotImplementedException ();
- }
- }
+ public class ProjectMetadataInstance
+ {
+ internal ProjectMetadataInstance (string name, string value)
+ {
+ Name = name;
+ EvaluatedValue = value;
+ }
+
+ public string EvaluatedValue { get; private set; }
+ public string Name { get; private set; }
+
+ public ProjectMetadataInstance DeepClone ()
+ {
+ return new ProjectMetadataInstance (Name, EvaluatedValue);
+ }
+
+ public override string ToString ()
+ {
+ return string.Format ("{0}={1}", Name, EvaluatedValue);
+ }
+ }
}
-
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectOnErrorInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectOnErrorInstance.cs
new file mode 100644
index 0000000000..b5572ef8a5
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectOnErrorInstance.cs
@@ -0,0 +1,82 @@
+//
+// ProjectOnErrorInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public class ProjectOnErrorInstance : ProjectTargetInstanceChild
+ {
+ internal ProjectOnErrorInstance (ProjectOnErrorElement xml)
+ {
+ condition = xml.Condition;
+ ExecuteTargets = xml.ExecuteTargetsAttribute;
+ //this.FullPath = fullPath;
+ #if NET_4_5
+ condition_location = xml.ConditionLocation;
+ ExecuteTargetsLocation = xml.ExecuteTargetsAttributeLocation;
+ location = xml.Location;
+ #endif
+ }
+
+ readonly string condition;
+
+ public override string Condition {
+ get { return condition; }
+ }
+
+ public string ExecuteTargets { get; private set; }
+
+ readonly ElementLocation condition_location, location;
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ ElementLocation ExecuteTargetsLocation { get; private set; }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation Location {
+ get { return location; }
+ }
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskInstance.cs
new file mode 100644
index 0000000000..1e5d7fa6e3
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskInstance.cs
@@ -0,0 +1,82 @@
+//
+// ProjectPropertyGroupTaskInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public sealed class ProjectPropertyGroupTaskInstance : ProjectTargetInstanceChild
+ {
+ internal ProjectPropertyGroupTaskInstance (ProjectPropertyGroupElement xml)
+ {
+ condition = xml.Condition;
+ condition_location = xml.ConditionLocation;
+ //this.FullPath = fullPath;
+ location = xml.Location;
+
+ Properties = xml.Properties.Select (prop => new ProjectPropertyGroupTaskPropertyInstance (prop)).ToArray ();
+ }
+
+ readonly string condition;
+ readonly ElementLocation condition_location, location;
+
+ public override string Condition {
+ get { return condition; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation Location {
+ get { return location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ ElementLocation ExecuteTargetsLocation { get; private set; }
+
+ public ICollection<ProjectPropertyGroupTaskPropertyInstance> Properties { get; private set; }
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskPropertyInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskPropertyInstance.cs
new file mode 100644
index 0000000000..df1d2c6af1
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyGroupTaskPropertyInstance.cs
@@ -0,0 +1,61 @@
+//
+// ProjectPropertyGroupTaskPropertyInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public class ProjectPropertyGroupTaskPropertyInstance
+ {
+ internal ProjectPropertyGroupTaskPropertyInstance (ProjectPropertyElement xml)
+ {
+ Condition = xml.Condition;
+ Name = xml.Name;
+ Value = xml.Value;
+ #if NET_4_5
+ ConditionLocation = xml.ConditionLocation;
+ Location = xml.Location;
+ #endif
+ }
+
+ public string Condition { get; private set; }
+
+ public string Name { get; private set; }
+
+ public string Value { get; private set; }
+
+ #if NET_4_5
+ public ElementLocation ConditionLocation { get; private set; }
+
+ public ElementLocation Location { get; private set; }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyInstance.cs
index 3b6b32c2d8..5bacdbe61a 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectPropertyInstance.cs
@@ -3,8 +3,9 @@
//
// 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
@@ -30,12 +31,32 @@ using System;
namespace Microsoft.Build.Execution
{
- public class ProjectPropertyInstance
- {
- private ProjectPropertyInstance ()
- {
- throw new NotImplementedException ();
- }
- }
-}
+ public class ProjectPropertyInstance
+ {
+ internal ProjectPropertyInstance (string name, bool isImmutable, string evaluatedValue, Func<string> evaluatedValueGetter = null)
+ {
+ Name = name;
+ IsImmutable = isImmutable;
+ evaluated_value_getter = evaluatedValueGetter ?? (() => evaluatedValue);
+ }
+
+ Func<string> evaluated_value_getter;
+ public string EvaluatedValue {
+ get { return evaluated_value_getter (); }
+ set {
+ if (IsImmutable)
+ throw new InvalidOperationException ();
+ evaluated_value_getter = () => value;
+ }
+ }
+ public virtual bool IsImmutable { get; private set; }
+
+ public string Name { get; private set; }
+
+ public override string ToString ()
+ {
+ return string.Format ("{0}={1}", Name, EvaluatedValue);
+ }
+ }
+}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstance.cs
index a95ee16cb0..3046811068 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstance.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstance.cs
@@ -1,9 +1,11 @@
+//
// ProjectTargetInstance.cs
//
// Author:
// Rolf Bjarne Kvinge (rolf@xamarin.com)
+// Atsushi Enomoto (atsshi@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
@@ -25,16 +27,83 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+
using System;
+using Microsoft.Build.Construction;
+using System.Collections.Generic;
+using System.Linq;
namespace Microsoft.Build.Execution
{
- public sealed class ProjectTargetInstance
- {
- private ProjectTargetInstance ()
- {
- throw new NotImplementedException ();
- }
- }
+ public sealed class ProjectTargetInstance
+ {
+ internal ProjectTargetInstance (ProjectTargetElement xml)
+ {
+ FullPath = xml.ContainingProject.FullPath;
+ Children = xml.Children.Select<ProjectElement,ProjectTargetInstanceChild> (c => {
+ if (c is ProjectOnErrorElement)
+ return new ProjectOnErrorInstance ((ProjectOnErrorElement) c);
+ if (c is ProjectItemGroupElement)
+ return new ProjectItemGroupTaskInstance ((ProjectItemGroupElement) c);
+ if (c is ProjectPropertyGroupElement)
+ return new ProjectPropertyGroupTaskInstance ((ProjectPropertyGroupElement) c);
+ if (c is ProjectTaskElement)
+ return new ProjectTaskInstance ((ProjectTaskElement) c);
+ throw new NotSupportedException ();
+ }).ToArray ();
+ Condition = xml.Condition;
+ DependsOnTargets = xml.DependsOnTargets;
+ //FullPath = fullPath;
+ Inputs = xml.Inputs;
+ KeepDuplicateOutputs = xml.KeepDuplicateOutputs;
+ Name = xml.Name;
+ OnErrorChildren = xml.OnErrors.Select (c => new ProjectOnErrorInstance (c)).ToArray ();
+ Outputs = xml.Outputs;
+ Returns = xml.Returns;
+ Tasks = xml.Tasks.Select (t => new ProjectTaskInstance (t)).ToArray ();
+ AfterTargetsLocation = xml.AfterTargetsLocation;
+ BeforeTargetsLocation = xml.BeforeTargetsLocation;
+ ConditionLocation = xml.ConditionLocation;
+ DependsOnTargetsLocation = xml.DependsOnTargetsLocation;
+ InputsLocation = xml.InputsLocation;
+ KeepDuplicateOutputsLocation = xml.KeepDuplicateOutputsLocation;
+ Location = xml.Location;
+ OutputsLocation = xml.OutputsLocation;
+ ReturnsLocation = xml.ReturnsLocation;
+ }
+
+ public IList<ProjectTargetInstanceChild> Children { get; private set; }
+ public string Condition { get; private set; }
+ public string DependsOnTargets { get; private set; }
+ public string FullPath { get; private set; }
+ public string Inputs { get; private set; }
+ public string KeepDuplicateOutputs { get; private set; }
+ public string Name { get; private set; }
+ public IList<ProjectOnErrorInstance> OnErrorChildren { get; private set; }
+ public string Outputs { get; private set; }
+ public string Returns { get; private set; }
+ public ICollection<ProjectTaskInstance> Tasks { get; private set; }
+#if NET_4_5
+ public ElementLocation AfterTargetsLocation { get; private set; }
+ public ElementLocation BeforeTargetsLocation { get; private set; }
+ public ElementLocation ConditionLocation { get; private set; }
+ public ElementLocation DependsOnTargetsLocation { get; private set; }
+ public ElementLocation InputsLocation { get; private set; }
+ public ElementLocation KeepDuplicateOutputsLocation { get; private set; }
+ public ElementLocation Location { get; private set; }
+ public ElementLocation OutputsLocation { get; private set; }
+ public ElementLocation ReturnsLocation { get; private set; }
+#else
+ internal ElementLocation AfterTargetsLocation { get; private set; }
+ internal ElementLocation BeforeTargetsLocation { get; private set; }
+ internal ElementLocation ConditionLocation { get; private set; }
+ internal ElementLocation DependsOnTargetsLocation { get; private set; }
+ internal ElementLocation InputsLocation { get; private set; }
+ internal ElementLocation KeepDuplicateOutputsLocation { get; private set; }
+ internal ElementLocation Location { get; private set; }
+ internal ElementLocation OutputsLocation { get; private set; }
+ internal ElementLocation ReturnsLocation { get; private set; }
+#endif
+ }
}
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstanceChild.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstanceChild.cs
new file mode 100644
index 0000000000..aa38e6b006
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTargetInstanceChild.cs
@@ -0,0 +1,52 @@
+//
+// ProjectTargetInstanceChild.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public abstract class ProjectTargetInstanceChild
+ {
+ public abstract string Condition { get; }
+ public string FullPath { get; internal set; }
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ abstract ElementLocation ConditionLocation { get; }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ abstract ElementLocation Location { get; }
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstance.cs
new file mode 100644
index 0000000000..bc53da1656
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstance.cs
@@ -0,0 +1,108 @@
+//
+// ProjectOnErrorInstance.cs
+//
+// Author:
+// Atsushi Enomoto (atsushi@xamarin.com)
+//
+// (C) 2013 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using Microsoft.Build.Construction;
+using System.Linq;
+
+namespace Microsoft.Build.Execution
+{
+ public sealed class ProjectTaskInstance : ProjectTargetInstanceChild
+ {
+ internal ProjectTaskInstance (ProjectTaskElement xml)
+ {
+ condition = xml.Condition;
+ ContinueOnError = xml.ContinueOnError;
+ Name = xml.Name;
+ Outputs = xml.Outputs.Select (o => {
+ if (o.IsOutputItem)
+ return (ProjectTaskInstanceChild) new ProjectTaskOutputItemInstance ((ProjectOutputElement) o);
+ if (o.IsOutputProperty)
+ return new ProjectTaskOutputPropertyInstance ((ProjectOutputElement) o);
+ throw new NotSupportedException ();
+ }).ToArray ();
+ Parameters = new Dictionary<string,string> (xml.Parameters);
+ #if NET_4_5
+ MSBuildArchitecture = xml.MSBuildArchitecture;
+ MSBuildRuntime = xml.MSBuildRuntime;
+
+ condition_location = xml.ConditionLocation;
+ ContinueOnErrorLocation = xml.ContinueOnErrorLocation;
+ location = xml.Location;
+ MSBuildArchitectureLocation = xml.MSBuildArchitectureLocation;
+ MSBuildRuntimeLocation = xml.MSBuildRuntimeLocation;
+ #endif
+ }
+
+ string condition;
+ public override string Condition {
+ get { return condition; }
+ }
+
+ ElementLocation condition_location, location;
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+
+ #if NET_4_5
+ public
+ #else
+ internal
+ #endif
+ override ElementLocation Location {
+ get { return location; }
+ }
+
+ public string ContinueOnError { get; private set; }
+
+ #if NET_4_5
+ public ElementLocation ContinueOnErrorLocation { get; private set; }
+
+ public string MSBuildArchitecture { get; private set; }
+
+ public ElementLocation MSBuildArchitectureLocation { get; private set; }
+
+ public string MSBuildRuntime { get; private set; }
+
+ public ElementLocation MSBuildRuntimeLocation { get; private set; }
+ #endif
+
+ public string Name { get; private set; }
+
+ public IList<ProjectTaskInstanceChild> Outputs { get; private set; }
+
+ public IDictionary<string, string> Parameters { get; private set; }
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstanceChild.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstanceChild.cs
new file mode 100644
index 0000000000..77ea7a2525
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskInstanceChild.cs
@@ -0,0 +1,16 @@
+using System;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public abstract class ProjectTaskInstanceChild
+ {
+ public abstract string Condition { get; }
+ #if NET_4_5
+ public abstract ElementLocation ConditionLocation { get; }
+ public abstract ElementLocation Location { get; }
+ public abstract ElementLocation TaskParameterLocation { get; }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputItemInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputItemInstance.cs
new file mode 100644
index 0000000000..356f9a62f2
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputItemInstance.cs
@@ -0,0 +1,42 @@
+using System;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public class ProjectTaskOutputItemInstance : ProjectTaskInstanceChild
+ {
+ internal ProjectTaskOutputItemInstance (ProjectOutputElement xml)
+ {
+ condition = xml.Condition;
+ ItemType = xml.ItemType;
+ TaskParameter = xml.TaskParameter;
+ #if NET_4_5
+ condition_location = xml.ConditionLocation;
+ location = xml.Location;
+ task_parameter_location = xml.TaskParameterLocation;
+ #endif
+ }
+
+ public string ItemType { get; private set; }
+ public string TaskParameter { get; private set; }
+
+ readonly string condition;
+ public override string Condition {
+ get { return condition; }
+ }
+ #if NET_4_5
+ readonly ElementLocation condition_location, location, task_parameter_location;
+ public ElementLocation ItemTypeLocation { get; private set; }
+ public override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+ public override ElementLocation Location {
+ get { return location; }
+ }
+ public override ElementLocation TaskParameterLocation {
+ get { return task_parameter_location; }
+ }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputPropertyInstance.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputPropertyInstance.cs
new file mode 100644
index 0000000000..855268e130
--- /dev/null
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/ProjectTaskOutputPropertyInstance.cs
@@ -0,0 +1,43 @@
+using System;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.Build.Execution
+{
+ public class ProjectTaskOutputPropertyInstance : ProjectTaskInstanceChild
+ {
+ internal ProjectTaskOutputPropertyInstance (ProjectOutputElement xml)
+ {
+ condition = xml.Condition;
+ PropertyName = xml.PropertyName;
+ TaskParameter = xml.TaskParameter;
+ #if NET_4_5
+ condition_location = xml.ConditionLocation;
+ location = xml.Location;
+ task_parameter_location = xml.TaskParameterLocation;
+ #endif
+ }
+
+ public string PropertyName { get; private set; }
+ public string TaskParameter { get; private set; }
+
+ readonly string condition;
+ public override string Condition {
+ get { return condition; }
+ }
+
+ #if NET_4_5
+ readonly ElementLocation condition_location, location, task_parameter_location;
+ public ElementLocation PropertyNameLocation { get; private set; }
+ public override ElementLocation ConditionLocation {
+ get { return condition_location; }
+ }
+ public override ElementLocation Location {
+ get { return location; }
+ }
+ public override ElementLocation TaskParameterLocation {
+ get { return task_parameter_location; }
+ }
+ #endif
+ }
+}
+
diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/TargetResult.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/TargetResult.cs
index 863966ba78..d6dac3a8ff 100644
--- a/mcs/class/Microsoft.Build/Microsoft.Build.Execution/TargetResult.cs
+++ b/mcs/class/Microsoft.Build/Microsoft.Build.Execution/TargetResult.cs
@@ -26,30 +26,40 @@
//
using Microsoft.Build.Framework;
-
using System;
+using System.Linq;
+using System.Collections.Generic;
namespace Microsoft.Build.Execution
{
- public class TargetResult : ITargetResult
- {
- internal TargetResult ()
- {
- throw new NotImplementedException ();
- }
+ public class TargetResult : ITargetResult
+ {
+ internal TargetResult ()
+ {
+ }
- public Exception Exception {
- get { throw new NotImplementedException (); }
- }
+ public Exception Exception { get; private set; }
- public ITaskItem[] Items {
- get { throw new NotImplementedException (); }
- }
+ public ITaskItem[] Items { get; private set; }
+ public TargetResultCode ResultCode { get; private set; }
- public TargetResultCode ResultCode {
- get { throw new NotImplementedException (); }
- }
- }
+ internal void Failure (Exception exception)
+ {
+ this.Exception = exception;
+ ResultCode = TargetResultCode.Failure;
+ }
+
+ internal void Skip ()
+ {
+ ResultCode = TargetResultCode.Skipped;
+ }
+
+ internal void Success (IEnumerable<ITaskItem> items)
+ {
+ Items = items.ToArray ();
+ ResultCode = TargetResultCode.Success;
+ }
+ }
}