Merge pull request #981 from methane/websocket
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Execution / BuildParameters.cs
1 // BuildParameters.cs
2 //
3 // Author:
4 //   Rolf Bjarne Kvinge (rolf@xamarin.com)
5 //   Atsushi Enomoto (atsushi@xamarin.com)
6 //
7 // Copyright (C) 2011,2013 Xamarin Inc.
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using Microsoft.Build.Evaluation;
30 using Microsoft.Build.Framework;
31 using Microsoft.Build.Logging;
32 using System;
33 using System.Collections.Generic;
34 using System.Globalization;
35 using System.Linq;
36 using System.Threading;
37 using System.Collections;
38
39 namespace Microsoft.Build.Execution
40 {
41         public class BuildParameters
42         {
43                 public BuildParameters ()
44                         : this (new ProjectCollection ())
45                 {
46                 }
47
48                 public BuildParameters (ProjectCollection projectCollection)
49                 {
50                         if (projectCollection == null)
51                                 throw new ArgumentNullException ("projectCollection");
52                         projects = projectCollection;
53                         
54                         EnableNodeReuse = true;
55                         Culture = CultureInfo.CurrentCulture;
56                         UICulture = CultureInfo.CurrentUICulture;
57                         MaxNodeCount = projectCollection.MaxNodeCount;
58
59                         // these properties are copied, while some members (such as Loggers) are not.
60                         this.DefaultToolsVersion = projectCollection.DefaultToolsVersion;
61                         this.ToolsetDefinitionLocations = projectCollection.ToolsetLocations;
62                         this.GlobalProperties = projectCollection.GlobalProperties;
63                         environment_properties = new Dictionary<string,string> ();
64                         foreach (DictionaryEntry p in Environment.GetEnvironmentVariables ())
65                                 environment_properties [(string) p.Key] = (string) p.Value;
66                 }
67
68                 readonly ProjectCollection projects;
69                 Dictionary<string,string> environment_properties;
70                 
71                 internal ProjectCollection ProjectCollection {
72                         get { return projects; }
73                 }
74
75                 public BuildParameters Clone ()
76                 {
77                         var ret = (BuildParameters) MemberwiseClone ();
78                         ret.ForwardingLoggers = ForwardingLoggers == null ? null : ForwardingLoggers.ToArray ();
79                         ret.GlobalProperties = GlobalProperties == null ? null : GlobalProperties.ToDictionary (p => p.Key, p => p.Value);
80                         ret.Loggers = Loggers == null ? null : new List<ILogger> (Loggers);
81                         ret.environment_properties = new Dictionary<string, string> (environment_properties);
82                         return ret;
83                 }
84
85                 public Toolset GetToolset (string toolsVersion)
86                 {
87                         // can return null.
88                         return projects.Toolsets.FirstOrDefault (t => t.ToolsVersion == toolsVersion);
89                 }
90
91                 [MonoTODO]
92                 public ThreadPriority BuildThreadPriority { get; set; }
93
94                 [MonoTODO]
95                 public CultureInfo Culture { get; set; }
96
97                 public string DefaultToolsVersion { get; set; }
98
99                 [MonoTODO]
100                 public bool DetailedSummary { get; set; }
101
102                 public bool EnableNodeReuse { get; set; }
103
104                 [MonoTODO]
105                 public IDictionary<string, string> EnvironmentProperties {
106                         get { return environment_properties; }
107                 }
108
109                 [MonoTODO]
110                 public IEnumerable<ForwardingLoggerRecord> ForwardingLoggers { get; set; }
111
112                 [MonoTODO]
113                 public IDictionary<string, string> GlobalProperties { get; set; }
114
115                 public HostServices HostServices { get; set; }
116
117                 [MonoTODO]
118                 public bool LegacyThreadingSemantics { get; set; }
119
120                 [MonoTODO]
121                 public IEnumerable<ILogger> Loggers { get; set; }
122
123                 [MonoTODO]
124                 public int MaxNodeCount { get; set; }
125
126                 [MonoTODO]
127                 public int MemoryUseLimit { get; set; }
128
129                 [MonoTODO]
130                 public string NodeExeLocation { get; set; }
131
132                 [MonoTODO]
133                 public bool OnlyLogCriticalEvents { get; set; }
134
135                 [MonoTODO]
136                 public bool ResetCaches { get; set; }
137
138                 [MonoTODO]
139                 public bool SaveOperatingEnvironment { get; set; }
140
141                 [MonoTODO]
142                 public ToolsetDefinitionLocations ToolsetDefinitionLocations { get; set; }
143
144                 [MonoTODO]
145                 public ICollection<Toolset> Toolsets {
146                         get { return projects.Toolsets; }
147                 }
148
149                 [MonoTODO]
150                 public CultureInfo UICulture { get; set; }
151
152                 [MonoTODO]
153                 public bool UseSynchronousLogging { get; set; }
154         }
155 }
156