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