diff options
Diffstat (limited to 'Prebuild/src/Core/Nodes')
-rw-r--r-- | Prebuild/src/Core/Nodes/ConfigurationNode.cs | 187 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/DataNode.cs | 82 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/ExcludeNode.cs | 85 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/FileNode.cs | 238 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/FilesNode.cs | 223 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/MatchNode.cs | 299 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/OptionsNode.cs | 655 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/ProcessNode.cs | 119 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/ProjectNode.cs | 510 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/ReferenceNode.cs | 153 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/ReferencePathNode.cs | 108 | ||||
-rw-r--r-- | Prebuild/src/Core/Nodes/SolutionNode.cs | 288 |
12 files changed, 2947 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs new file mode 100644 index 0000000..390794f --- /dev/null +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs | |||
@@ -0,0 +1,187 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Xml; | ||
37 | |||
38 | using Prebuild.Core.Attributes; | ||
39 | using Prebuild.Core.Interfaces; | ||
40 | using Prebuild.Core.Utilities; | ||
41 | |||
42 | namespace Prebuild.Core.Nodes | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | [DataNode("Configuration")] | ||
48 | public class ConfigurationNode : DataNode, ICloneable, IComparable | ||
49 | { | ||
50 | #region Fields | ||
51 | |||
52 | private string m_Name = "unknown"; | ||
53 | private OptionsNode m_Options; | ||
54 | |||
55 | #endregion | ||
56 | |||
57 | #region Constructors | ||
58 | |||
59 | /// <summary> | ||
60 | /// Initializes a new instance of the <see cref="ConfigurationNode"/> class. | ||
61 | /// </summary> | ||
62 | public ConfigurationNode() | ||
63 | { | ||
64 | m_Options = new OptionsNode(); | ||
65 | } | ||
66 | |||
67 | #endregion | ||
68 | |||
69 | #region Properties | ||
70 | |||
71 | /// <summary> | ||
72 | /// Gets or sets the parent. | ||
73 | /// </summary> | ||
74 | /// <value>The parent.</value> | ||
75 | public override IDataNode Parent | ||
76 | { | ||
77 | get | ||
78 | { | ||
79 | return base.Parent; | ||
80 | } | ||
81 | set | ||
82 | { | ||
83 | base.Parent = value; | ||
84 | if(base.Parent is SolutionNode) | ||
85 | { | ||
86 | SolutionNode node = (SolutionNode)base.Parent; | ||
87 | if(node != null && node.Options != null) | ||
88 | { | ||
89 | node.Options.CopyTo(m_Options); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Gets the name. | ||
97 | /// </summary> | ||
98 | /// <value>The name.</value> | ||
99 | public string Name | ||
100 | { | ||
101 | get | ||
102 | { | ||
103 | return m_Name; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// Gets or sets the options. | ||
109 | /// </summary> | ||
110 | /// <value>The options.</value> | ||
111 | public OptionsNode Options | ||
112 | { | ||
113 | get | ||
114 | { | ||
115 | return m_Options; | ||
116 | } | ||
117 | set | ||
118 | { | ||
119 | m_Options = value; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | #endregion | ||
124 | |||
125 | #region Public Methods | ||
126 | |||
127 | /// <summary> | ||
128 | /// Parses the specified node. | ||
129 | /// </summary> | ||
130 | /// <param name="node">The node.</param> | ||
131 | public override void Parse(XmlNode node) | ||
132 | { | ||
133 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
134 | if( node == null ) | ||
135 | { | ||
136 | throw new ArgumentNullException("node"); | ||
137 | } | ||
138 | foreach(XmlNode child in node.ChildNodes) | ||
139 | { | ||
140 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
141 | if(dataNode is OptionsNode) | ||
142 | { | ||
143 | ((OptionsNode)dataNode).CopyTo(m_Options); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Copies to. | ||
150 | /// </summary> | ||
151 | /// <param name="conf">The conf.</param> | ||
152 | public void CopyTo(ConfigurationNode conf) | ||
153 | { | ||
154 | m_Options.CopyTo(conf.m_Options); | ||
155 | } | ||
156 | |||
157 | #endregion | ||
158 | |||
159 | #region ICloneable Members | ||
160 | |||
161 | /// <summary> | ||
162 | /// Creates a new object that is a copy of the current instance. | ||
163 | /// </summary> | ||
164 | /// <returns> | ||
165 | /// A new object that is a copy of this instance. | ||
166 | /// </returns> | ||
167 | public object Clone() | ||
168 | { | ||
169 | ConfigurationNode ret = new ConfigurationNode(); | ||
170 | ret.m_Name = m_Name; | ||
171 | m_Options.CopyTo(ret.m_Options); | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | #endregion | ||
176 | |||
177 | #region IComparable Members | ||
178 | |||
179 | public int CompareTo(object obj) | ||
180 | { | ||
181 | ConfigurationNode that = (ConfigurationNode) obj; | ||
182 | return this.m_Name.CompareTo(that.m_Name); | ||
183 | } | ||
184 | |||
185 | #endregion | ||
186 | } | ||
187 | } | ||
diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs new file mode 100644 index 0000000..ef5f7ee --- /dev/null +++ b/Prebuild/src/Core/Nodes/DataNode.cs | |||
@@ -0,0 +1,82 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Xml; | ||
37 | |||
38 | using Prebuild.Core.Attributes; | ||
39 | using Prebuild.Core.Interfaces; | ||
40 | |||
41 | namespace Prebuild.Core.Nodes | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// | ||
45 | /// </summary> | ||
46 | public class DataNode : IDataNode | ||
47 | { | ||
48 | #region Fields | ||
49 | |||
50 | private IDataNode parent; | ||
51 | |||
52 | #endregion | ||
53 | |||
54 | #region IDataNode Members | ||
55 | |||
56 | /// <summary> | ||
57 | /// Gets or sets the parent. | ||
58 | /// </summary> | ||
59 | /// <value>The parent.</value> | ||
60 | public virtual IDataNode Parent | ||
61 | { | ||
62 | get | ||
63 | { | ||
64 | return parent; | ||
65 | } | ||
66 | set | ||
67 | { | ||
68 | parent = value; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Parses the specified node. | ||
74 | /// </summary> | ||
75 | /// <param name="node">The node.</param> | ||
76 | public virtual void Parse(XmlNode node) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | #endregion | ||
81 | } | ||
82 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs new file mode 100644 index 0000000..bfcebca --- /dev/null +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs | |||
@@ -0,0 +1,85 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-01-31 16:35:39 +0100 (ti, 31 jan 2006) $ | ||
31 | * $Revision: 74 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Xml; | ||
37 | |||
38 | using Prebuild.Core.Attributes; | ||
39 | using Prebuild.Core.Interfaces; | ||
40 | using Prebuild.Core.Utilities; | ||
41 | |||
42 | namespace Prebuild.Core.Nodes | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | [DataNode("Exclude")] | ||
48 | public class ExcludeNode : DataNode | ||
49 | { | ||
50 | #region Fields | ||
51 | |||
52 | private string m_Name = "unknown"; | ||
53 | |||
54 | #endregion | ||
55 | |||
56 | #region Properties | ||
57 | |||
58 | /// <summary> | ||
59 | /// Gets the name. | ||
60 | /// </summary> | ||
61 | /// <value>The name.</value> | ||
62 | public string Name | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | return m_Name; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | #endregion | ||
71 | |||
72 | #region Public Methods | ||
73 | |||
74 | /// <summary> | ||
75 | /// Parses the specified node. | ||
76 | /// </summary> | ||
77 | /// <param name="node">The node.</param> | ||
78 | public override void Parse(XmlNode node) | ||
79 | { | ||
80 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
81 | } | ||
82 | |||
83 | #endregion | ||
84 | } | ||
85 | } | ||
diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs new file mode 100644 index 0000000..de3b69e --- /dev/null +++ b/Prebuild/src/Core/Nodes/FileNode.cs | |||
@@ -0,0 +1,238 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ | ||
31 | * $Revision: 197 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.IO; | ||
37 | using System.Xml; | ||
38 | |||
39 | using Prebuild.Core.Attributes; | ||
40 | using Prebuild.Core.Interfaces; | ||
41 | using Prebuild.Core.Utilities; | ||
42 | |||
43 | namespace Prebuild.Core.Nodes | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// | ||
47 | /// </summary> | ||
48 | public enum BuildAction | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// | ||
52 | /// </summary> | ||
53 | None, | ||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | Compile, | ||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | Content, | ||
62 | /// <summary> | ||
63 | /// | ||
64 | /// </summary> | ||
65 | EmbeddedResource | ||
66 | } | ||
67 | |||
68 | /// <summary> | ||
69 | /// | ||
70 | /// </summary> | ||
71 | public enum SubType | ||
72 | { | ||
73 | /// <summary> | ||
74 | /// | ||
75 | /// </summary> | ||
76 | Code, | ||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | Component, | ||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | Designer, | ||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | ||
88 | Form, | ||
89 | /// <summary> | ||
90 | /// | ||
91 | /// </summary> | ||
92 | Settings, | ||
93 | /// <summary> | ||
94 | /// | ||
95 | /// </summary> | ||
96 | UserControl | ||
97 | } | ||
98 | |||
99 | public enum CopyToOutput | ||
100 | { | ||
101 | Never, | ||
102 | Always, | ||
103 | PreserveNewest | ||
104 | } | ||
105 | |||
106 | /// <summary> | ||
107 | /// | ||
108 | /// </summary> | ||
109 | [DataNode("File")] | ||
110 | public class FileNode : DataNode | ||
111 | { | ||
112 | #region Fields | ||
113 | |||
114 | private string m_Path; | ||
115 | private string m_ResourceName = ""; | ||
116 | private BuildAction m_BuildAction = BuildAction.Compile; | ||
117 | private bool m_Valid; | ||
118 | private SubType m_SubType = SubType.Code; | ||
119 | private CopyToOutput m_CopyToOutput = CopyToOutput.Never; | ||
120 | private bool m_Link = false; | ||
121 | |||
122 | |||
123 | #endregion | ||
124 | |||
125 | #region Properties | ||
126 | |||
127 | /// <summary> | ||
128 | /// | ||
129 | /// </summary> | ||
130 | public string Path | ||
131 | { | ||
132 | get | ||
133 | { | ||
134 | return m_Path; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | /// <summary> | ||
139 | /// | ||
140 | /// </summary> | ||
141 | public string ResourceName | ||
142 | { | ||
143 | get | ||
144 | { | ||
145 | return m_ResourceName; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// | ||
151 | /// </summary> | ||
152 | public BuildAction BuildAction | ||
153 | { | ||
154 | get | ||
155 | { | ||
156 | return m_BuildAction; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | public CopyToOutput CopyToOutput | ||
161 | { | ||
162 | get | ||
163 | { | ||
164 | return this.m_CopyToOutput; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | public bool IsLink | ||
169 | { | ||
170 | get | ||
171 | { | ||
172 | return this.m_Link; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | /// <summary> | ||
177 | /// | ||
178 | /// </summary> | ||
179 | public SubType SubType | ||
180 | { | ||
181 | get | ||
182 | { | ||
183 | return m_SubType; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// | ||
189 | /// </summary> | ||
190 | public bool IsValid | ||
191 | { | ||
192 | get | ||
193 | { | ||
194 | return m_Valid; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | #region Public Methods | ||
201 | |||
202 | /// <summary> | ||
203 | /// | ||
204 | /// </summary> | ||
205 | /// <param name="node"></param> | ||
206 | public override void Parse(XmlNode node) | ||
207 | { | ||
208 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), | ||
209 | Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); | ||
210 | m_SubType = (SubType)Enum.Parse(typeof(SubType), | ||
211 | Helper.AttributeValue(node, "subType", m_SubType.ToString())); | ||
212 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | ||
213 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | ||
214 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | ||
215 | |||
216 | if( node == null ) | ||
217 | { | ||
218 | throw new ArgumentNullException("node"); | ||
219 | } | ||
220 | |||
221 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
222 | if(m_Path == null) | ||
223 | { | ||
224 | m_Path = ""; | ||
225 | } | ||
226 | |||
227 | m_Path = m_Path.Trim(); | ||
228 | m_Valid = true; | ||
229 | if(!File.Exists(m_Path)) | ||
230 | { | ||
231 | m_Valid = false; | ||
232 | Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | #endregion | ||
237 | } | ||
238 | } | ||
diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs new file mode 100644 index 0000000..d31307b --- /dev/null +++ b/Prebuild/src/Core/Nodes/FilesNode.cs | |||
@@ -0,0 +1,223 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ | ||
31 | * $Revision: 164 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.Xml; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | |||
43 | namespace Prebuild.Core.Nodes | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// | ||
47 | /// </summary> | ||
48 | [DataNode("Files")] | ||
49 | public class FilesNode : DataNode | ||
50 | { | ||
51 | #region Fields | ||
52 | |||
53 | private StringCollection m_Files; | ||
54 | private Hashtable m_BuildActions; | ||
55 | private Hashtable m_SubTypes; | ||
56 | private Hashtable m_ResourceNames; | ||
57 | private Hashtable m_CopyToOutputs; | ||
58 | private Hashtable m_Links; | ||
59 | |||
60 | |||
61 | #endregion | ||
62 | |||
63 | #region Constructors | ||
64 | |||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | public FilesNode() | ||
69 | { | ||
70 | m_Files = new StringCollection(); | ||
71 | m_BuildActions = new Hashtable(); | ||
72 | m_SubTypes = new Hashtable(); | ||
73 | m_ResourceNames = new Hashtable(); | ||
74 | m_CopyToOutputs = new Hashtable(); | ||
75 | m_Links = new Hashtable(); | ||
76 | } | ||
77 | |||
78 | #endregion | ||
79 | |||
80 | #region Properties | ||
81 | |||
82 | /// <summary> | ||
83 | /// | ||
84 | /// </summary> | ||
85 | public int Count | ||
86 | { | ||
87 | get | ||
88 | { | ||
89 | return m_Files.Count; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | #endregion | ||
94 | |||
95 | #region Public Methods | ||
96 | |||
97 | /// <summary> | ||
98 | /// | ||
99 | /// </summary> | ||
100 | /// <param name="file"></param> | ||
101 | /// <returns></returns> | ||
102 | public BuildAction GetBuildAction(string file) | ||
103 | { | ||
104 | if(!m_BuildActions.ContainsKey(file)) | ||
105 | { | ||
106 | return BuildAction.Compile; | ||
107 | } | ||
108 | |||
109 | return (BuildAction)m_BuildActions[file]; | ||
110 | } | ||
111 | |||
112 | public CopyToOutput GetCopyToOutput(string file) | ||
113 | { | ||
114 | if (!this.m_CopyToOutputs.ContainsKey(file)) | ||
115 | { | ||
116 | return CopyToOutput.Never; | ||
117 | } | ||
118 | return (CopyToOutput) this.m_CopyToOutputs[file]; | ||
119 | } | ||
120 | |||
121 | public bool GetIsLink(string file) | ||
122 | { | ||
123 | if (!this.m_Links.ContainsKey(file)) | ||
124 | { | ||
125 | return false; | ||
126 | } | ||
127 | return (bool) this.m_Links[file]; | ||
128 | } | ||
129 | |||
130 | /// <summary> | ||
131 | /// | ||
132 | /// </summary> | ||
133 | /// <param name="file"></param> | ||
134 | /// <returns></returns> | ||
135 | public SubType GetSubType(string file) | ||
136 | { | ||
137 | if(!m_SubTypes.ContainsKey(file)) | ||
138 | { | ||
139 | return SubType.Code; | ||
140 | } | ||
141 | |||
142 | return (SubType)m_SubTypes[file]; | ||
143 | } | ||
144 | |||
145 | /// <summary> | ||
146 | /// | ||
147 | /// </summary> | ||
148 | /// <param name="file"></param> | ||
149 | /// <returns></returns> | ||
150 | public string GetResourceName(string file) | ||
151 | { | ||
152 | if(!m_ResourceNames.ContainsKey(file)) | ||
153 | { | ||
154 | return ""; | ||
155 | } | ||
156 | |||
157 | return (string)m_ResourceNames[file]; | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// | ||
162 | /// </summary> | ||
163 | /// <param name="node"></param> | ||
164 | public override void Parse(XmlNode node) | ||
165 | { | ||
166 | if( node == null ) | ||
167 | { | ||
168 | throw new ArgumentNullException("node"); | ||
169 | } | ||
170 | foreach(XmlNode child in node.ChildNodes) | ||
171 | { | ||
172 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
173 | if(dataNode is FileNode) | ||
174 | { | ||
175 | FileNode fileNode = (FileNode)dataNode; | ||
176 | if(fileNode.IsValid) | ||
177 | { | ||
178 | if (!m_Files.Contains(fileNode.Path)) | ||
179 | { | ||
180 | m_Files.Add(fileNode.Path); | ||
181 | m_BuildActions[fileNode.Path] = fileNode.BuildAction; | ||
182 | m_SubTypes[fileNode.Path] = fileNode.SubType; | ||
183 | m_ResourceNames[fileNode.Path] = fileNode.ResourceName; | ||
184 | this.m_Links[fileNode.Path] = fileNode.IsLink; | ||
185 | this.m_CopyToOutputs[fileNode.Path] = fileNode.CopyToOutput; | ||
186 | |||
187 | } | ||
188 | } | ||
189 | } | ||
190 | else if(dataNode is MatchNode) | ||
191 | { | ||
192 | foreach(string file in ((MatchNode)dataNode).Files) | ||
193 | { | ||
194 | if (!m_Files.Contains(file)) | ||
195 | { | ||
196 | m_Files.Add(file); | ||
197 | m_BuildActions[file] = ((MatchNode)dataNode).BuildAction; | ||
198 | m_SubTypes[file] = ((MatchNode)dataNode).SubType; | ||
199 | m_ResourceNames[file] = ((MatchNode)dataNode).ResourceName; | ||
200 | this.m_Links[file] = ((MatchNode) dataNode).IsLink; | ||
201 | this.m_CopyToOutputs[file] = ((MatchNode) dataNode).CopyToOutput; | ||
202 | |||
203 | } | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | // TODO: Check in to why StringCollection's enumerator doesn't implement | ||
210 | // IEnumerator? | ||
211 | /// <summary> | ||
212 | /// | ||
213 | /// </summary> | ||
214 | /// <returns></returns> | ||
215 | public StringEnumerator GetEnumerator() | ||
216 | { | ||
217 | return m_Files.GetEnumerator(); | ||
218 | } | ||
219 | |||
220 | #endregion | ||
221 | |||
222 | } | ||
223 | } | ||
diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs new file mode 100644 index 0000000..e0d2fa8 --- /dev/null +++ b/Prebuild/src/Core/Nodes/MatchNode.cs | |||
@@ -0,0 +1,299 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ | ||
31 | * $Revision: 164 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections.Specialized; | ||
37 | using System.IO; | ||
38 | using System.Text.RegularExpressions; | ||
39 | using System.Xml; | ||
40 | |||
41 | using Prebuild.Core.Attributes; | ||
42 | using Prebuild.Core.Interfaces; | ||
43 | using Prebuild.Core.Utilities; | ||
44 | |||
45 | namespace Prebuild.Core.Nodes | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | [DataNode("Match")] | ||
51 | public class MatchNode : DataNode | ||
52 | { | ||
53 | #region Fields | ||
54 | |||
55 | private StringCollection m_Files; | ||
56 | private Regex m_Regex; | ||
57 | private BuildAction m_BuildAction = BuildAction.Compile; | ||
58 | private SubType m_SubType = SubType.Code; | ||
59 | string m_ResourceName = ""; | ||
60 | private CopyToOutput m_CopyToOutput; | ||
61 | private bool m_Link; | ||
62 | |||
63 | |||
64 | #endregion | ||
65 | |||
66 | #region Constructors | ||
67 | |||
68 | /// <summary> | ||
69 | /// | ||
70 | /// </summary> | ||
71 | public MatchNode() | ||
72 | { | ||
73 | m_Files = new StringCollection(); | ||
74 | } | ||
75 | |||
76 | #endregion | ||
77 | |||
78 | #region Properties | ||
79 | |||
80 | /// <summary> | ||
81 | /// | ||
82 | /// </summary> | ||
83 | public StringCollection Files | ||
84 | { | ||
85 | get | ||
86 | { | ||
87 | return m_Files; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// | ||
93 | /// </summary> | ||
94 | public BuildAction BuildAction | ||
95 | { | ||
96 | get | ||
97 | { | ||
98 | return m_BuildAction; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | /// <summary> | ||
103 | /// | ||
104 | /// </summary> | ||
105 | public SubType SubType | ||
106 | { | ||
107 | get | ||
108 | { | ||
109 | return m_SubType; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public CopyToOutput CopyToOutput | ||
114 | { | ||
115 | get | ||
116 | { | ||
117 | return this.m_CopyToOutput; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | public bool IsLink | ||
122 | { | ||
123 | get | ||
124 | { | ||
125 | return this.m_Link; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// | ||
131 | /// </summary> | ||
132 | public string ResourceName | ||
133 | { | ||
134 | get | ||
135 | { | ||
136 | return m_ResourceName; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | |||
141 | #endregion | ||
142 | |||
143 | #region Private Methods | ||
144 | |||
145 | /// <summary> | ||
146 | /// Recurses the directories. | ||
147 | /// </summary> | ||
148 | /// <param name="path">The path.</param> | ||
149 | /// <param name="pattern">The pattern.</param> | ||
150 | /// <param name="recurse">if set to <c>true</c> [recurse].</param> | ||
151 | /// <param name="useRegex">if set to <c>true</c> [use regex].</param> | ||
152 | private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex) | ||
153 | { | ||
154 | try | ||
155 | { | ||
156 | string[] files; | ||
157 | |||
158 | if(!useRegex) | ||
159 | { | ||
160 | files = Directory.GetFiles(path, pattern); | ||
161 | if(files != null) | ||
162 | { | ||
163 | string fileTemp; | ||
164 | foreach (string file in files) | ||
165 | { | ||
166 | if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") | ||
167 | { | ||
168 | fileTemp = file.Substring(2); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | fileTemp = file; | ||
173 | } | ||
174 | |||
175 | m_Files.Add(fileTemp); | ||
176 | } | ||
177 | } | ||
178 | else | ||
179 | { | ||
180 | return; | ||
181 | } | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | Match match; | ||
186 | files = Directory.GetFiles(path); | ||
187 | foreach(string file in files) | ||
188 | { | ||
189 | match = m_Regex.Match(file); | ||
190 | if(match.Success) | ||
191 | { | ||
192 | m_Files.Add(file); | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | if(recurse) | ||
198 | { | ||
199 | string[] dirs = Directory.GetDirectories(path); | ||
200 | if(dirs != null && dirs.Length > 0) | ||
201 | { | ||
202 | foreach(string str in dirs) | ||
203 | { | ||
204 | RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | catch(DirectoryNotFoundException) | ||
210 | { | ||
211 | return; | ||
212 | } | ||
213 | catch(ArgumentException) | ||
214 | { | ||
215 | return; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | #endregion | ||
220 | |||
221 | #region Public Methods | ||
222 | |||
223 | /// <summary> | ||
224 | /// | ||
225 | /// </summary> | ||
226 | /// <param name="node"></param> | ||
227 | public override void Parse(XmlNode node) | ||
228 | { | ||
229 | if( node == null ) | ||
230 | { | ||
231 | throw new ArgumentNullException("node"); | ||
232 | } | ||
233 | string path = Helper.AttributeValue(node, "path", "."); | ||
234 | string pattern = Helper.AttributeValue(node, "pattern", "*"); | ||
235 | bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); | ||
236 | bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); | ||
237 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), | ||
238 | Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); | ||
239 | m_SubType = (SubType)Enum.Parse(typeof(SubType), | ||
240 | Helper.AttributeValue(node, "subType", m_SubType.ToString())); | ||
241 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | ||
242 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | ||
243 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | ||
244 | |||
245 | |||
246 | if(path != null && path.Length == 0) | ||
247 | { | ||
248 | path = ".";//use current directory | ||
249 | } | ||
250 | //throw new WarningException("Match must have a 'path' attribute"); | ||
251 | |||
252 | if(pattern == null) | ||
253 | { | ||
254 | throw new WarningException("Match must have a 'pattern' attribute"); | ||
255 | } | ||
256 | |||
257 | path = Helper.NormalizePath(path); | ||
258 | if(!Directory.Exists(path)) | ||
259 | { | ||
260 | throw new WarningException("Match path does not exist: {0}", path); | ||
261 | } | ||
262 | |||
263 | try | ||
264 | { | ||
265 | if(useRegex) | ||
266 | { | ||
267 | m_Regex = new Regex(pattern); | ||
268 | } | ||
269 | } | ||
270 | catch(ArgumentException ex) | ||
271 | { | ||
272 | throw new WarningException("Could not compile regex pattern: {0}", ex.Message); | ||
273 | } | ||
274 | |||
275 | RecurseDirectories(path, pattern, recurse, useRegex); | ||
276 | |||
277 | foreach(XmlNode child in node.ChildNodes) | ||
278 | { | ||
279 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
280 | if(dataNode is ExcludeNode) | ||
281 | { | ||
282 | ExcludeNode excludeNode = (ExcludeNode)dataNode; | ||
283 | if (m_Files.Contains(Helper.NormalizePath(excludeNode.Name))) | ||
284 | { | ||
285 | m_Files.Remove(Helper.NormalizePath(excludeNode.Name)); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | |||
290 | if(m_Files.Count < 1) | ||
291 | { | ||
292 | throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); | ||
293 | } | ||
294 | m_Regex = null; | ||
295 | } | ||
296 | |||
297 | #endregion | ||
298 | } | ||
299 | } | ||
diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs new file mode 100644 index 0000000..b5a2f60 --- /dev/null +++ b/Prebuild/src/Core/Nodes/OptionsNode.cs | |||
@@ -0,0 +1,655 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ | ||
31 | * $Revision: 197 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | |||
36 | |||
37 | using System; | ||
38 | using System.Collections; | ||
39 | using System.Collections.Specialized; | ||
40 | using System.Reflection; | ||
41 | using System.Xml; | ||
42 | |||
43 | using Prebuild.Core.Attributes; | ||
44 | using Prebuild.Core.Interfaces; | ||
45 | using Prebuild.Core.Utilities; | ||
46 | |||
47 | namespace Prebuild.Core.Nodes | ||
48 | { | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | [DataNode("Options")] | ||
53 | public class OptionsNode : DataNode | ||
54 | { | ||
55 | #region Fields | ||
56 | |||
57 | private static Hashtable m_OptionFields; | ||
58 | |||
59 | [OptionNode("CompilerDefines")] | ||
60 | private string m_CompilerDefines = ""; | ||
61 | |||
62 | /// <summary> | ||
63 | /// | ||
64 | /// </summary> | ||
65 | public string CompilerDefines | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | return m_CompilerDefines; | ||
70 | } | ||
71 | set | ||
72 | { | ||
73 | m_CompilerDefines = value; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | [OptionNode("OptimizeCode")] | ||
78 | private bool m_OptimizeCode; | ||
79 | |||
80 | /// <summary> | ||
81 | /// | ||
82 | /// </summary> | ||
83 | public bool OptimizeCode | ||
84 | { | ||
85 | get | ||
86 | { | ||
87 | return m_OptimizeCode; | ||
88 | } | ||
89 | set | ||
90 | { | ||
91 | m_OptimizeCode = value; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | [OptionNode("CheckUnderflowOverflow")] | ||
96 | private bool m_CheckUnderflowOverflow; | ||
97 | |||
98 | /// <summary> | ||
99 | /// | ||
100 | /// </summary> | ||
101 | public bool CheckUnderflowOverflow | ||
102 | { | ||
103 | get | ||
104 | { | ||
105 | return m_CheckUnderflowOverflow; | ||
106 | } | ||
107 | set | ||
108 | { | ||
109 | m_CheckUnderflowOverflow = value; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | [OptionNode("AllowUnsafe")] | ||
114 | private bool m_AllowUnsafe; | ||
115 | |||
116 | /// <summary> | ||
117 | /// | ||
118 | /// </summary> | ||
119 | public bool AllowUnsafe | ||
120 | { | ||
121 | get | ||
122 | { | ||
123 | return m_AllowUnsafe; | ||
124 | } | ||
125 | set | ||
126 | { | ||
127 | m_AllowUnsafe = value; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | [OptionNode("PreBuildEvent")] | ||
132 | private string m_PreBuildEvent; | ||
133 | |||
134 | /// <summary> | ||
135 | /// | ||
136 | /// </summary> | ||
137 | public string PreBuildEvent | ||
138 | { | ||
139 | get | ||
140 | { | ||
141 | return m_PreBuildEvent; | ||
142 | } | ||
143 | set | ||
144 | { | ||
145 | m_PreBuildEvent = value; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | [OptionNode("PostBuildEvent")] | ||
150 | private string m_PostBuildEvent; | ||
151 | |||
152 | /// <summary> | ||
153 | /// | ||
154 | /// </summary> | ||
155 | public string PostBuildEvent | ||
156 | { | ||
157 | get | ||
158 | { | ||
159 | return m_PostBuildEvent; | ||
160 | } | ||
161 | set | ||
162 | { | ||
163 | m_PostBuildEvent = value; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | [OptionNode("PreBuildEventArgs")] | ||
168 | private string m_PreBuildEventArgs; | ||
169 | |||
170 | /// <summary> | ||
171 | /// | ||
172 | /// </summary> | ||
173 | public string PreBuildEventArgs | ||
174 | { | ||
175 | get | ||
176 | { | ||
177 | return m_PreBuildEventArgs; | ||
178 | } | ||
179 | set | ||
180 | { | ||
181 | m_PreBuildEventArgs = value; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | [OptionNode("PostBuildEventArgs")] | ||
186 | private string m_PostBuildEventArgs; | ||
187 | |||
188 | /// <summary> | ||
189 | /// | ||
190 | /// </summary> | ||
191 | public string PostBuildEventArgs | ||
192 | { | ||
193 | get | ||
194 | { | ||
195 | return m_PostBuildEventArgs; | ||
196 | } | ||
197 | set | ||
198 | { | ||
199 | m_PostBuildEventArgs = value; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | [OptionNode("RunPostBuildEvent")] | ||
204 | private string m_RunPostBuildEvent; | ||
205 | |||
206 | /// <summary> | ||
207 | /// | ||
208 | /// </summary> | ||
209 | public string RunPostBuildEvent | ||
210 | { | ||
211 | get | ||
212 | { | ||
213 | return m_RunPostBuildEvent; | ||
214 | } | ||
215 | set | ||
216 | { | ||
217 | m_RunPostBuildEvent = value; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | [OptionNode("RunScript")] | ||
222 | private string m_RunScript; | ||
223 | |||
224 | /// <summary> | ||
225 | /// | ||
226 | /// </summary> | ||
227 | public string RunScript | ||
228 | { | ||
229 | get | ||
230 | { | ||
231 | return m_RunScript; | ||
232 | } | ||
233 | set | ||
234 | { | ||
235 | m_RunScript = value; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | [OptionNode("WarningLevel")] | ||
240 | private int m_WarningLevel = 4; | ||
241 | |||
242 | /// <summary> | ||
243 | /// | ||
244 | /// </summary> | ||
245 | public int WarningLevel | ||
246 | { | ||
247 | get | ||
248 | { | ||
249 | return m_WarningLevel; | ||
250 | } | ||
251 | set | ||
252 | { | ||
253 | m_WarningLevel = value; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | [OptionNode("WarningsAsErrors")] | ||
258 | private bool m_WarningsAsErrors; | ||
259 | |||
260 | /// <summary> | ||
261 | /// | ||
262 | /// </summary> | ||
263 | public bool WarningsAsErrors | ||
264 | { | ||
265 | get | ||
266 | { | ||
267 | return m_WarningsAsErrors; | ||
268 | } | ||
269 | set | ||
270 | { | ||
271 | m_WarningsAsErrors = value; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | [OptionNode("SuppressWarnings")] | ||
276 | private string m_SuppressWarnings = ""; | ||
277 | |||
278 | /// <summary> | ||
279 | /// | ||
280 | /// </summary> | ||
281 | public string SuppressWarnings | ||
282 | { | ||
283 | get | ||
284 | { | ||
285 | return m_SuppressWarnings; | ||
286 | } | ||
287 | set | ||
288 | { | ||
289 | m_SuppressWarnings = value; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | [OptionNode("OutputPath")] | ||
294 | private string m_OutputPath = "bin/"; | ||
295 | |||
296 | /// <summary> | ||
297 | /// | ||
298 | /// </summary> | ||
299 | public string OutputPath | ||
300 | { | ||
301 | get | ||
302 | { | ||
303 | return m_OutputPath; | ||
304 | } | ||
305 | set | ||
306 | { | ||
307 | m_OutputPath = value; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | [OptionNode("GenerateDocumentation")] | ||
312 | private bool m_GenerateDocumentation; | ||
313 | |||
314 | /// <summary> | ||
315 | /// | ||
316 | /// </summary> | ||
317 | public bool GenerateDocumentation | ||
318 | { | ||
319 | get | ||
320 | { | ||
321 | return m_GenerateDocumentation; | ||
322 | } | ||
323 | set | ||
324 | { | ||
325 | m_GenerateDocumentation = value; | ||
326 | } | ||
327 | } | ||
328 | |||
329 | [OptionNode("GenerateXmlDocFile")] | ||
330 | private bool m_GenerateXmlDocFile; | ||
331 | |||
332 | /// <summary> | ||
333 | /// | ||
334 | /// </summary> | ||
335 | public bool GenerateXmlDocFile | ||
336 | { | ||
337 | get | ||
338 | { | ||
339 | return m_GenerateXmlDocFile; | ||
340 | } | ||
341 | set | ||
342 | { | ||
343 | m_GenerateXmlDocFile = value; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | [OptionNode("XmlDocFile")] | ||
348 | private string m_XmlDocFile = ""; | ||
349 | |||
350 | /// <summary> | ||
351 | /// | ||
352 | /// </summary> | ||
353 | public string XmlDocFile | ||
354 | { | ||
355 | get | ||
356 | { | ||
357 | return m_XmlDocFile; | ||
358 | } | ||
359 | set | ||
360 | { | ||
361 | m_XmlDocFile = value; | ||
362 | } | ||
363 | } | ||
364 | |||
365 | [OptionNode("KeyFile")] | ||
366 | private string m_KeyFile = ""; | ||
367 | |||
368 | /// <summary> | ||
369 | /// | ||
370 | /// </summary> | ||
371 | public string KeyFile | ||
372 | { | ||
373 | get | ||
374 | { | ||
375 | return m_KeyFile; | ||
376 | } | ||
377 | set | ||
378 | { | ||
379 | m_KeyFile = value; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | [OptionNode("DebugInformation")] | ||
384 | private bool m_DebugInformation; | ||
385 | |||
386 | /// <summary> | ||
387 | /// | ||
388 | /// </summary> | ||
389 | public bool DebugInformation | ||
390 | { | ||
391 | get | ||
392 | { | ||
393 | return m_DebugInformation; | ||
394 | } | ||
395 | set | ||
396 | { | ||
397 | m_DebugInformation = value; | ||
398 | } | ||
399 | } | ||
400 | |||
401 | [OptionNode("RegisterComInterop")] | ||
402 | private bool m_RegisterComInterop; | ||
403 | |||
404 | /// <summary> | ||
405 | /// | ||
406 | /// </summary> | ||
407 | public bool RegisterComInterop | ||
408 | { | ||
409 | get | ||
410 | { | ||
411 | return m_RegisterComInterop; | ||
412 | } | ||
413 | set | ||
414 | { | ||
415 | m_RegisterComInterop = value; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | [OptionNode("RemoveIntegerChecks")] | ||
420 | private bool m_RemoveIntegerChecks; | ||
421 | |||
422 | /// <summary> | ||
423 | /// | ||
424 | /// </summary> | ||
425 | public bool RemoveIntegerChecks | ||
426 | { | ||
427 | get | ||
428 | { | ||
429 | return m_RemoveIntegerChecks; | ||
430 | } | ||
431 | set | ||
432 | { | ||
433 | m_RemoveIntegerChecks = value; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | [OptionNode("IncrementalBuild")] | ||
438 | private bool m_IncrementalBuild; | ||
439 | |||
440 | /// <summary> | ||
441 | /// | ||
442 | /// </summary> | ||
443 | public bool IncrementalBuild | ||
444 | { | ||
445 | get | ||
446 | { | ||
447 | return m_IncrementalBuild; | ||
448 | } | ||
449 | set | ||
450 | { | ||
451 | m_IncrementalBuild = value; | ||
452 | } | ||
453 | } | ||
454 | |||
455 | [OptionNode("BaseAddress")] | ||
456 | private string m_BaseAddress = "285212672"; | ||
457 | |||
458 | /// <summary> | ||
459 | /// | ||
460 | /// </summary> | ||
461 | public string BaseAddress | ||
462 | { | ||
463 | get | ||
464 | { | ||
465 | return m_BaseAddress; | ||
466 | } | ||
467 | set | ||
468 | { | ||
469 | m_BaseAddress = value; | ||
470 | } | ||
471 | } | ||
472 | |||
473 | [OptionNode("FileAlignment")] | ||
474 | private int m_FileAlignment = 4096; | ||
475 | |||
476 | /// <summary> | ||
477 | /// | ||
478 | /// </summary> | ||
479 | public int FileAlignment | ||
480 | { | ||
481 | get | ||
482 | { | ||
483 | return m_FileAlignment; | ||
484 | } | ||
485 | set | ||
486 | { | ||
487 | m_FileAlignment = value; | ||
488 | } | ||
489 | } | ||
490 | |||
491 | [OptionNode("NoStdLib")] | ||
492 | private bool m_NoStdLib; | ||
493 | |||
494 | /// <summary> | ||
495 | /// | ||
496 | /// </summary> | ||
497 | public bool NoStdLib | ||
498 | { | ||
499 | get | ||
500 | { | ||
501 | return m_NoStdLib; | ||
502 | } | ||
503 | set | ||
504 | { | ||
505 | m_NoStdLib = value; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | private StringCollection m_FieldsDefined; | ||
510 | |||
511 | #endregion | ||
512 | |||
513 | #region Constructors | ||
514 | |||
515 | /// <summary> | ||
516 | /// Initializes the <see cref="OptionsNode"/> class. | ||
517 | /// </summary> | ||
518 | static OptionsNode() | ||
519 | { | ||
520 | Type t = typeof(OptionsNode); | ||
521 | |||
522 | m_OptionFields = new Hashtable(); | ||
523 | foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) | ||
524 | { | ||
525 | object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); | ||
526 | if(attrs == null || attrs.Length < 1) | ||
527 | { | ||
528 | continue; | ||
529 | } | ||
530 | |||
531 | OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; | ||
532 | m_OptionFields[ona.NodeName] = f; | ||
533 | } | ||
534 | } | ||
535 | |||
536 | /// <summary> | ||
537 | /// Initializes a new instance of the <see cref="OptionsNode"/> class. | ||
538 | /// </summary> | ||
539 | public OptionsNode() | ||
540 | { | ||
541 | m_FieldsDefined = new StringCollection(); | ||
542 | } | ||
543 | |||
544 | #endregion | ||
545 | |||
546 | #region Properties | ||
547 | |||
548 | /// <summary> | ||
549 | /// Gets the <see cref="Object"/> at the specified index. | ||
550 | /// </summary> | ||
551 | /// <value></value> | ||
552 | public object this[string index] | ||
553 | { | ||
554 | get | ||
555 | { | ||
556 | if(!m_OptionFields.ContainsKey(index)) | ||
557 | { | ||
558 | return null; | ||
559 | } | ||
560 | |||
561 | FieldInfo f = (FieldInfo)m_OptionFields[index]; | ||
562 | return f.GetValue(this); | ||
563 | } | ||
564 | } | ||
565 | |||
566 | /// <summary> | ||
567 | /// Gets the <see cref="Object"/> at the specified index. | ||
568 | /// </summary> | ||
569 | /// <value></value> | ||
570 | public object this[string index, object defaultValue] | ||
571 | { | ||
572 | get | ||
573 | { | ||
574 | object valueObject = this[index]; | ||
575 | if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) | ||
576 | { | ||
577 | return defaultValue; | ||
578 | } | ||
579 | return valueObject; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | |||
584 | #endregion | ||
585 | |||
586 | #region Private Methods | ||
587 | |||
588 | private void FlagDefined(string name) | ||
589 | { | ||
590 | if(!m_FieldsDefined.Contains(name)) | ||
591 | { | ||
592 | m_FieldsDefined.Add(name); | ||
593 | } | ||
594 | } | ||
595 | |||
596 | private void SetOption(string nodeName, string val) | ||
597 | { | ||
598 | lock(m_OptionFields) | ||
599 | { | ||
600 | if(!m_OptionFields.ContainsKey(nodeName)) | ||
601 | { | ||
602 | return; | ||
603 | } | ||
604 | |||
605 | FieldInfo f = (FieldInfo)m_OptionFields[nodeName]; | ||
606 | f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); | ||
607 | FlagDefined(f.Name); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | #endregion | ||
612 | |||
613 | #region Public Methods | ||
614 | |||
615 | /// <summary> | ||
616 | /// Parses the specified node. | ||
617 | /// </summary> | ||
618 | /// <param name="node">The node.</param> | ||
619 | public override void Parse(XmlNode node) | ||
620 | { | ||
621 | if( node == null ) | ||
622 | { | ||
623 | throw new ArgumentNullException("node"); | ||
624 | } | ||
625 | |||
626 | foreach(XmlNode child in node.ChildNodes) | ||
627 | { | ||
628 | SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); | ||
629 | } | ||
630 | } | ||
631 | |||
632 | /// <summary> | ||
633 | /// Copies to. | ||
634 | /// </summary> | ||
635 | /// <param name="opt">The opt.</param> | ||
636 | public void CopyTo(OptionsNode opt) | ||
637 | { | ||
638 | if(opt == null) | ||
639 | { | ||
640 | return; | ||
641 | } | ||
642 | |||
643 | foreach(FieldInfo f in m_OptionFields.Values) | ||
644 | { | ||
645 | if(m_FieldsDefined.Contains(f.Name)) | ||
646 | { | ||
647 | f.SetValue(opt, f.GetValue(this)); | ||
648 | opt.m_FieldsDefined.Add(f.Name); | ||
649 | } | ||
650 | } | ||
651 | } | ||
652 | |||
653 | #endregion | ||
654 | } | ||
655 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs new file mode 100644 index 0000000..f546a4b --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProcessNode.cs | |||
@@ -0,0 +1,119 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.Xml; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | using Prebuild.Core.Utilities; | ||
43 | |||
44 | namespace Prebuild.Core.Nodes | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// | ||
48 | /// </summary> | ||
49 | [DataNode("Process")] | ||
50 | public class ProcessNode : DataNode | ||
51 | { | ||
52 | #region Fields | ||
53 | |||
54 | private string m_Path; | ||
55 | private bool m_IsValid = true; | ||
56 | |||
57 | #endregion | ||
58 | |||
59 | #region Properties | ||
60 | |||
61 | /// <summary> | ||
62 | /// Gets the path. | ||
63 | /// </summary> | ||
64 | /// <value>The path.</value> | ||
65 | public string Path | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | return m_Path; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// Gets a value indicating whether this instance is valid. | ||
75 | /// </summary> | ||
76 | /// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value> | ||
77 | public bool IsValid | ||
78 | { | ||
79 | get | ||
80 | { | ||
81 | return m_IsValid; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | #endregion | ||
86 | |||
87 | #region Public Methods | ||
88 | |||
89 | /// <summary> | ||
90 | /// Parses the specified node. | ||
91 | /// </summary> | ||
92 | /// <param name="node">The node.</param> | ||
93 | public override void Parse(XmlNode node) | ||
94 | { | ||
95 | if( node == null ) | ||
96 | { | ||
97 | throw new ArgumentNullException("node"); | ||
98 | } | ||
99 | |||
100 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
101 | if(m_Path == null) | ||
102 | { | ||
103 | m_Path = ""; | ||
104 | } | ||
105 | |||
106 | try | ||
107 | { | ||
108 | m_Path = Helper.ResolvePath(m_Path); | ||
109 | } | ||
110 | catch(ArgumentException) | ||
111 | { | ||
112 | Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); | ||
113 | m_IsValid = false; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | #endregion | ||
118 | } | ||
119 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs new file mode 100644 index 0000000..c56dacc --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs | |||
@@ -0,0 +1,510 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-11-11 05:43:20 +0100 (lö, 11 nov 2006) $ | ||
31 | * $Revision: 192 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.IO; | ||
38 | using System.Xml; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | using Prebuild.Core.Utilities; | ||
43 | |||
44 | namespace Prebuild.Core.Nodes | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// | ||
48 | /// </summary> | ||
49 | public enum ProjectType | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// | ||
53 | /// </summary> | ||
54 | Exe, | ||
55 | /// <summary> | ||
56 | /// | ||
57 | /// </summary> | ||
58 | WinExe, | ||
59 | /// <summary> | ||
60 | /// | ||
61 | /// </summary> | ||
62 | Library | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | public enum ClrRuntime | ||
69 | { | ||
70 | /// <summary> | ||
71 | /// | ||
72 | /// </summary> | ||
73 | Microsoft, | ||
74 | /// <summary> | ||
75 | /// | ||
76 | /// </summary> | ||
77 | Mono | ||
78 | } | ||
79 | |||
80 | /// <summary> | ||
81 | /// | ||
82 | /// </summary> | ||
83 | [DataNode("Project")] | ||
84 | public class ProjectNode : DataNode, IComparable | ||
85 | { | ||
86 | #region Fields | ||
87 | |||
88 | private string m_Name = "unknown"; | ||
89 | private string m_Path = ""; | ||
90 | private string m_FullPath = ""; | ||
91 | private string m_AssemblyName; | ||
92 | private string m_AppIcon = ""; | ||
93 | private string m_DesignerFolder = ""; | ||
94 | private string m_Language = "C#"; | ||
95 | private ProjectType m_Type = ProjectType.Exe; | ||
96 | private ClrRuntime m_Runtime = ClrRuntime.Microsoft; | ||
97 | private string m_StartupObject = ""; | ||
98 | private string m_RootNamespace; | ||
99 | private string m_FilterGroups = ""; | ||
100 | private Guid m_Guid; | ||
101 | |||
102 | private Hashtable m_Configurations; | ||
103 | private ArrayList m_ReferencePaths; | ||
104 | private ArrayList m_References; | ||
105 | private FilesNode m_Files; | ||
106 | |||
107 | #endregion | ||
108 | |||
109 | #region Constructors | ||
110 | |||
111 | /// <summary> | ||
112 | /// Initializes a new instance of the <see cref="ProjectNode"/> class. | ||
113 | /// </summary> | ||
114 | public ProjectNode() | ||
115 | { | ||
116 | m_Configurations = new Hashtable(); | ||
117 | m_ReferencePaths = new ArrayList(); | ||
118 | m_References = new ArrayList(); | ||
119 | } | ||
120 | |||
121 | #endregion | ||
122 | |||
123 | #region Properties | ||
124 | |||
125 | /// <summary> | ||
126 | /// Gets the name. | ||
127 | /// </summary> | ||
128 | /// <value>The name.</value> | ||
129 | public string Name | ||
130 | { | ||
131 | get | ||
132 | { | ||
133 | return m_Name; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Gets the path. | ||
139 | /// </summary> | ||
140 | /// <value>The path.</value> | ||
141 | public string Path | ||
142 | { | ||
143 | get | ||
144 | { | ||
145 | return m_Path; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// Gets the filter groups. | ||
151 | /// </summary> | ||
152 | /// <value>The filter groups.</value> | ||
153 | public string FilterGroups | ||
154 | { | ||
155 | get | ||
156 | { | ||
157 | return m_FilterGroups; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | /// <summary> | ||
162 | /// Gets the full path. | ||
163 | /// </summary> | ||
164 | /// <value>The full path.</value> | ||
165 | public string FullPath | ||
166 | { | ||
167 | get | ||
168 | { | ||
169 | return m_FullPath; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Gets the name of the assembly. | ||
175 | /// </summary> | ||
176 | /// <value>The name of the assembly.</value> | ||
177 | public string AssemblyName | ||
178 | { | ||
179 | get | ||
180 | { | ||
181 | return m_AssemblyName; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | /// <summary> | ||
186 | /// Gets the app icon. | ||
187 | /// </summary> | ||
188 | /// <value>The app icon.</value> | ||
189 | public string AppIcon | ||
190 | { | ||
191 | get | ||
192 | { | ||
193 | return m_AppIcon; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | /// <summary> | ||
198 | /// | ||
199 | /// </summary> | ||
200 | public string DesignerFolder | ||
201 | { | ||
202 | get | ||
203 | { | ||
204 | return m_DesignerFolder; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | /// <summary> | ||
209 | /// Gets the language. | ||
210 | /// </summary> | ||
211 | /// <value>The language.</value> | ||
212 | public string Language | ||
213 | { | ||
214 | get | ||
215 | { | ||
216 | return m_Language; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | /// <summary> | ||
221 | /// Gets the type. | ||
222 | /// </summary> | ||
223 | /// <value>The type.</value> | ||
224 | public ProjectType Type | ||
225 | { | ||
226 | get | ||
227 | { | ||
228 | return m_Type; | ||
229 | } | ||
230 | } | ||
231 | |||
232 | /// <summary> | ||
233 | /// Gets the runtime. | ||
234 | /// </summary> | ||
235 | /// <value>The runtime.</value> | ||
236 | public ClrRuntime Runtime | ||
237 | { | ||
238 | get | ||
239 | { | ||
240 | return m_Runtime; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | private bool m_GenerateAssemblyInfoFile = false; | ||
245 | |||
246 | /// <summary> | ||
247 | /// | ||
248 | /// </summary> | ||
249 | public bool GenerateAssemblyInfoFile | ||
250 | { | ||
251 | get | ||
252 | { | ||
253 | return m_GenerateAssemblyInfoFile; | ||
254 | } | ||
255 | set | ||
256 | { | ||
257 | m_GenerateAssemblyInfoFile = value; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | /// <summary> | ||
262 | /// Gets the startup object. | ||
263 | /// </summary> | ||
264 | /// <value>The startup object.</value> | ||
265 | public string StartupObject | ||
266 | { | ||
267 | get | ||
268 | { | ||
269 | return m_StartupObject; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | /// <summary> | ||
274 | /// Gets the root namespace. | ||
275 | /// </summary> | ||
276 | /// <value>The root namespace.</value> | ||
277 | public string RootNamespace | ||
278 | { | ||
279 | get | ||
280 | { | ||
281 | return m_RootNamespace; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | /// <summary> | ||
286 | /// Gets the configurations. | ||
287 | /// </summary> | ||
288 | /// <value>The configurations.</value> | ||
289 | public ICollection Configurations | ||
290 | { | ||
291 | get | ||
292 | { | ||
293 | ArrayList tmp = new ArrayList( ConfigurationsTable.Values); | ||
294 | tmp.Sort(); | ||
295 | return tmp; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | /// <summary> | ||
300 | /// Gets the configurations table. | ||
301 | /// </summary> | ||
302 | /// <value>The configurations table.</value> | ||
303 | public Hashtable ConfigurationsTable | ||
304 | { | ||
305 | get | ||
306 | { | ||
307 | return m_Configurations; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | /// <summary> | ||
312 | /// Gets the reference paths. | ||
313 | /// </summary> | ||
314 | /// <value>The reference paths.</value> | ||
315 | public ArrayList ReferencePaths | ||
316 | { | ||
317 | get | ||
318 | { | ||
319 | ArrayList tmp = new ArrayList(m_ReferencePaths); | ||
320 | tmp.Sort(); | ||
321 | return tmp; | ||
322 | } | ||
323 | } | ||
324 | |||
325 | /// <summary> | ||
326 | /// Gets the references. | ||
327 | /// </summary> | ||
328 | /// <value>The references.</value> | ||
329 | public ArrayList References | ||
330 | { | ||
331 | get | ||
332 | { | ||
333 | ArrayList tmp = new ArrayList(m_References); | ||
334 | tmp.Sort(); | ||
335 | return tmp; | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /// <summary> | ||
340 | /// Gets the files. | ||
341 | /// </summary> | ||
342 | /// <value>The files.</value> | ||
343 | public FilesNode Files | ||
344 | { | ||
345 | get | ||
346 | { | ||
347 | return m_Files; | ||
348 | } | ||
349 | } | ||
350 | |||
351 | /// <summary> | ||
352 | /// Gets or sets the parent. | ||
353 | /// </summary> | ||
354 | /// <value>The parent.</value> | ||
355 | public override IDataNode Parent | ||
356 | { | ||
357 | get | ||
358 | { | ||
359 | return base.Parent; | ||
360 | } | ||
361 | set | ||
362 | { | ||
363 | base.Parent = value; | ||
364 | if(base.Parent is SolutionNode && m_Configurations.Count < 1) | ||
365 | { | ||
366 | SolutionNode parent = (SolutionNode)base.Parent; | ||
367 | foreach(ConfigurationNode conf in parent.Configurations) | ||
368 | { | ||
369 | m_Configurations[conf.Name] = conf.Clone(); | ||
370 | } | ||
371 | } | ||
372 | } | ||
373 | } | ||
374 | |||
375 | /// <summary> | ||
376 | /// Gets the GUID. | ||
377 | /// </summary> | ||
378 | /// <value>The GUID.</value> | ||
379 | public Guid Guid | ||
380 | { | ||
381 | get | ||
382 | { | ||
383 | return m_Guid; | ||
384 | } | ||
385 | } | ||
386 | |||
387 | #endregion | ||
388 | |||
389 | #region Private Methods | ||
390 | |||
391 | private void HandleConfiguration(ConfigurationNode conf) | ||
392 | { | ||
393 | if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, | ||
394 | //so it *may* override changes to the same properties for configurations defines at the project level | ||
395 | { | ||
396 | foreach(ConfigurationNode confNode in this.m_Configurations.Values) | ||
397 | { | ||
398 | conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides | ||
399 | } | ||
400 | } | ||
401 | if(m_Configurations.ContainsKey(conf.Name)) | ||
402 | { | ||
403 | ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name]; | ||
404 | conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | m_Configurations[conf.Name] = conf; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | #endregion | ||
413 | |||
414 | #region Public Methods | ||
415 | |||
416 | /// <summary> | ||
417 | /// Parses the specified node. | ||
418 | /// </summary> | ||
419 | /// <param name="node">The node.</param> | ||
420 | public override void Parse(XmlNode node) | ||
421 | { | ||
422 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
423 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
424 | m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); | ||
425 | m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); | ||
426 | m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); | ||
427 | m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); | ||
428 | m_Language = Helper.AttributeValue(node, "language", m_Language); | ||
429 | m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); | ||
430 | m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); | ||
431 | m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); | ||
432 | m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); | ||
433 | |||
434 | int hash = m_Name.GetHashCode(); | ||
435 | |||
436 | m_Guid = new Guid( hash, 0, 0, 0, 0, 0, 0,0,0,0,0 ); | ||
437 | |||
438 | m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); | ||
439 | |||
440 | if(m_AssemblyName == null || m_AssemblyName.Length < 1) | ||
441 | { | ||
442 | m_AssemblyName = m_Name; | ||
443 | } | ||
444 | |||
445 | if(m_RootNamespace == null || m_RootNamespace.Length < 1) | ||
446 | { | ||
447 | m_RootNamespace = m_Name; | ||
448 | } | ||
449 | |||
450 | m_FullPath = m_Path; | ||
451 | try | ||
452 | { | ||
453 | m_FullPath = Helper.ResolvePath(m_FullPath); | ||
454 | } | ||
455 | catch | ||
456 | { | ||
457 | throw new WarningException("Could not resolve Solution path: {0}", m_Path); | ||
458 | } | ||
459 | |||
460 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
461 | try | ||
462 | { | ||
463 | Helper.SetCurrentDir(m_FullPath); | ||
464 | |||
465 | if( node == null ) | ||
466 | { | ||
467 | throw new ArgumentNullException("node"); | ||
468 | } | ||
469 | |||
470 | foreach(XmlNode child in node.ChildNodes) | ||
471 | { | ||
472 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
473 | if(dataNode is ConfigurationNode) | ||
474 | { | ||
475 | HandleConfiguration((ConfigurationNode)dataNode); | ||
476 | } | ||
477 | else if(dataNode is ReferencePathNode) | ||
478 | { | ||
479 | m_ReferencePaths.Add(dataNode); | ||
480 | } | ||
481 | else if(dataNode is ReferenceNode) | ||
482 | { | ||
483 | m_References.Add(dataNode); | ||
484 | } | ||
485 | else if(dataNode is FilesNode) | ||
486 | { | ||
487 | m_Files = (FilesNode)dataNode; | ||
488 | } | ||
489 | } | ||
490 | } | ||
491 | finally | ||
492 | { | ||
493 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
494 | } | ||
495 | } | ||
496 | |||
497 | |||
498 | #endregion | ||
499 | |||
500 | #region IComparable Members | ||
501 | |||
502 | public int CompareTo(object obj) | ||
503 | { | ||
504 | ProjectNode that = (ProjectNode)obj; | ||
505 | return this.m_Name.CompareTo(that.m_Name); | ||
506 | } | ||
507 | |||
508 | #endregion | ||
509 | } | ||
510 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs new file mode 100644 index 0000000..a2880c0 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs | |||
@@ -0,0 +1,153 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-07-25 18:56:49 +0200 (ti, 25 jul 2006) $ | ||
31 | * $Revision: 132 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Xml; | ||
37 | |||
38 | using Prebuild.Core.Attributes; | ||
39 | using Prebuild.Core.Interfaces; | ||
40 | using Prebuild.Core.Utilities; | ||
41 | |||
42 | namespace Prebuild.Core.Nodes | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | [DataNode("Reference")] | ||
48 | public class ReferenceNode : DataNode, IComparable | ||
49 | { | ||
50 | #region Fields | ||
51 | |||
52 | private string m_Name = "unknown"; | ||
53 | private string m_Path; | ||
54 | private string m_LocalCopy; | ||
55 | private string m_Version; | ||
56 | |||
57 | #endregion | ||
58 | |||
59 | #region Properties | ||
60 | |||
61 | /// <summary> | ||
62 | /// Gets the name. | ||
63 | /// </summary> | ||
64 | /// <value>The name.</value> | ||
65 | public string Name | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | return m_Name; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// Gets the path. | ||
75 | /// </summary> | ||
76 | /// <value>The path.</value> | ||
77 | public string Path | ||
78 | { | ||
79 | get | ||
80 | { | ||
81 | return m_Path; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Gets a value indicating whether [local copy specified]. | ||
87 | /// </summary> | ||
88 | /// <value><c>true</c> if [local copy specified]; otherwise, <c>false</c>.</value> | ||
89 | public bool LocalCopySpecified | ||
90 | { | ||
91 | get | ||
92 | { | ||
93 | return ( m_LocalCopy != null && m_LocalCopy.Length == 0); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Gets a value indicating whether [local copy]. | ||
99 | /// </summary> | ||
100 | /// <value><c>true</c> if [local copy]; otherwise, <c>false</c>.</value> | ||
101 | public bool LocalCopy | ||
102 | { | ||
103 | get | ||
104 | { | ||
105 | if( m_LocalCopy == null) | ||
106 | { | ||
107 | return false; | ||
108 | } | ||
109 | return bool.Parse(m_LocalCopy); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Gets the version. | ||
115 | /// </summary> | ||
116 | /// <value>The version.</value> | ||
117 | public string Version | ||
118 | { | ||
119 | get | ||
120 | { | ||
121 | return m_Version; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | #endregion | ||
126 | |||
127 | #region Public Methods | ||
128 | |||
129 | /// <summary> | ||
130 | /// Parses the specified node. | ||
131 | /// </summary> | ||
132 | /// <param name="node">The node.</param> | ||
133 | public override void Parse(XmlNode node) | ||
134 | { | ||
135 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
136 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
137 | m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); | ||
138 | m_Version = Helper.AttributeValue(node, "version", m_Version); | ||
139 | } | ||
140 | |||
141 | #endregion | ||
142 | |||
143 | #region IComparable Members | ||
144 | |||
145 | public int CompareTo(object obj) | ||
146 | { | ||
147 | ReferenceNode that = (ReferenceNode)obj; | ||
148 | return this.m_Name.CompareTo(that.m_Name); | ||
149 | } | ||
150 | |||
151 | #endregion | ||
152 | } | ||
153 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs new file mode 100644 index 0000000..0563c1b --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs | |||
@@ -0,0 +1,108 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.Xml; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | using Prebuild.Core.Utilities; | ||
43 | |||
44 | namespace Prebuild.Core.Nodes | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// | ||
48 | /// </summary> | ||
49 | [DataNode("ReferencePath")] | ||
50 | public class ReferencePathNode : DataNode, IComparable | ||
51 | { | ||
52 | #region Fields | ||
53 | |||
54 | private string m_Path; | ||
55 | |||
56 | #endregion | ||
57 | |||
58 | #region Properties | ||
59 | |||
60 | /// <summary> | ||
61 | /// Gets the path. | ||
62 | /// </summary> | ||
63 | /// <value>The path.</value> | ||
64 | public string Path | ||
65 | { | ||
66 | get | ||
67 | { | ||
68 | return m_Path; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | #endregion | ||
73 | |||
74 | #region Public Methods | ||
75 | |||
76 | /// <summary> | ||
77 | /// Parses the specified node. | ||
78 | /// </summary> | ||
79 | /// <param name="node">The node.</param> | ||
80 | public override void Parse(XmlNode node) | ||
81 | { | ||
82 | if( node == null ) | ||
83 | { | ||
84 | throw new ArgumentNullException("node"); | ||
85 | } | ||
86 | |||
87 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
88 | if(m_Path == null) | ||
89 | { | ||
90 | m_Path = ""; | ||
91 | } | ||
92 | |||
93 | m_Path = m_Path.Trim(); | ||
94 | } | ||
95 | |||
96 | #endregion | ||
97 | |||
98 | #region IComparable Members | ||
99 | |||
100 | public int CompareTo(object obj) | ||
101 | { | ||
102 | ReferencePathNode that = (ReferencePathNode)obj; | ||
103 | return this.m_Path.CompareTo(that.m_Path); | ||
104 | } | ||
105 | |||
106 | #endregion | ||
107 | } | ||
108 | } | ||
diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs new file mode 100644 index 0000000..c777fa4 --- /dev/null +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs | |||
@@ -0,0 +1,288 @@ | |||
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 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-02-28 17:15:42 +0100 (ti, 28 feb 2006) $ | ||
31 | * $Revision: 92 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Diagnostics; | ||
38 | using System.IO; | ||
39 | using System.Xml; | ||
40 | |||
41 | using Prebuild.Core.Attributes; | ||
42 | using Prebuild.Core.Interfaces; | ||
43 | using Prebuild.Core.Utilities; | ||
44 | |||
45 | namespace Prebuild.Core.Nodes | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | [DataNode("Solution")] | ||
51 | public class SolutionNode : DataNode | ||
52 | { | ||
53 | #region Fields | ||
54 | |||
55 | private string m_Name = "unknown"; | ||
56 | private string m_Path = ""; | ||
57 | private string m_FullPath = ""; | ||
58 | private string m_ActiveConfig = "Debug"; | ||
59 | |||
60 | private OptionsNode m_Options; | ||
61 | private FilesNode m_Files; | ||
62 | private Hashtable m_Configurations; | ||
63 | private Hashtable m_Projects; | ||
64 | private ArrayList m_ProjectsOrder; | ||
65 | |||
66 | #endregion | ||
67 | |||
68 | #region Constructors | ||
69 | |||
70 | /// <summary> | ||
71 | /// Initializes a new instance of the <see cref="SolutionNode"/> class. | ||
72 | /// </summary> | ||
73 | public SolutionNode() | ||
74 | { | ||
75 | m_Configurations = new Hashtable(); | ||
76 | m_Projects = new Hashtable(); | ||
77 | m_ProjectsOrder = new ArrayList(); | ||
78 | } | ||
79 | |||
80 | #endregion | ||
81 | |||
82 | #region Properties | ||
83 | |||
84 | /// <summary> | ||
85 | /// Gets or sets the active config. | ||
86 | /// </summary> | ||
87 | /// <value>The active config.</value> | ||
88 | public string ActiveConfig | ||
89 | { | ||
90 | get | ||
91 | { | ||
92 | return m_ActiveConfig; | ||
93 | } | ||
94 | set | ||
95 | { | ||
96 | m_ActiveConfig = value; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Gets the name. | ||
102 | /// </summary> | ||
103 | /// <value>The name.</value> | ||
104 | public string Name | ||
105 | { | ||
106 | get | ||
107 | { | ||
108 | return m_Name; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Gets the path. | ||
114 | /// </summary> | ||
115 | /// <value>The path.</value> | ||
116 | public string Path | ||
117 | { | ||
118 | get | ||
119 | { | ||
120 | return m_Path; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /// <summary> | ||
125 | /// Gets the full path. | ||
126 | /// </summary> | ||
127 | /// <value>The full path.</value> | ||
128 | public string FullPath | ||
129 | { | ||
130 | get | ||
131 | { | ||
132 | return m_FullPath; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Gets the options. | ||
138 | /// </summary> | ||
139 | /// <value>The options.</value> | ||
140 | public OptionsNode Options | ||
141 | { | ||
142 | get | ||
143 | { | ||
144 | return m_Options; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Gets the files. | ||
150 | /// </summary> | ||
151 | /// <value>The files.</value> | ||
152 | public FilesNode Files | ||
153 | { | ||
154 | get | ||
155 | { | ||
156 | return m_Files; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// Gets the configurations. | ||
162 | /// </summary> | ||
163 | /// <value>The configurations.</value> | ||
164 | public ICollection Configurations | ||
165 | { | ||
166 | get | ||
167 | { | ||
168 | ArrayList tmp = new ArrayList(ConfigurationsTable.Values); | ||
169 | tmp.Sort(); | ||
170 | return tmp; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Gets the configurations table. | ||
176 | /// </summary> | ||
177 | /// <value>The configurations table.</value> | ||
178 | public Hashtable ConfigurationsTable | ||
179 | { | ||
180 | get | ||
181 | { | ||
182 | return m_Configurations; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | /// <summary> | ||
187 | /// Gets the projects. | ||
188 | /// </summary> | ||
189 | /// <value>The projects.</value> | ||
190 | public ICollection Projects | ||
191 | { | ||
192 | get | ||
193 | { | ||
194 | ArrayList tmp = new ArrayList(m_Projects.Values); | ||
195 | tmp.Sort(); | ||
196 | return tmp; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | /// <summary> | ||
201 | /// Gets the projects table. | ||
202 | /// </summary> | ||
203 | /// <value>The projects table.</value> | ||
204 | public Hashtable ProjectsTable | ||
205 | { | ||
206 | get | ||
207 | { | ||
208 | return m_Projects; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | /// <summary> | ||
213 | /// Gets the projects table. | ||
214 | /// </summary> | ||
215 | /// <value>The projects table.</value> | ||
216 | public ArrayList ProjectsTableOrder | ||
217 | { | ||
218 | get | ||
219 | { | ||
220 | return m_ProjectsOrder; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | #endregion | ||
225 | |||
226 | #region Public Methods | ||
227 | |||
228 | /// <summary> | ||
229 | /// Parses the specified node. | ||
230 | /// </summary> | ||
231 | /// <param name="node">The node.</param> | ||
232 | public override void Parse(XmlNode node) | ||
233 | { | ||
234 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
235 | m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); | ||
236 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
237 | |||
238 | m_FullPath = m_Path; | ||
239 | try | ||
240 | { | ||
241 | m_FullPath = Helper.ResolvePath(m_FullPath); | ||
242 | } | ||
243 | catch | ||
244 | { | ||
245 | throw new WarningException("Could not resolve solution path: {0}", m_Path); | ||
246 | } | ||
247 | |||
248 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
249 | try | ||
250 | { | ||
251 | Helper.SetCurrentDir(m_FullPath); | ||
252 | |||
253 | if( node == null ) | ||
254 | { | ||
255 | throw new ArgumentNullException("node"); | ||
256 | } | ||
257 | |||
258 | foreach(XmlNode child in node.ChildNodes) | ||
259 | { | ||
260 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
261 | if(dataNode is OptionsNode) | ||
262 | { | ||
263 | m_Options = (OptionsNode)dataNode; | ||
264 | } | ||
265 | else if(dataNode is FilesNode) | ||
266 | { | ||
267 | m_Files = (FilesNode)dataNode; | ||
268 | } | ||
269 | else if(dataNode is ConfigurationNode) | ||
270 | { | ||
271 | m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode; | ||
272 | } | ||
273 | else if(dataNode is ProjectNode) | ||
274 | { | ||
275 | m_Projects[((ProjectNode)dataNode).Name] = dataNode; | ||
276 | m_ProjectsOrder.Add(dataNode); | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | finally | ||
281 | { | ||
282 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | #endregion | ||
287 | } | ||
288 | } | ||