aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/ProjectNode.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Nodes/ProjectNode.cs')
-rw-r--r--Prebuild/src/Core/Nodes/ProjectNode.cs580
1 files changed, 0 insertions, 580 deletions
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs
deleted file mode 100644
index 04af7a3..0000000
--- a/Prebuild/src/Core/Nodes/ProjectNode.cs
+++ /dev/null
@@ -1,580 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections;
28using System.Collections.Generic;
29using System.IO;
30using System.Xml;
31
32using Prebuild.Core.Attributes;
33using Prebuild.Core.Interfaces;
34using Prebuild.Core.Utilities;
35
36namespace Prebuild.Core.Nodes
37{
38 /// <summary>
39 /// A set of values that the Project's type can be
40 /// </summary>
41 public enum ProjectType
42 {
43 /// <summary>
44 /// The project is a console executable
45 /// </summary>
46 Exe,
47 /// <summary>
48 /// The project is a windows executable
49 /// </summary>
50 WinExe,
51 /// <summary>
52 /// The project is a library
53 /// </summary>
54 Library,
55 /// <summary>
56 /// The project is a website
57 /// </summary>
58 Web,
59 }
60
61 /// <summary>
62 ///
63 /// </summary>
64 public enum ClrRuntime
65 {
66 /// <summary>
67 ///
68 /// </summary>
69 Microsoft,
70 /// <summary>
71 ///
72 /// </summary>
73 Mono
74 }
75 /// <summary>
76 /// The version of the .NET framework to use (Required for VS2008)
77 /// <remarks>We don't need .NET 1.1 in here, it'll default when using vs2003.</remarks>
78 /// </summary>
79 public enum FrameworkVersion
80 {
81 /// <summary>
82 /// .NET 2.0
83 /// </summary>
84 v2_0,
85 /// <summary>
86 /// .NET 3.0
87 /// </summary>
88 v3_0,
89 /// <summary>
90 /// .NET 3.5
91 /// </summary>
92 v3_5,
93 /// <summary>
94 /// .NET 4.0
95 /// </summary>
96 v4_0,
97 }
98 /// <summary>
99 /// The Node object representing /Prebuild/Solution/Project elements
100 /// </summary>
101 [DataNode("Project")]
102 public class ProjectNode : DataNode, IComparable
103 {
104 #region Fields
105
106 private string m_Name = "unknown";
107 private string m_Path = "";
108 private string m_FullPath = "";
109 private string m_AssemblyName;
110 private string m_AppIcon = "";
111 private string m_ConfigFile = "";
112 private string m_DesignerFolder = "";
113 private string m_Language = "C#";
114 private ProjectType m_Type = ProjectType.Exe;
115 private ClrRuntime m_Runtime = ClrRuntime.Microsoft;
116 private FrameworkVersion m_Framework = FrameworkVersion.v2_0;
117 private string m_StartupObject = "";
118 private string m_RootNamespace;
119 private string m_FilterGroups = "";
120 private string m_Version = "";
121 private Guid m_Guid;
122 private string m_DebugStartParameters;
123
124 private Hashtable m_Configurations = new Hashtable();
125 private readonly List<ReferencePathNode> m_ReferencePaths = new List<ReferencePathNode>();
126 private readonly List<ReferenceNode> m_References = new List<ReferenceNode>();
127 private readonly List<AuthorNode> m_Authors = new List<AuthorNode>();
128 private FilesNode m_Files;
129
130 #endregion
131
132 #region Properties
133
134 /// <summary>
135 /// Gets the name.
136 /// </summary>
137 /// <value>The name.</value>
138 public string Name
139 {
140 get
141 {
142 return m_Name;
143 }
144 }
145 /// <summary>
146 /// The version of the .NET Framework to compile under
147 /// </summary>
148 public FrameworkVersion FrameworkVersion
149 {
150 get
151 {
152 return this.m_Framework;
153 }
154 }
155 /// <summary>
156 /// Gets the path.
157 /// </summary>
158 /// <value>The path.</value>
159 public string Path
160 {
161 get
162 {
163 return m_Path;
164 }
165 }
166
167 /// <summary>
168 /// Gets the filter groups.
169 /// </summary>
170 /// <value>The filter groups.</value>
171 public string FilterGroups
172 {
173 get
174 {
175 return m_FilterGroups;
176 }
177 }
178
179 /// <summary>
180 /// Gets the project's version
181 /// </summary>
182 /// <value>The project's version.</value>
183 public string Version
184 {
185 get
186 {
187 return m_Version;
188 }
189 }
190
191 /// <summary>
192 /// Gets the full path.
193 /// </summary>
194 /// <value>The full path.</value>
195 public string FullPath
196 {
197 get
198 {
199 return m_FullPath;
200 }
201 }
202
203 /// <summary>
204 /// Gets the name of the assembly.
205 /// </summary>
206 /// <value>The name of the assembly.</value>
207 public string AssemblyName
208 {
209 get
210 {
211 return m_AssemblyName;
212 }
213 }
214
215 /// <summary>
216 /// Gets the app icon.
217 /// </summary>
218 /// <value>The app icon.</value>
219 public string AppIcon
220 {
221 get
222 {
223 return m_AppIcon;
224 }
225 }
226
227 /// <summary>
228 /// Gets the app icon.
229 /// </summary>
230 /// <value>The app icon.</value>
231 public string ConfigFile
232 {
233 get
234 {
235 return m_ConfigFile;
236 }
237 }
238
239 /// <summary>
240 ///
241 /// </summary>
242 public string DesignerFolder
243 {
244 get
245 {
246 return m_DesignerFolder;
247 }
248 }
249
250 /// <summary>
251 /// Gets the language.
252 /// </summary>
253 /// <value>The language.</value>
254 public string Language
255 {
256 get
257 {
258 return m_Language;
259 }
260 }
261
262 /// <summary>
263 /// Gets the type.
264 /// </summary>
265 /// <value>The type.</value>
266 public ProjectType Type
267 {
268 get
269 {
270 return m_Type;
271 }
272 }
273
274 /// <summary>
275 /// Gets the runtime.
276 /// </summary>
277 /// <value>The runtime.</value>
278 public ClrRuntime Runtime
279 {
280 get
281 {
282 return m_Runtime;
283 }
284 }
285
286 private bool m_GenerateAssemblyInfoFile = false;
287
288 /// <summary>
289 ///
290 /// </summary>
291 public bool GenerateAssemblyInfoFile
292 {
293 get
294 {
295 return m_GenerateAssemblyInfoFile;
296 }
297 set
298 {
299 m_GenerateAssemblyInfoFile = value;
300 }
301 }
302
303 /// <summary>
304 /// Gets the startup object.
305 /// </summary>
306 /// <value>The startup object.</value>
307 public string StartupObject
308 {
309 get
310 {
311 return m_StartupObject;
312 }
313 }
314
315 /// <summary>
316 /// Gets the root namespace.
317 /// </summary>
318 /// <value>The root namespace.</value>
319 public string RootNamespace
320 {
321 get
322 {
323 return m_RootNamespace;
324 }
325 }
326
327 /// <summary>
328 /// Gets the configurations.
329 /// </summary>
330 /// <value>The configurations.</value>
331 public IList Configurations
332 {
333 get
334 {
335 ArrayList tmp = new ArrayList(ConfigurationsTable.Values);
336 tmp.Sort();
337 return tmp;
338 }
339 }
340
341 /// <summary>
342 /// Gets the configurations table.
343 /// </summary>
344 /// <value>The configurations table.</value>
345 public Hashtable ConfigurationsTable
346 {
347 get
348 {
349 return m_Configurations;
350 }
351 }
352
353 /// <summary>
354 /// Gets the reference paths.
355 /// </summary>
356 /// <value>The reference paths.</value>
357 public List<ReferencePathNode> ReferencePaths
358 {
359 get
360 {
361 List<ReferencePathNode> tmp = new List<ReferencePathNode>(m_ReferencePaths);
362 tmp.Sort();
363 return tmp;
364 }
365 }
366
367 /// <summary>
368 /// Gets the references.
369 /// </summary>
370 /// <value>The references.</value>
371 public List<ReferenceNode> References
372 {
373 get
374 {
375 List<ReferenceNode> tmp = new List<ReferenceNode>(m_References);
376 tmp.Sort();
377 return tmp;
378 }
379 }
380
381 /// <summary>
382 /// Gets the Authors list.
383 /// </summary>
384 /// <value>The list of the project's authors.</value>
385 public List<AuthorNode> Authors
386 {
387 get
388 {
389 return m_Authors;
390 }
391 }
392
393 /// <summary>
394 /// Gets the files.
395 /// </summary>
396 /// <value>The files.</value>
397 public FilesNode Files
398 {
399 get
400 {
401 return m_Files;
402 }
403 }
404
405 /// <summary>
406 /// Gets or sets the parent.
407 /// </summary>
408 /// <value>The parent.</value>
409 public override IDataNode Parent
410 {
411 get
412 {
413 return base.Parent;
414 }
415 set
416 {
417 base.Parent = value;
418 if(base.Parent is SolutionNode && m_Configurations.Count < 1)
419 {
420 SolutionNode parent = (SolutionNode)base.Parent;
421 foreach(ConfigurationNode conf in parent.Configurations)
422 {
423 m_Configurations[conf.Name] = conf.Clone();
424 }
425 }
426 }
427 }
428
429 /// <summary>
430 /// Gets the GUID.
431 /// </summary>
432 /// <value>The GUID.</value>
433 public Guid Guid
434 {
435 get
436 {
437 return m_Guid;
438 }
439 }
440
441 public string DebugStartParameters
442 {
443 get
444 {
445 return m_DebugStartParameters;
446 }
447 }
448
449 #endregion
450
451 #region Private Methods
452
453 private void HandleConfiguration(ConfigurationNode conf)
454 {
455 if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first,
456 //so it *may* override changes to the same properties for configurations defines at the project level
457 {
458 foreach(ConfigurationNode confNode in this.m_Configurations.Values)
459 {
460 conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides
461 }
462 }
463 if(m_Configurations.ContainsKey(conf.Name))
464 {
465 ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name];
466 conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides
467 }
468 else
469 {
470 m_Configurations[conf.Name] = conf;
471 }
472 }
473
474 #endregion
475
476 #region Public Methods
477
478 /// <summary>
479 /// Parses the specified node.
480 /// </summary>
481 /// <param name="node">The node.</param>
482 public override void Parse(XmlNode node)
483 {
484 m_Name = Helper.AttributeValue(node, "name", m_Name);
485 m_Path = Helper.AttributeValue(node, "path", m_Path);
486 m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups);
487 m_Version = Helper.AttributeValue(node, "version", m_Version);
488 m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon);
489 m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile);
490 m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder);
491 m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName);
492 m_Language = Helper.AttributeValue(node, "language", m_Language);
493 m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type);
494 m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime);
495 m_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework);
496 m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject);
497 m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace);
498
499 int hash = m_Name.GetHashCode();
500 Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
501 string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString());
502 m_Guid = new Guid(guid);
503
504 m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false);
505 m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty);
506
507 if(m_AssemblyName == null || m_AssemblyName.Length < 1)
508 {
509 m_AssemblyName = m_Name;
510 }
511
512 if(m_RootNamespace == null || m_RootNamespace.Length < 1)
513 {
514 m_RootNamespace = m_Name;
515 }
516
517 m_FullPath = m_Path;
518 try
519 {
520 m_FullPath = Helper.ResolvePath(m_FullPath);
521 }
522 catch
523 {
524 throw new WarningException("Could not resolve Solution path: {0}", m_Path);
525 }
526
527 Kernel.Instance.CurrentWorkingDirectory.Push();
528 try
529 {
530 Helper.SetCurrentDir(m_FullPath);
531
532 if( node == null )
533 {
534 throw new ArgumentNullException("node");
535 }
536
537 foreach(XmlNode child in node.ChildNodes)
538 {
539 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
540 if(dataNode is ConfigurationNode)
541 {
542 HandleConfiguration((ConfigurationNode)dataNode);
543 }
544 else if(dataNode is ReferencePathNode)
545 {
546 m_ReferencePaths.Add((ReferencePathNode)dataNode);
547 }
548 else if(dataNode is ReferenceNode)
549 {
550 m_References.Add((ReferenceNode)dataNode);
551 }
552 else if(dataNode is AuthorNode)
553 {
554 m_Authors.Add((AuthorNode)dataNode);
555 }
556 else if(dataNode is FilesNode)
557 {
558 m_Files = (FilesNode)dataNode;
559 }
560 }
561 }
562 finally
563 {
564 Kernel.Instance.CurrentWorkingDirectory.Pop();
565 }
566 }
567
568 #endregion
569
570 #region IComparable Members
571
572 public int CompareTo(object obj)
573 {
574 ProjectNode that = (ProjectNode)obj;
575 return this.m_Name.CompareTo(that.m_Name);
576 }
577
578 #endregion
579 }
580}