From e36c452d4e891073768fd70915a65531f806f831 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 19 Feb 2009 14:16:22 +0000 Subject: * Reverted Prebuild commit due to strange run-time errors. --- Prebuild/src/Core/Kernel.cs | 149 +++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 93 deletions(-) (limited to 'Prebuild/src/Core/Kernel.cs') diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs index 95ef04e..1f0ad70 100644 --- a/Prebuild/src/Core/Kernel.cs +++ b/Prebuild/src/Core/Kernel.cs @@ -36,8 +36,16 @@ POSSIBILITY OF SUCH DAMAGE. */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: cjcollier $ + * $Date: 2008-02-08 01:31:29 +0900 (Fri, 08 Feb 2008) $ + * $Revision: 256 $ + */ +#endregion + using System; -using System.Collections.Generic; using System.Diagnostics; using System.Collections; using System.Collections.Specialized; @@ -72,17 +80,17 @@ namespace Prebuild.Core #region Fields - private static readonly Kernel m_Instance = new Kernel(); + private static Kernel m_Instance = new Kernel(); /// /// This must match the version of the schema that is embeeded /// - private const string m_SchemaVersion = "1.7"; - private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; - private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; + private static string m_SchemaVersion = "1.7"; + private static string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; + private static string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; bool disposed; private Version m_Version; - private const string m_Revision = ""; + private string m_Revision = ""; private CommandLineCollection m_CommandLine; private Log m_Log; private CurrentDirectory m_CurrentWorkingDirectory; @@ -90,16 +98,19 @@ namespace Prebuild.Core private Hashtable m_Targets; private Hashtable m_Nodes; - - readonly List m_Solutions = new List(); + + ArrayList m_Solutions; string m_Target; string m_Clean; string[] m_RemoveDirectories; - XmlDocument m_CurrentDoc; + string m_CurrentFile; + XmlDocument m_CurrentDoc; bool m_PauseAfterFinish; string[] m_ProjectGroups; + StringCollection m_Refs; - #endregion + + #endregion #region Constructors @@ -199,7 +210,7 @@ namespace Prebuild.Core /// Gets the solutions. /// /// The solutions. - public List Solutions + public ArrayList Solutions { get { @@ -224,7 +235,7 @@ namespace Prebuild.Core #region Private Methods - private static void RemoveDirectories(string rootDir, string[] dirNames) + private void RemoveDirectories(string rootDir, string[] dirNames) { foreach(string dir in Directory.GetDirectories(rootDir)) { @@ -286,15 +297,13 @@ namespace Prebuild.Core foreach(Type t in assm.GetTypes()) { TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); - if(ta == null) + { continue; - - if (t.IsAbstract) - continue; - + } + ITarget target = (ITarget)assm.CreateInstance(t.FullName); - if (target == null) + if(target == null) { throw new MissingMethodException("Could not create ITarget instance"); } @@ -307,13 +316,16 @@ namespace Prebuild.Core { foreach(Type t in assm.GetTypes()) { - foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) - { - NodeEntry ne = new NodeEntry(); - ne.Type = t; - ne.Attribute = dna; - m_Nodes[dna.Name] = ne; - } + DataNodeAttribute dna = (DataNodeAttribute)Helper.CheckType(t, typeof(DataNodeAttribute), typeof(IDataNode)); + if(dna == null) + { + continue; + } + + NodeEntry ne = new NodeEntry(); + ne.Type = t; + ne.Attribute = dna; + m_Nodes[dna.Name] = ne; } } @@ -331,32 +343,7 @@ namespace Prebuild.Core m_Log.Write(); } - - - private void ProcessFile(string file) - { - ProcessFile(file, this.m_Solutions); - } - - public void ProcessFile(ProcessNode node, SolutionNode parent) - { - if (node.IsValid) - { - List list = new List(); - ProcessFile(node.Path, list); - - foreach (SolutionNode solution in list) - parent.SolutionsTable[solution.Name] = solution; - } - } - - /// - /// - /// - /// - /// - /// - public void ProcessFile(string file, IList solutions) + private void ProcessFile(string file) { m_CurrentWorkingDirectory.Push(); @@ -374,7 +361,8 @@ namespace Prebuild.Core return; } - Helper.SetCurrentDir(Path.GetDirectoryName(path)); + m_CurrentFile = path; + Helper.SetCurrentDir(Path.GetDirectoryName(path)); XmlTextReader reader = new XmlTextReader(path); @@ -391,33 +379,6 @@ namespace Prebuild.Core string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML - // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the - // output before the system processes it. - if (m_CommandLine.WasPassed("ppi")) - { - // Get the filename if there is one, otherwise use a default. - string ppiFile = m_CommandLine["ppi"]; - if (ppiFile == null || ppiFile.Trim().Length == 0) - { - ppiFile = "preprocessed-input.xml"; - } - - // Write out the string to the given stream. - try - { - using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) - { - ppiWriter.WriteLine(xml); - } - } - catch(IOException ex) - { - Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); - } - - // Finish processing this special tag. - return; - } m_CurrentDoc = new XmlDocument(); try @@ -482,7 +443,7 @@ namespace Prebuild.Core } else if(dataNode is SolutionNode) { - solutions.Add((SolutionNode)dataNode); + m_Solutions.Add(dataNode); } } } @@ -566,7 +527,7 @@ namespace Prebuild.Core /// public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) { - IDataNode dataNode; + IDataNode dataNode = null; try { @@ -668,6 +629,9 @@ namespace Prebuild.Core m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); LoadSchema(); + + m_Solutions = new ArrayList(); + m_Refs = new StringCollection(); } /// @@ -700,18 +664,17 @@ namespace Prebuild.Core m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); return; } - - if(m_Target == null && m_Clean == null) - { - if(perfomedOtherTask) //finished - { - return; - } - m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); - return; - } - - string file = "./prebuild.xml"; + else if(m_Target == null && m_Clean == null) + { + if(perfomedOtherTask) //finished + { + return; + } + m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); + return; + } + + string file = "./prebuild.xml"; if(m_CommandLine.WasPassed("file")) { file = m_CommandLine["file"]; -- cgit v1.1