diff options
Diffstat (limited to 'Prebuild/src/Core/Kernel.cs')
-rw-r--r-- | Prebuild/src/Core/Kernel.cs | 120 |
1 files changed, 78 insertions, 42 deletions
diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs index 170d0f5..1f0ad70 100644 --- a/Prebuild/src/Core/Kernel.cs +++ b/Prebuild/src/Core/Kernel.cs | |||
@@ -1,34 +1,47 @@ | |||
1 | #region BSD License | 1 | #region BSD License |
2 | /* | 2 | /* |
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | 3 | Copyright (c) 2004-2008 |
4 | 4 | Matthew Holmes (matthew@wildfiregames.com), | |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | 5 | Dan Moorehead (dan05a@gmail.com), |
6 | provided that the following conditions are met: | 6 | Rob Loach (http://www.robloach.net), |
7 | 7 | C.J. Adams-Collier (cjac@colliertech.org) | |
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | 8 | |
9 | and the following disclaimer. | 9 | Redistribution and use in source and binary forms, with or without |
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | 10 | modification, are permitted provided that the following conditions are |
11 | and the following disclaimer in the documentation and/or other materials provided with the | 11 | met: |
12 | distribution. | 12 | |
13 | * The name of the author may not be used to endorse or promote products derived from this software | 13 | * Redistributions of source code must retain the above copyright |
14 | without specific prior written permission. | 14 | notice, this list of conditions and the following disclaimer. |
15 | 15 | ||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | 16 | * Redistributions in binary form must reproduce the above copyright |
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 | notice, this list of conditions and the following disclaimer in the |
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 | documentation and/or other materials provided with the distribution. |
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 19 | |
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 | * The name of the author may not be used to endorse or promote |
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 21 | products derived from this software without specific prior written |
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | permission. |
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
28 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
31 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
33 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | POSSIBILITY OF SUCH DAMAGE. | ||
35 | |||
23 | */ | 36 | */ |
24 | #endregion | 37 | #endregion |
25 | 38 | ||
26 | #region CVS Information | 39 | #region CVS Information |
27 | /* | 40 | /* |
28 | * $Source$ | 41 | * $Source$ |
29 | * $Author: robloach $ | 42 | * $Author: cjcollier $ |
30 | * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ | 43 | * $Date: 2008-02-08 01:31:29 +0900 (Fri, 08 Feb 2008) $ |
31 | * $Revision: 165 $ | 44 | * $Revision: 256 $ |
32 | */ | 45 | */ |
33 | #endregion | 46 | #endregion |
34 | 47 | ||
@@ -91,6 +104,7 @@ namespace Prebuild.Core | |||
91 | string m_Clean; | 104 | string m_Clean; |
92 | string[] m_RemoveDirectories; | 105 | string[] m_RemoveDirectories; |
93 | string m_CurrentFile; | 106 | string m_CurrentFile; |
107 | XmlDocument m_CurrentDoc; | ||
94 | bool m_PauseAfterFinish; | 108 | bool m_PauseAfterFinish; |
95 | string[] m_ProjectGroups; | 109 | string[] m_ProjectGroups; |
96 | StringCollection m_Refs; | 110 | StringCollection m_Refs; |
@@ -203,6 +217,19 @@ namespace Prebuild.Core | |||
203 | return m_Solutions; | 217 | return m_Solutions; |
204 | } | 218 | } |
205 | } | 219 | } |
220 | |||
221 | /// <summary> | ||
222 | /// Gets the XmlDocument object representing the prebuild.xml | ||
223 | /// being processed | ||
224 | /// </summary> | ||
225 | /// <value>The XmlDocument object</value> | ||
226 | public XmlDocument CurrentDoc | ||
227 | { | ||
228 | get | ||
229 | { | ||
230 | return m_CurrentDoc; | ||
231 | } | ||
232 | } | ||
206 | 233 | ||
207 | #endregion | 234 | #endregion |
208 | 235 | ||
@@ -304,10 +331,16 @@ namespace Prebuild.Core | |||
304 | 331 | ||
305 | private void LogBanner() | 332 | private void LogBanner() |
306 | { | 333 | { |
307 | m_Log.Write("Prebuild v" + this.Version); | 334 | m_Log.Write("Prebuild v" + this.Version); |
308 | m_Log.Write("Copyright (c) Matthew Holmes, Dan Moorehead and David Hudson"); | 335 | m_Log.Write("Copyright (c) 2004-2008"); |
309 | m_Log.Write("See 'prebuild /usage' for help"); | 336 | m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); |
310 | m_Log.Write(); | 337 | m_Log.Write("Dan Moorehead (dan05a@gmail.com),"); |
338 | m_Log.Write("David Hudson (jendave@yahoo.com),"); | ||
339 | m_Log.Write("Rob Loach (http://www.robloach.net),"); | ||
340 | m_Log.Write("C.J. Adams-Collier (cjac@colliertech.org),"); | ||
341 | |||
342 | m_Log.Write("See 'prebuild /usage' for help"); | ||
343 | m_Log.Write(); | ||
311 | } | 344 | } |
312 | 345 | ||
313 | private void ProcessFile(string file) | 346 | private void ProcessFile(string file) |
@@ -330,7 +363,6 @@ namespace Prebuild.Core | |||
330 | 363 | ||
331 | m_CurrentFile = path; | 364 | m_CurrentFile = path; |
332 | Helper.SetCurrentDir(Path.GetDirectoryName(path)); | 365 | Helper.SetCurrentDir(Path.GetDirectoryName(path)); |
333 | |||
334 | 366 | ||
335 | XmlTextReader reader = new XmlTextReader(path); | 367 | XmlTextReader reader = new XmlTextReader(path); |
336 | 368 | ||
@@ -348,7 +380,7 @@ namespace Prebuild.Core | |||
348 | string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML | 380 | string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML |
349 | 381 | ||
350 | 382 | ||
351 | XmlDocument doc = new XmlDocument(); | 383 | m_CurrentDoc = new XmlDocument(); |
352 | try | 384 | try |
353 | { | 385 | { |
354 | XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); | 386 | XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); |
@@ -358,7 +390,7 @@ namespace Prebuild.Core | |||
358 | { | 390 | { |
359 | validator.Schemas.Add(schema); | 391 | validator.Schemas.Add(schema); |
360 | } | 392 | } |
361 | doc.Load(validator); | 393 | m_CurrentDoc.Load(validator); |
362 | } | 394 | } |
363 | catch(XmlException e) | 395 | catch(XmlException e) |
364 | { | 396 | { |
@@ -394,7 +426,7 @@ namespace Prebuild.Core | |||
394 | return; | 426 | return; |
395 | } | 427 | } |
396 | //start reading the xml config file | 428 | //start reading the xml config file |
397 | XmlElement rootNode = doc.DocumentElement; | 429 | XmlElement rootNode = m_CurrentDoc.DocumentElement; |
398 | //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); | 430 | //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); |
399 | Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); | 431 | Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); |
400 | 432 | ||
@@ -681,17 +713,21 @@ namespace Prebuild.Core | |||
681 | } | 713 | } |
682 | else | 714 | else |
683 | { | 715 | { |
684 | ITarget targ = (ITarget)m_Targets[target]; | 716 | if (!m_Targets.Contains(target)) { |
717 | m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); | ||
718 | return; | ||
719 | } | ||
720 | ITarget targ = (ITarget)m_Targets[target]; | ||
685 | 721 | ||
686 | if(clean) | 722 | if(clean) |
687 | { | 723 | { |
688 | targ.Clean(this); | 724 | targ.Clean(this); |
689 | } | 725 | } |
690 | else | 726 | else |
691 | { | 727 | { |
692 | targ.Write(this); | 728 | targ.Write(this); |
693 | } | 729 | } |
694 | } | 730 | } |
695 | 731 | ||
696 | m_Log.Flush(); | 732 | m_Log.Flush(); |
697 | } | 733 | } |
@@ -755,4 +791,4 @@ namespace Prebuild.Core | |||
755 | 791 | ||
756 | #endregion | 792 | #endregion |
757 | } | 793 | } |
758 | } \ No newline at end of file | 794 | } |