diff options
author | Jeff Ames | 2008-03-17 20:55:21 +0000 |
---|---|---|
committer | Jeff Ames | 2008-03-17 20:55:21 +0000 |
commit | 79209c429705beb57ad9b787718856ab2c9fd37c (patch) | |
tree | 6f459e172985bce8ffbfc09a5b9a4594dd881a62 /Prebuild/src/Core/Nodes/MatchNode.cs | |
parent | * More almost completely unproductive log message fiddling (diff) | |
download | opensim-SC_OLD-79209c429705beb57ad9b787718856ab2c9fd37c.zip opensim-SC_OLD-79209c429705beb57ad9b787718856ab2c9fd37c.tar.gz opensim-SC_OLD-79209c429705beb57ad9b787718856ab2c9fd37c.tar.bz2 opensim-SC_OLD-79209c429705beb57ad9b787718856ab2c9fd37c.tar.xz |
Merged changes in Prebuild trunk up to r258 into OpenSim's Prebuild.
Hopefully this should make merging upstream easier.
Building with NAnt should still work, but Visual Studio is untested.
Diffstat (limited to '')
-rw-r--r-- | Prebuild/src/Core/Nodes/MatchNode.cs | 78 |
1 files changed, 63 insertions, 15 deletions
diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs index 8d7b467..aeaf3c1 100644 --- a/Prebuild/src/Core/Nodes/MatchNode.cs +++ b/Prebuild/src/Core/Nodes/MatchNode.cs | |||
@@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O | |||
26 | #region CVS Information | 26 | #region CVS Information |
27 | /* | 27 | /* |
28 | * $Source$ | 28 | * $Source$ |
29 | * $Author: jendave $ | 29 | * $Author: borrillis $ |
30 | * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ | 30 | * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ |
31 | * $Revision: 164 $ | 31 | * $Revision: 243 $ |
32 | */ | 32 | */ |
33 | #endregion | 33 | #endregion |
34 | 34 | ||
@@ -41,6 +41,7 @@ using System.Xml; | |||
41 | using Prebuild.Core.Attributes; | 41 | using Prebuild.Core.Attributes; |
42 | using Prebuild.Core.Interfaces; | 42 | using Prebuild.Core.Interfaces; |
43 | using Prebuild.Core.Utilities; | 43 | using Prebuild.Core.Utilities; |
44 | using System.Collections; | ||
44 | 45 | ||
45 | namespace Prebuild.Core.Nodes | 46 | namespace Prebuild.Core.Nodes |
46 | { | 47 | { |
@@ -59,7 +60,9 @@ namespace Prebuild.Core.Nodes | |||
59 | string m_ResourceName = ""; | 60 | string m_ResourceName = ""; |
60 | private CopyToOutput m_CopyToOutput; | 61 | private CopyToOutput m_CopyToOutput; |
61 | private bool m_Link; | 62 | private bool m_Link; |
62 | 63 | private string m_LinkPath; | |
64 | private bool m_PreservePath; | ||
65 | private ArrayList m_Exclusions; | ||
63 | 66 | ||
64 | #endregion | 67 | #endregion |
65 | 68 | ||
@@ -71,6 +74,7 @@ namespace Prebuild.Core.Nodes | |||
71 | public MatchNode() | 74 | public MatchNode() |
72 | { | 75 | { |
73 | m_Files = new StringCollection(); | 76 | m_Files = new StringCollection(); |
77 | m_Exclusions = new ArrayList(); | ||
74 | } | 78 | } |
75 | 79 | ||
76 | #endregion | 80 | #endregion |
@@ -126,6 +130,13 @@ namespace Prebuild.Core.Nodes | |||
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
133 | public string LinkPath | ||
134 | { | ||
135 | get | ||
136 | { | ||
137 | return this.m_LinkPath; | ||
138 | } | ||
139 | } | ||
129 | /// <summary> | 140 | /// <summary> |
130 | /// | 141 | /// |
131 | /// </summary> | 142 | /// </summary> |
@@ -137,6 +148,13 @@ namespace Prebuild.Core.Nodes | |||
137 | } | 148 | } |
138 | } | 149 | } |
139 | 150 | ||
151 | public bool PreservePath | ||
152 | { | ||
153 | get | ||
154 | { | ||
155 | return m_PreservePath; | ||
156 | } | ||
157 | } | ||
140 | 158 | ||
141 | #endregion | 159 | #endregion |
142 | 160 | ||
@@ -149,8 +167,10 @@ namespace Prebuild.Core.Nodes | |||
149 | /// <param name="pattern">The pattern.</param> | 167 | /// <param name="pattern">The pattern.</param> |
150 | /// <param name="recurse">if set to <c>true</c> [recurse].</param> | 168 | /// <param name="recurse">if set to <c>true</c> [recurse].</param> |
151 | /// <param name="useRegex">if set to <c>true</c> [use regex].</param> | 169 | /// <param name="useRegex">if set to <c>true</c> [use regex].</param> |
152 | private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex) | 170 | private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, ArrayList exclusions) |
153 | { | 171 | { |
172 | Match match; | ||
173 | Boolean excludeFile; | ||
154 | try | 174 | try |
155 | { | 175 | { |
156 | string[] files; | 176 | string[] files; |
@@ -163,6 +183,7 @@ namespace Prebuild.Core.Nodes | |||
163 | string fileTemp; | 183 | string fileTemp; |
164 | foreach (string file in files) | 184 | foreach (string file in files) |
165 | { | 185 | { |
186 | excludeFile = false; | ||
166 | if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") | 187 | if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") |
167 | { | 188 | { |
168 | fileTemp = file.Substring(2); | 189 | fileTemp = file.Substring(2); |
@@ -171,8 +192,20 @@ namespace Prebuild.Core.Nodes | |||
171 | { | 192 | { |
172 | fileTemp = file; | 193 | fileTemp = file; |
173 | } | 194 | } |
174 | 195 | ||
175 | m_Files.Add(fileTemp); | 196 | // Check all excludions and set flag if there are any hits. |
197 | foreach ( ExcludeNode exclude in exclusions ) | ||
198 | { | ||
199 | Regex exRegEx = new Regex( exclude.Pattern ); | ||
200 | match = exRegEx.Match( file ); | ||
201 | excludeFile |= match.Success; | ||
202 | } | ||
203 | |||
204 | if ( !excludeFile ) | ||
205 | { | ||
206 | m_Files.Add( fileTemp ); | ||
207 | } | ||
208 | |||
176 | } | 209 | } |
177 | } | 210 | } |
178 | else | 211 | else |
@@ -182,14 +215,26 @@ namespace Prebuild.Core.Nodes | |||
182 | } | 215 | } |
183 | else | 216 | else |
184 | { | 217 | { |
185 | Match match; | ||
186 | files = Directory.GetFiles(path); | 218 | files = Directory.GetFiles(path); |
187 | foreach(string file in files) | 219 | foreach(string file in files) |
188 | { | 220 | { |
221 | excludeFile = false; | ||
222 | |||
189 | match = m_Regex.Match(file); | 223 | match = m_Regex.Match(file); |
190 | if(match.Success) | 224 | if(match.Success) |
191 | { | 225 | { |
192 | m_Files.Add(file); | 226 | // Check all excludions and set flag if there are any hits. |
227 | foreach ( ExcludeNode exclude in exclusions ) | ||
228 | { | ||
229 | Regex exRegEx = new Regex( exclude.Pattern ); | ||
230 | match = exRegEx.Match( file ); | ||
231 | excludeFile |= !match.Success; | ||
232 | } | ||
233 | |||
234 | if ( !excludeFile ) | ||
235 | { | ||
236 | m_Files.Add( file ); | ||
237 | } | ||
193 | } | 238 | } |
194 | } | 239 | } |
195 | } | 240 | } |
@@ -201,7 +246,7 @@ namespace Prebuild.Core.Nodes | |||
201 | { | 246 | { |
202 | foreach(string str in dirs) | 247 | foreach(string str in dirs) |
203 | { | 248 | { |
204 | RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex); | 249 | RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex, exclusions); |
205 | } | 250 | } |
206 | } | 251 | } |
207 | } | 252 | } |
@@ -241,6 +286,11 @@ namespace Prebuild.Core.Nodes | |||
241 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | 286 | 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())); | 287 | 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)); | 288 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); |
289 | if ( this.m_Link == true ) | ||
290 | { | ||
291 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); | ||
292 | } | ||
293 | this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); | ||
244 | 294 | ||
245 | 295 | ||
246 | if(path != null && path.Length == 0) | 296 | if(path != null && path.Length == 0) |
@@ -272,7 +322,6 @@ namespace Prebuild.Core.Nodes | |||
272 | throw new WarningException("Could not compile regex pattern: {0}", ex.Message); | 322 | throw new WarningException("Could not compile regex pattern: {0}", ex.Message); |
273 | } | 323 | } |
274 | 324 | ||
275 | RecurseDirectories(path, pattern, recurse, useRegex); | ||
276 | 325 | ||
277 | foreach(XmlNode child in node.ChildNodes) | 326 | foreach(XmlNode child in node.ChildNodes) |
278 | { | 327 | { |
@@ -280,13 +329,12 @@ namespace Prebuild.Core.Nodes | |||
280 | if(dataNode is ExcludeNode) | 329 | if(dataNode is ExcludeNode) |
281 | { | 330 | { |
282 | ExcludeNode excludeNode = (ExcludeNode)dataNode; | 331 | ExcludeNode excludeNode = (ExcludeNode)dataNode; |
283 | if (m_Files.Contains(Helper.NormalizePath(excludeNode.Name))) | 332 | m_Exclusions.Add( dataNode ); |
284 | { | ||
285 | m_Files.Remove(Helper.NormalizePath(excludeNode.Name)); | ||
286 | } | ||
287 | } | 333 | } |
288 | } | 334 | } |
289 | 335 | ||
336 | RecurseDirectories( path, pattern, recurse, useRegex, m_Exclusions ); | ||
337 | |||
290 | if(m_Files.Count < 1) | 338 | if(m_Files.Count < 1) |
291 | { | 339 | { |
292 | throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); | 340 | throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); |