diff options
author | Justin Clark-Casey (justincc) | 2010-09-11 01:13:08 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-09-11 01:13:08 +0100 |
commit | 7e65590a55ba575d0086bdfc25addaf1051d799b (patch) | |
tree | 1dc11683170d45d80d7aab6eefdfcc836d3e773b /Prebuild/src/Core/Nodes/ProjectNode.cs | |
parent | Make it clear that the "create region" command will reference ini files in th... (diff) | |
download | opensim-SC_OLD-7e65590a55ba575d0086bdfc25addaf1051d799b.zip opensim-SC_OLD-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.gz opensim-SC_OLD-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.bz2 opensim-SC_OLD-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.xz |
Update Prebuild.exe with Prebuild r323 + an existing OpenSim specific nant hack to correctly clean up chosen OpenSim exes and dlls in bin/ on a "nant clean"
Source code is included for reference. This can go away again once Prebuild is updated with a more general mechanism for cleaning up files.
The Prebuild source code here can be built with nant, or regnerated for other tools using the prebuild at {root}/bin/Prebuild.exe
Diffstat (limited to '')
-rw-r--r-- | Prebuild/src/Core/Nodes/ProjectNode.cs | 579 |
1 files changed, 579 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs new file mode 100644 index 0000000..fb92b32 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs | |||
@@ -0,0 +1,579 @@ | |||
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 | } | ||
97 | /// <summary> | ||
98 | /// The Node object representing /Prebuild/Solution/Project elements | ||
99 | /// </summary> | ||
100 | [DataNode("Project")] | ||
101 | public class ProjectNode : DataNode, IComparable | ||
102 | { | ||
103 | #region Fields | ||
104 | |||
105 | private string m_Name = "unknown"; | ||
106 | private string m_Path = ""; | ||
107 | private string m_FullPath = ""; | ||
108 | private string m_AssemblyName; | ||
109 | private string m_AppIcon = ""; | ||
110 | private string m_ConfigFile = ""; | ||
111 | private string m_DesignerFolder = ""; | ||
112 | private string m_Language = "C#"; | ||
113 | private ProjectType m_Type = ProjectType.Exe; | ||
114 | private ClrRuntime m_Runtime = ClrRuntime.Microsoft; | ||
115 | private FrameworkVersion m_Framework = FrameworkVersion.v2_0; | ||
116 | private string m_StartupObject = ""; | ||
117 | private string m_RootNamespace; | ||
118 | private string m_FilterGroups = ""; | ||
119 | private string m_Version = ""; | ||
120 | private Guid m_Guid; | ||
121 | private string m_DebugStartParameters; | ||
122 | |||
123 | private readonly Dictionary<string, ConfigurationNode> m_Configurations = new Dictionary<string, ConfigurationNode>(); | ||
124 | private readonly List<ReferencePathNode> m_ReferencePaths = new List<ReferencePathNode>(); | ||
125 | private readonly List<ReferenceNode> m_References = new List<ReferenceNode>(); | ||
126 | private readonly List<AuthorNode> m_Authors = new List<AuthorNode>(); | ||
127 | private FilesNode m_Files; | ||
128 | |||
129 | #endregion | ||
130 | |||
131 | #region Properties | ||
132 | |||
133 | /// <summary> | ||
134 | /// Gets the name. | ||
135 | /// </summary> | ||
136 | /// <value>The name.</value> | ||
137 | public string Name | ||
138 | { | ||
139 | get | ||
140 | { | ||
141 | return m_Name; | ||
142 | } | ||
143 | } | ||
144 | /// <summary> | ||
145 | /// The version of the .NET Framework to compile under | ||
146 | /// </summary> | ||
147 | public FrameworkVersion FrameworkVersion | ||
148 | { | ||
149 | get | ||
150 | { | ||
151 | return m_Framework; | ||
152 | } | ||
153 | } | ||
154 | /// <summary> | ||
155 | /// Gets the path. | ||
156 | /// </summary> | ||
157 | /// <value>The path.</value> | ||
158 | public string Path | ||
159 | { | ||
160 | get | ||
161 | { | ||
162 | return m_Path; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// Gets the filter groups. | ||
168 | /// </summary> | ||
169 | /// <value>The filter groups.</value> | ||
170 | public string FilterGroups | ||
171 | { | ||
172 | get | ||
173 | { | ||
174 | return m_FilterGroups; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | /// <summary> | ||
179 | /// Gets the project's version | ||
180 | /// </summary> | ||
181 | /// <value>The project's version.</value> | ||
182 | public string Version | ||
183 | { | ||
184 | get | ||
185 | { | ||
186 | return m_Version; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Gets the full path. | ||
192 | /// </summary> | ||
193 | /// <value>The full path.</value> | ||
194 | public string FullPath | ||
195 | { | ||
196 | get | ||
197 | { | ||
198 | return m_FullPath; | ||
199 | } | ||
200 | } | ||
201 | |||
202 | /// <summary> | ||
203 | /// Gets the name of the assembly. | ||
204 | /// </summary> | ||
205 | /// <value>The name of the assembly.</value> | ||
206 | public string AssemblyName | ||
207 | { | ||
208 | get | ||
209 | { | ||
210 | return m_AssemblyName; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
215 | /// Gets the app icon. | ||
216 | /// </summary> | ||
217 | /// <value>The app icon.</value> | ||
218 | public string AppIcon | ||
219 | { | ||
220 | get | ||
221 | { | ||
222 | return m_AppIcon; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | /// <summary> | ||
227 | /// Gets the app icon. | ||
228 | /// </summary> | ||
229 | /// <value>The app icon.</value> | ||
230 | public string ConfigFile | ||
231 | { | ||
232 | get | ||
233 | { | ||
234 | return m_ConfigFile; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | /// <summary> | ||
239 | /// | ||
240 | /// </summary> | ||
241 | public string DesignerFolder | ||
242 | { | ||
243 | get | ||
244 | { | ||
245 | return m_DesignerFolder; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /// <summary> | ||
250 | /// Gets the language. | ||
251 | /// </summary> | ||
252 | /// <value>The language.</value> | ||
253 | public string Language | ||
254 | { | ||
255 | get | ||
256 | { | ||
257 | return m_Language; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | /// <summary> | ||
262 | /// Gets the type. | ||
263 | /// </summary> | ||
264 | /// <value>The type.</value> | ||
265 | public ProjectType Type | ||
266 | { | ||
267 | get | ||
268 | { | ||
269 | return m_Type; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | /// <summary> | ||
274 | /// Gets the runtime. | ||
275 | /// </summary> | ||
276 | /// <value>The runtime.</value> | ||
277 | public ClrRuntime Runtime | ||
278 | { | ||
279 | get | ||
280 | { | ||
281 | return m_Runtime; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | private bool m_GenerateAssemblyInfoFile; | ||
286 | |||
287 | /// <summary> | ||
288 | /// | ||
289 | /// </summary> | ||
290 | public bool GenerateAssemblyInfoFile | ||
291 | { | ||
292 | get | ||
293 | { | ||
294 | return m_GenerateAssemblyInfoFile; | ||
295 | } | ||
296 | set | ||
297 | { | ||
298 | m_GenerateAssemblyInfoFile = value; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | /// <summary> | ||
303 | /// Gets the startup object. | ||
304 | /// </summary> | ||
305 | /// <value>The startup object.</value> | ||
306 | public string StartupObject | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | return m_StartupObject; | ||
311 | } | ||
312 | } | ||
313 | |||
314 | /// <summary> | ||
315 | /// Gets the root namespace. | ||
316 | /// </summary> | ||
317 | /// <value>The root namespace.</value> | ||
318 | public string RootNamespace | ||
319 | { | ||
320 | get | ||
321 | { | ||
322 | return m_RootNamespace; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | /// <summary> | ||
327 | /// Gets the configurations. | ||
328 | /// </summary> | ||
329 | /// <value>The configurations.</value> | ||
330 | public List<ConfigurationNode> Configurations | ||
331 | { | ||
332 | get | ||
333 | { | ||
334 | List<ConfigurationNode> tmp = new List<ConfigurationNode>(ConfigurationsTable.Values); | ||
335 | tmp.Sort(); | ||
336 | return tmp; | ||
337 | } | ||
338 | } | ||
339 | |||
340 | /// <summary> | ||
341 | /// Gets the configurations table. | ||
342 | /// </summary> | ||
343 | /// <value>The configurations table.</value> | ||
344 | public Dictionary<string, ConfigurationNode> ConfigurationsTable | ||
345 | { | ||
346 | get | ||
347 | { | ||
348 | return m_Configurations; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | /// <summary> | ||
353 | /// Gets the reference paths. | ||
354 | /// </summary> | ||
355 | /// <value>The reference paths.</value> | ||
356 | public List<ReferencePathNode> ReferencePaths | ||
357 | { | ||
358 | get | ||
359 | { | ||
360 | List<ReferencePathNode> tmp = new List<ReferencePathNode>(m_ReferencePaths); | ||
361 | tmp.Sort(); | ||
362 | return tmp; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | /// <summary> | ||
367 | /// Gets the references. | ||
368 | /// </summary> | ||
369 | /// <value>The references.</value> | ||
370 | public List<ReferenceNode> References | ||
371 | { | ||
372 | get | ||
373 | { | ||
374 | List<ReferenceNode> tmp = new List<ReferenceNode>(m_References); | ||
375 | tmp.Sort(); | ||
376 | return tmp; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | /// <summary> | ||
381 | /// Gets the Authors list. | ||
382 | /// </summary> | ||
383 | /// <value>The list of the project's authors.</value> | ||
384 | public List<AuthorNode> Authors | ||
385 | { | ||
386 | get | ||
387 | { | ||
388 | return m_Authors; | ||
389 | } | ||
390 | } | ||
391 | |||
392 | /// <summary> | ||
393 | /// Gets the files. | ||
394 | /// </summary> | ||
395 | /// <value>The files.</value> | ||
396 | public FilesNode Files | ||
397 | { | ||
398 | get | ||
399 | { | ||
400 | return m_Files; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | /// <summary> | ||
405 | /// Gets or sets the parent. | ||
406 | /// </summary> | ||
407 | /// <value>The parent.</value> | ||
408 | public override IDataNode Parent | ||
409 | { | ||
410 | get | ||
411 | { | ||
412 | return base.Parent; | ||
413 | } | ||
414 | set | ||
415 | { | ||
416 | base.Parent = value; | ||
417 | if(base.Parent is SolutionNode && m_Configurations.Count < 1) | ||
418 | { | ||
419 | SolutionNode parent = (SolutionNode)base.Parent; | ||
420 | foreach(ConfigurationNode conf in parent.Configurations) | ||
421 | { | ||
422 | m_Configurations[conf.NameAndPlatform] = (ConfigurationNode) conf.Clone(); | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | } | ||
427 | |||
428 | /// <summary> | ||
429 | /// Gets the GUID. | ||
430 | /// </summary> | ||
431 | /// <value>The GUID.</value> | ||
432 | public Guid Guid | ||
433 | { | ||
434 | get | ||
435 | { | ||
436 | return m_Guid; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | public string DebugStartParameters | ||
441 | { | ||
442 | get | ||
443 | { | ||
444 | return m_DebugStartParameters; | ||
445 | } | ||
446 | } | ||
447 | |||
448 | #endregion | ||
449 | |||
450 | #region Private Methods | ||
451 | |||
452 | private void HandleConfiguration(ConfigurationNode conf) | ||
453 | { | ||
454 | if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, | ||
455 | //so it *may* override changes to the same properties for configurations defines at the project level | ||
456 | { | ||
457 | foreach(ConfigurationNode confNode in m_Configurations.Values) | ||
458 | { | ||
459 | conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides | ||
460 | } | ||
461 | } | ||
462 | if(m_Configurations.ContainsKey(conf.NameAndPlatform)) | ||
463 | { | ||
464 | ConfigurationNode parentConf = m_Configurations[conf.NameAndPlatform]; | ||
465 | conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides | ||
466 | } | ||
467 | else | ||
468 | { | ||
469 | m_Configurations[conf.NameAndPlatform] = conf; | ||
470 | } | ||
471 | } | ||
472 | |||
473 | #endregion | ||
474 | |||
475 | #region Public Methods | ||
476 | |||
477 | /// <summary> | ||
478 | /// Parses the specified node. | ||
479 | /// </summary> | ||
480 | /// <param name="node">The node.</param> | ||
481 | public override void Parse(XmlNode node) | ||
482 | { | ||
483 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
484 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
485 | m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); | ||
486 | m_Version = Helper.AttributeValue(node, "version", m_Version); | ||
487 | m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); | ||
488 | m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile); | ||
489 | m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); | ||
490 | m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); | ||
491 | m_Language = Helper.AttributeValue(node, "language", m_Language); | ||
492 | m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); | ||
493 | m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); | ||
494 | m_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework); | ||
495 | m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); | ||
496 | m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); | ||
497 | |||
498 | int hash = m_Name.GetHashCode(); | ||
499 | Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
500 | string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString()); | ||
501 | m_Guid = new Guid(guid); | ||
502 | |||
503 | m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); | ||
504 | m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty); | ||
505 | |||
506 | if(string.IsNullOrEmpty(m_AssemblyName)) | ||
507 | { | ||
508 | m_AssemblyName = m_Name; | ||
509 | } | ||
510 | |||
511 | if(string.IsNullOrEmpty(m_RootNamespace)) | ||
512 | { | ||
513 | m_RootNamespace = m_Name; | ||
514 | } | ||
515 | |||
516 | m_FullPath = m_Path; | ||
517 | try | ||
518 | { | ||
519 | m_FullPath = Helper.ResolvePath(m_FullPath); | ||
520 | } | ||
521 | catch | ||
522 | { | ||
523 | throw new WarningException("Could not resolve Solution path: {0}", m_Path); | ||
524 | } | ||
525 | |||
526 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
527 | try | ||
528 | { | ||
529 | Helper.SetCurrentDir(m_FullPath); | ||
530 | |||
531 | if( node == null ) | ||
532 | { | ||
533 | throw new ArgumentNullException("node"); | ||
534 | } | ||
535 | |||
536 | foreach(XmlNode child in node.ChildNodes) | ||
537 | { | ||
538 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
539 | if(dataNode is ConfigurationNode) | ||
540 | { | ||
541 | HandleConfiguration((ConfigurationNode)dataNode); | ||
542 | } | ||
543 | else if(dataNode is ReferencePathNode) | ||
544 | { | ||
545 | m_ReferencePaths.Add((ReferencePathNode)dataNode); | ||
546 | } | ||
547 | else if(dataNode is ReferenceNode) | ||
548 | { | ||
549 | m_References.Add((ReferenceNode)dataNode); | ||
550 | } | ||
551 | else if(dataNode is AuthorNode) | ||
552 | { | ||
553 | m_Authors.Add((AuthorNode)dataNode); | ||
554 | } | ||
555 | else if(dataNode is FilesNode) | ||
556 | { | ||
557 | m_Files = (FilesNode)dataNode; | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | finally | ||
562 | { | ||
563 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
564 | } | ||
565 | } | ||
566 | |||
567 | #endregion | ||
568 | |||
569 | #region IComparable Members | ||
570 | |||
571 | public int CompareTo(object obj) | ||
572 | { | ||
573 | ProjectNode that = (ProjectNode)obj; | ||
574 | return m_Name.CompareTo(that.m_Name); | ||
575 | } | ||
576 | |||
577 | #endregion | ||
578 | } | ||
579 | } | ||