From 7daa3955bc3a1918e40962851f9e8d38597a245e Mon Sep 17 00:00:00 2001 From: gareth Date: Thu, 22 Mar 2007 10:11:15 +0000 Subject: brought zircon branch into trunk --- Prebuild/src/Core/Nodes/ConfigurationNode.cs | 177 ++++++++ Prebuild/src/Core/Nodes/DataNode.cs | 82 ++++ Prebuild/src/Core/Nodes/ExcludeNode.cs | 85 ++++ Prebuild/src/Core/Nodes/FileNode.cs | 238 ++++++++++ Prebuild/src/Core/Nodes/FilesNode.cs | 222 +++++++++ Prebuild/src/Core/Nodes/MatchNode.cs | 299 ++++++++++++ Prebuild/src/Core/Nodes/OptionsNode.cs | 655 +++++++++++++++++++++++++++ Prebuild/src/Core/Nodes/ProcessNode.cs | 119 +++++ Prebuild/src/Core/Nodes/ProjectNode.cs | 490 ++++++++++++++++++++ Prebuild/src/Core/Nodes/ReferenceNode.cs | 143 ++++++ Prebuild/src/Core/Nodes/ReferencePathNode.cs | 98 ++++ Prebuild/src/Core/Nodes/SolutionNode.cs | 284 ++++++++++++ 12 files changed, 2892 insertions(+) create mode 100644 Prebuild/src/Core/Nodes/ConfigurationNode.cs create mode 100644 Prebuild/src/Core/Nodes/DataNode.cs create mode 100644 Prebuild/src/Core/Nodes/ExcludeNode.cs create mode 100644 Prebuild/src/Core/Nodes/FileNode.cs create mode 100644 Prebuild/src/Core/Nodes/FilesNode.cs create mode 100644 Prebuild/src/Core/Nodes/MatchNode.cs create mode 100644 Prebuild/src/Core/Nodes/OptionsNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProcessNode.cs create mode 100644 Prebuild/src/Core/Nodes/ProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferenceNode.cs create mode 100644 Prebuild/src/Core/Nodes/ReferencePathNode.cs create mode 100644 Prebuild/src/Core/Nodes/SolutionNode.cs (limited to 'Prebuild/src/Core/Nodes') diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs new file mode 100644 index 0000000..e1488a7 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs @@ -0,0 +1,177 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Configuration")] + public class ConfigurationNode : DataNode, ICloneable + { + #region Fields + + private string m_Name = "unknown"; + private OptionsNode m_Options; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ConfigurationNode() + { + m_Options = new OptionsNode(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode) + { + SolutionNode node = (SolutionNode)base.Parent; + if(node != null && node.Options != null) + { + node.Options.CopyTo(m_Options); + } + } + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets or sets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + set + { + m_Options = value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + ((OptionsNode)dataNode).CopyTo(m_Options); + } + } + } + + /// + /// Copies to. + /// + /// The conf. + public void CopyTo(ConfigurationNode conf) + { + m_Options.CopyTo(conf.m_Options); + } + + #endregion + + #region ICloneable Members + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + public object Clone() + { + ConfigurationNode ret = new ConfigurationNode(); + ret.m_Name = m_Name; + m_Options.CopyTo(ret.m_Options); + return ret; + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public class DataNode : IDataNode + { + #region Fields + + private IDataNode parent; + + #endregion + + #region IDataNode Members + + /// + /// Gets or sets the parent. + /// + /// The parent. + public virtual IDataNode Parent + { + get + { + return parent; + } + set + { + parent = value; + } + } + + /// + /// Parses the specified node. + /// + /// The node. + public virtual void Parse(XmlNode node) + { + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-31 16:35:39 +0100 (ti, 31 jan 2006) $ + * $Revision: 74 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Exclude")] + public class ExcludeNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ + * $Revision: 197 $ + */ +#endregion + +using System; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum BuildAction + { + /// + /// + /// + None, + /// + /// + /// + Compile, + /// + /// + /// + Content, + /// + /// + /// + EmbeddedResource + } + + /// + /// + /// + public enum SubType + { + /// + /// + /// + Code, + /// + /// + /// + Component, + /// + /// + /// + Designer, + /// + /// + /// + Form, + /// + /// + /// + Settings, + /// + /// + /// + UserControl + } + + public enum CopyToOutput + { + Never, + Always, + PreserveNewest + } + + /// + /// + /// + [DataNode("File")] + public class FileNode : DataNode + { + #region Fields + + private string m_Path; + private string m_ResourceName = ""; + private BuildAction m_BuildAction = BuildAction.Compile; + private bool m_Valid; + private SubType m_SubType = SubType.Code; + private CopyToOutput m_CopyToOutput = CopyToOutput.Never; + private bool m_Link = false; + + + #endregion + + #region Properties + + /// + /// + /// + public string Path + { + get + { + return m_Path; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + return m_BuildAction; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + /// + /// + /// + public SubType SubType + { + get + { + return m_SubType; + } + } + + /// + /// + /// + public bool IsValid + { + get + { + return m_Valid; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), + Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); + m_SubType = (SubType)Enum.Parse(typeof(SubType), + Helper.AttributeValue(node, "subType", m_SubType.ToString())); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + m_Valid = true; + if(!File.Exists(m_Path)) + { + m_Valid = false; + Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs new file mode 100644 index 0000000..442a45f --- /dev/null +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -0,0 +1,222 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Files")] + public class FilesNode : DataNode + { + #region Fields + + private StringCollection m_Files; + private Hashtable m_BuildActions; + private Hashtable m_SubTypes; + private Hashtable m_ResourceNames; + private Hashtable m_CopyToOutputs; + private Hashtable m_Links; + + + #endregion + + #region Constructors + + /// + /// + /// + public FilesNode() + { + m_Files = new StringCollection(); + m_BuildActions = new Hashtable(); + m_SubTypes = new Hashtable(); + m_ResourceNames = new Hashtable(); + m_CopyToOutputs = new Hashtable(); + m_Links = new Hashtable(); + } + + #endregion + + #region Properties + + /// + /// + /// + public int Count + { + get + { + return m_Files.Count; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + /// + public BuildAction GetBuildAction(string file) + { + if(!m_BuildActions.ContainsKey(file)) + { + return BuildAction.Compile; + } + + return (BuildAction)m_BuildActions[file]; + } + + public CopyToOutput GetCopyToOutput(string file) + { + if (!this.m_CopyToOutputs.ContainsKey(file)) + { + return CopyToOutput.Never; + } + return (CopyToOutput) this.m_CopyToOutputs[file]; + } + + public bool GetIsLink(string file) + { + if (!this.m_Links.ContainsKey(file)) + { + return false; + } + return (bool) this.m_Links[file]; + } + + /// + /// + /// + /// + /// + public SubType GetSubType(string file) + { + if(!m_SubTypes.ContainsKey(file)) + { + return SubType.Code; + } + + return (SubType)m_SubTypes[file]; + } + + /// + /// + /// + /// + /// + public string GetResourceName(string file) + { + if(!m_ResourceNames.ContainsKey(file)) + { + return ""; + } + + return (string)m_ResourceNames[file]; + } + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is FileNode) + { + FileNode fileNode = (FileNode)dataNode; + if(fileNode.IsValid) + { + if (!m_Files.Contains(fileNode.Path)) + { + m_Files.Add(fileNode.Path); + m_BuildActions[fileNode.Path] = fileNode.BuildAction; + m_SubTypes[fileNode.Path] = fileNode.SubType; + m_ResourceNames[fileNode.Path] = fileNode.ResourceName; + this.m_Links[fileNode.Path] = fileNode.IsLink; + this.m_CopyToOutputs[fileNode.Path] = fileNode.CopyToOutput; + + } + } + } + else if(dataNode is MatchNode) + { + foreach(string file in ((MatchNode)dataNode).Files) + { + if (!m_Files.Contains(file)) + { + m_Files.Add(file); + m_BuildActions[file] = ((MatchNode)dataNode).BuildAction; + m_SubTypes[file] = ((MatchNode)dataNode).SubType; + m_ResourceNames[file] = ((MatchNode)dataNode).ResourceName; + this.m_Links[file] = ((MatchNode) dataNode).IsLink; + this.m_CopyToOutputs[file] = ((MatchNode) dataNode).CopyToOutput; + + } + } + } + } + } + + // TODO: Check in to why StringCollection's enumerator doesn't implement + // IEnumerator? + /// + /// + /// + /// + public StringEnumerator GetEnumerator() + { + return m_Files.GetEnumerator(); + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Revision: 164 $ + */ +#endregion + +using System; +using System.Collections.Specialized; +using System.IO; +using System.Text.RegularExpressions; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Match")] + public class MatchNode : DataNode + { + #region Fields + + private StringCollection m_Files; + private Regex m_Regex; + private BuildAction m_BuildAction = BuildAction.Compile; + private SubType m_SubType = SubType.Code; + string m_ResourceName = ""; + private CopyToOutput m_CopyToOutput; + private bool m_Link; + + + #endregion + + #region Constructors + + /// + /// + /// + public MatchNode() + { + m_Files = new StringCollection(); + } + + #endregion + + #region Properties + + /// + /// + /// + public StringCollection Files + { + get + { + return m_Files; + } + } + + /// + /// + /// + public BuildAction BuildAction + { + get + { + return m_BuildAction; + } + } + + /// + /// + /// + public SubType SubType + { + get + { + return m_SubType; + } + } + + public CopyToOutput CopyToOutput + { + get + { + return this.m_CopyToOutput; + } + } + + public bool IsLink + { + get + { + return this.m_Link; + } + } + + /// + /// + /// + public string ResourceName + { + get + { + return m_ResourceName; + } + } + + + #endregion + + #region Private Methods + + /// + /// Recurses the directories. + /// + /// The path. + /// The pattern. + /// if set to true [recurse]. + /// if set to true [use regex]. + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex) + { + try + { + string[] files; + + if(!useRegex) + { + files = Directory.GetFiles(path, pattern); + if(files != null) + { + string fileTemp; + foreach (string file in files) + { + if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") + { + fileTemp = file.Substring(2); + } + else + { + fileTemp = file; + } + + m_Files.Add(fileTemp); + } + } + else + { + return; + } + } + else + { + Match match; + files = Directory.GetFiles(path); + foreach(string file in files) + { + match = m_Regex.Match(file); + if(match.Success) + { + m_Files.Add(file); + } + } + } + + if(recurse) + { + string[] dirs = Directory.GetDirectories(path); + if(dirs != null && dirs.Length > 0) + { + foreach(string str in dirs) + { + RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex); + } + } + } + } + catch(DirectoryNotFoundException) + { + return; + } + catch(ArgumentException) + { + return; + } + } + + #endregion + + #region Public Methods + + /// + /// + /// + /// + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + string path = Helper.AttributeValue(node, "path", "."); + string pattern = Helper.AttributeValue(node, "pattern", "*"); + bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); + bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); + m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), + Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); + m_SubType = (SubType)Enum.Parse(typeof(SubType), + Helper.AttributeValue(node, "subType", m_SubType.ToString())); + m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); + this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + + + if(path != null && path.Length == 0) + { + path = ".";//use current directory + } + //throw new WarningException("Match must have a 'path' attribute"); + + if(pattern == null) + { + throw new WarningException("Match must have a 'pattern' attribute"); + } + + path = Helper.NormalizePath(path); + if(!Directory.Exists(path)) + { + throw new WarningException("Match path does not exist: {0}", path); + } + + try + { + if(useRegex) + { + m_Regex = new Regex(pattern); + } + } + catch(ArgumentException ex) + { + throw new WarningException("Could not compile regex pattern: {0}", ex.Message); + } + + RecurseDirectories(path, pattern, recurse, useRegex); + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ExcludeNode) + { + ExcludeNode excludeNode = (ExcludeNode)dataNode; + if (m_Files.Contains(Helper.NormalizePath(excludeNode.Name))) + { + m_Files.Remove(Helper.NormalizePath(excludeNode.Name)); + } + } + } + + if(m_Files.Count < 1) + { + throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); + } + m_Regex = null; + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ + * $Revision: 197 $ + */ +#endregion + + + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Options")] + public class OptionsNode : DataNode + { + #region Fields + + private static Hashtable m_OptionFields; + + [OptionNode("CompilerDefines")] + private string m_CompilerDefines = ""; + + /// + /// + /// + public string CompilerDefines + { + get + { + return m_CompilerDefines; + } + set + { + m_CompilerDefines = value; + } + } + + [OptionNode("OptimizeCode")] + private bool m_OptimizeCode; + + /// + /// + /// + public bool OptimizeCode + { + get + { + return m_OptimizeCode; + } + set + { + m_OptimizeCode = value; + } + } + + [OptionNode("CheckUnderflowOverflow")] + private bool m_CheckUnderflowOverflow; + + /// + /// + /// + public bool CheckUnderflowOverflow + { + get + { + return m_CheckUnderflowOverflow; + } + set + { + m_CheckUnderflowOverflow = value; + } + } + + [OptionNode("AllowUnsafe")] + private bool m_AllowUnsafe; + + /// + /// + /// + public bool AllowUnsafe + { + get + { + return m_AllowUnsafe; + } + set + { + m_AllowUnsafe = value; + } + } + + [OptionNode("PreBuildEvent")] + private string m_PreBuildEvent; + + /// + /// + /// + public string PreBuildEvent + { + get + { + return m_PreBuildEvent; + } + set + { + m_PreBuildEvent = value; + } + } + + [OptionNode("PostBuildEvent")] + private string m_PostBuildEvent; + + /// + /// + /// + public string PostBuildEvent + { + get + { + return m_PostBuildEvent; + } + set + { + m_PostBuildEvent = value; + } + } + + [OptionNode("PreBuildEventArgs")] + private string m_PreBuildEventArgs; + + /// + /// + /// + public string PreBuildEventArgs + { + get + { + return m_PreBuildEventArgs; + } + set + { + m_PreBuildEventArgs = value; + } + } + + [OptionNode("PostBuildEventArgs")] + private string m_PostBuildEventArgs; + + /// + /// + /// + public string PostBuildEventArgs + { + get + { + return m_PostBuildEventArgs; + } + set + { + m_PostBuildEventArgs = value; + } + } + + [OptionNode("RunPostBuildEvent")] + private string m_RunPostBuildEvent; + + /// + /// + /// + public string RunPostBuildEvent + { + get + { + return m_RunPostBuildEvent; + } + set + { + m_RunPostBuildEvent = value; + } + } + + [OptionNode("RunScript")] + private string m_RunScript; + + /// + /// + /// + public string RunScript + { + get + { + return m_RunScript; + } + set + { + m_RunScript = value; + } + } + + [OptionNode("WarningLevel")] + private int m_WarningLevel = 4; + + /// + /// + /// + public int WarningLevel + { + get + { + return m_WarningLevel; + } + set + { + m_WarningLevel = value; + } + } + + [OptionNode("WarningsAsErrors")] + private bool m_WarningsAsErrors; + + /// + /// + /// + public bool WarningsAsErrors + { + get + { + return m_WarningsAsErrors; + } + set + { + m_WarningsAsErrors = value; + } + } + + [OptionNode("SuppressWarnings")] + private string m_SuppressWarnings = ""; + + /// + /// + /// + public string SuppressWarnings + { + get + { + return m_SuppressWarnings; + } + set + { + m_SuppressWarnings = value; + } + } + + [OptionNode("OutputPath")] + private string m_OutputPath = "bin/"; + + /// + /// + /// + public string OutputPath + { + get + { + return m_OutputPath; + } + set + { + m_OutputPath = value; + } + } + + [OptionNode("GenerateDocumentation")] + private bool m_GenerateDocumentation; + + /// + /// + /// + public bool GenerateDocumentation + { + get + { + return m_GenerateDocumentation; + } + set + { + m_GenerateDocumentation = value; + } + } + + [OptionNode("GenerateXmlDocFile")] + private bool m_GenerateXmlDocFile; + + /// + /// + /// + public bool GenerateXmlDocFile + { + get + { + return m_GenerateXmlDocFile; + } + set + { + m_GenerateXmlDocFile = value; + } + } + + [OptionNode("XmlDocFile")] + private string m_XmlDocFile = ""; + + /// + /// + /// + public string XmlDocFile + { + get + { + return m_XmlDocFile; + } + set + { + m_XmlDocFile = value; + } + } + + [OptionNode("KeyFile")] + private string m_KeyFile = ""; + + /// + /// + /// + public string KeyFile + { + get + { + return m_KeyFile; + } + set + { + m_KeyFile = value; + } + } + + [OptionNode("DebugInformation")] + private bool m_DebugInformation; + + /// + /// + /// + public bool DebugInformation + { + get + { + return m_DebugInformation; + } + set + { + m_DebugInformation = value; + } + } + + [OptionNode("RegisterComInterop")] + private bool m_RegisterComInterop; + + /// + /// + /// + public bool RegisterComInterop + { + get + { + return m_RegisterComInterop; + } + set + { + m_RegisterComInterop = value; + } + } + + [OptionNode("RemoveIntegerChecks")] + private bool m_RemoveIntegerChecks; + + /// + /// + /// + public bool RemoveIntegerChecks + { + get + { + return m_RemoveIntegerChecks; + } + set + { + m_RemoveIntegerChecks = value; + } + } + + [OptionNode("IncrementalBuild")] + private bool m_IncrementalBuild; + + /// + /// + /// + public bool IncrementalBuild + { + get + { + return m_IncrementalBuild; + } + set + { + m_IncrementalBuild = value; + } + } + + [OptionNode("BaseAddress")] + private string m_BaseAddress = "285212672"; + + /// + /// + /// + public string BaseAddress + { + get + { + return m_BaseAddress; + } + set + { + m_BaseAddress = value; + } + } + + [OptionNode("FileAlignment")] + private int m_FileAlignment = 4096; + + /// + /// + /// + public int FileAlignment + { + get + { + return m_FileAlignment; + } + set + { + m_FileAlignment = value; + } + } + + [OptionNode("NoStdLib")] + private bool m_NoStdLib; + + /// + /// + /// + public bool NoStdLib + { + get + { + return m_NoStdLib; + } + set + { + m_NoStdLib = value; + } + } + + private StringCollection m_FieldsDefined; + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static OptionsNode() + { + Type t = typeof(OptionsNode); + + m_OptionFields = new Hashtable(); + foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) + { + object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); + if(attrs == null || attrs.Length < 1) + { + continue; + } + + OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; + m_OptionFields[ona.NodeName] = f; + } + } + + /// + /// Initializes a new instance of the class. + /// + public OptionsNode() + { + m_FieldsDefined = new StringCollection(); + } + + #endregion + + #region Properties + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index] + { + get + { + if(!m_OptionFields.ContainsKey(index)) + { + return null; + } + + FieldInfo f = (FieldInfo)m_OptionFields[index]; + return f.GetValue(this); + } + } + + /// + /// Gets the at the specified index. + /// + /// + public object this[string index, object defaultValue] + { + get + { + object valueObject = this[index]; + if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) + { + return defaultValue; + } + return valueObject; + } + } + + + #endregion + + #region Private Methods + + private void FlagDefined(string name) + { + if(!m_FieldsDefined.Contains(name)) + { + m_FieldsDefined.Add(name); + } + } + + private void SetOption(string nodeName, string val) + { + lock(m_OptionFields) + { + if(!m_OptionFields.ContainsKey(nodeName)) + { + return; + } + + FieldInfo f = (FieldInfo)m_OptionFields[nodeName]; + f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); + FlagDefined(f.Name); + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); + } + } + + /// + /// Copies to. + /// + /// The opt. + public void CopyTo(OptionsNode opt) + { + if(opt == null) + { + return; + } + + foreach(FieldInfo f in m_OptionFields.Values) + { + if(m_FieldsDefined.Contains(f.Name)) + { + f.SetValue(opt, f.GetValue(this)); + opt.m_FieldsDefined.Add(f.Name); + } + } + } + + #endregion + } +} 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 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Process")] + public class ProcessNode : DataNode + { + #region Fields + + private string m_Path; + private bool m_IsValid = true; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether this instance is valid. + /// + /// true if this instance is valid; otherwise, false. + public bool IsValid + { + get + { + return m_IsValid; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + try + { + m_Path = Helper.ResolvePath(m_Path); + } + catch(ArgumentException) + { + Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); + m_IsValid = false; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs new file mode 100644 index 0000000..7ac0a36 --- /dev/null +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -0,0 +1,490 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-11-11 05:43:20 +0100 (lö, 11 nov 2006) $ + * $Revision: 192 $ + */ +#endregion + +using System; +using System.Collections; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + public enum ProjectType + { + /// + /// + /// + Exe, + /// + /// + /// + WinExe, + /// + /// + /// + Library + } + + /// + /// + /// + public enum ClrRuntime + { + /// + /// + /// + Microsoft, + /// + /// + /// + Mono + } + + /// + /// + /// + [DataNode("Project")] + public class ProjectNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_AssemblyName; + private string m_AppIcon = ""; + private string m_DesignerFolder = ""; + private string m_Language = "C#"; + private ProjectType m_Type = ProjectType.Exe; + private ClrRuntime m_Runtime = ClrRuntime.Microsoft; + private string m_StartupObject = ""; + private string m_RootNamespace; + private string m_FilterGroups = ""; + private Guid m_Guid; + + private Hashtable m_Configurations; + private ArrayList m_ReferencePaths; + private ArrayList m_References; + private FilesNode m_Files; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ProjectNode() + { + m_Configurations = new Hashtable(); + m_ReferencePaths = new ArrayList(); + m_References = new ArrayList(); + } + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the filter groups. + /// + /// The filter groups. + public string FilterGroups + { + get + { + return m_FilterGroups; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the name of the assembly. + /// + /// The name of the assembly. + public string AssemblyName + { + get + { + return m_AssemblyName; + } + } + + /// + /// Gets the app icon. + /// + /// The app icon. + public string AppIcon + { + get + { + return m_AppIcon; + } + } + + /// + /// + /// + public string DesignerFolder + { + get + { + return m_DesignerFolder; + } + } + + /// + /// Gets the language. + /// + /// The language. + public string Language + { + get + { + return m_Language; + } + } + + /// + /// Gets the type. + /// + /// The type. + public ProjectType Type + { + get + { + return m_Type; + } + } + + /// + /// Gets the runtime. + /// + /// The runtime. + public ClrRuntime Runtime + { + get + { + return m_Runtime; + } + } + + private bool m_GenerateAssemblyInfoFile = false; + + /// + /// + /// + public bool GenerateAssemblyInfoFile + { + get + { + return m_GenerateAssemblyInfoFile; + } + set + { + m_GenerateAssemblyInfoFile = value; + } + } + + /// + /// Gets the startup object. + /// + /// The startup object. + public string StartupObject + { + get + { + return m_StartupObject; + } + } + + /// + /// Gets the root namespace. + /// + /// The root namespace. + public string RootNamespace + { + get + { + return m_RootNamespace; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ICollection Configurations + { + get + { + return m_Configurations.Values; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Hashtable ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the reference paths. + /// + /// The reference paths. + public ArrayList ReferencePaths + { + get + { + return m_ReferencePaths; + } + } + + /// + /// Gets the references. + /// + /// The references. + public ArrayList References + { + get + { + return m_References; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets or sets the parent. + /// + /// The parent. + public override IDataNode Parent + { + get + { + return base.Parent; + } + set + { + base.Parent = value; + if(base.Parent is SolutionNode && m_Configurations.Count < 1) + { + SolutionNode parent = (SolutionNode)base.Parent; + foreach(ConfigurationNode conf in parent.Configurations) + { + m_Configurations[conf.Name] = conf.Clone(); + } + } + } + } + + /// + /// Gets the GUID. + /// + /// The GUID. + public Guid Guid + { + get + { + return m_Guid; + } + } + + #endregion + + #region Private Methods + + private void HandleConfiguration(ConfigurationNode conf) + { + if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, + //so it *may* override changes to the same properties for configurations defines at the project level + { + foreach(ConfigurationNode confNode in this.m_Configurations.Values) + { + conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides + } + } + if(m_Configurations.ContainsKey(conf.Name)) + { + ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name]; + conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides + } + else + { + m_Configurations[conf.Name] = conf; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); + m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); + m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); + m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); + m_Language = Helper.AttributeValue(node, "language", m_Language); + m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); + m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); + m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); + m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); + m_Guid = Guid.NewGuid(); + m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); + + if(m_AssemblyName == null || m_AssemblyName.Length < 1) + { + m_AssemblyName = m_Name; + } + + if(m_RootNamespace == null || m_RootNamespace.Length < 1) + { + m_RootNamespace = m_Name; + } + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve Solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is ConfigurationNode) + { + HandleConfiguration((ConfigurationNode)dataNode); + } + else if(dataNode is ReferencePathNode) + { + m_ReferencePaths.Add(dataNode); + } + else if(dataNode is ReferenceNode) + { + m_References.Add(dataNode); + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs new file mode 100644 index 0000000..beb50dc --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs @@ -0,0 +1,143 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-07-25 18:56:49 +0200 (ti, 25 jul 2006) $ + * $Revision: 132 $ + */ +#endregion + +using System; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Reference")] + public class ReferenceNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path; + private string m_LocalCopy; + private string m_Version; + + #endregion + + #region Properties + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets a value indicating whether [local copy specified]. + /// + /// true if [local copy specified]; otherwise, false. + public bool LocalCopySpecified + { + get + { + return ( m_LocalCopy != null && m_LocalCopy.Length == 0); + } + } + + /// + /// Gets a value indicating whether [local copy]. + /// + /// true if [local copy]; otherwise, false. + public bool LocalCopy + { + get + { + if( m_LocalCopy == null) + { + return false; + } + return bool.Parse(m_LocalCopy); + } + } + + /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Path = Helper.AttributeValue(node, "path", m_Path); + m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); + m_Version = Helper.AttributeValue(node, "version", m_Version); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs new file mode 100644 index 0000000..5d98dda --- /dev/null +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs @@ -0,0 +1,98 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Revision: 71 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("ReferencePath")] + public class ReferencePathNode : DataNode + { + #region Fields + + private string m_Path; + + #endregion + + #region Properties + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Path == null) + { + m_Path = ""; + } + + m_Path = m_Path.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs new file mode 100644 index 0000000..0121075 --- /dev/null +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs @@ -0,0 +1,284 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-02-28 17:15:42 +0100 (ti, 28 feb 2006) $ + * $Revision: 92 $ + */ +#endregion + +using System; +using System.Collections; +using System.Diagnostics; +using System.IO; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Solution")] + public class SolutionNode : DataNode + { + #region Fields + + private string m_Name = "unknown"; + private string m_Path = ""; + private string m_FullPath = ""; + private string m_ActiveConfig = "Debug"; + + private OptionsNode m_Options; + private FilesNode m_Files; + private Hashtable m_Configurations; + private Hashtable m_Projects; + private ArrayList m_ProjectsOrder; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public SolutionNode() + { + m_Configurations = new Hashtable(); + m_Projects = new Hashtable(); + m_ProjectsOrder = new ArrayList(); + } + + #endregion + + #region Properties + + /// + /// Gets or sets the active config. + /// + /// The active config. + public string ActiveConfig + { + get + { + return m_ActiveConfig; + } + set + { + m_ActiveConfig = value; + } + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return m_Name; + } + } + + /// + /// Gets the path. + /// + /// The path. + public string Path + { + get + { + return m_Path; + } + } + + /// + /// Gets the full path. + /// + /// The full path. + public string FullPath + { + get + { + return m_FullPath; + } + } + + /// + /// Gets the options. + /// + /// The options. + public OptionsNode Options + { + get + { + return m_Options; + } + } + + /// + /// Gets the files. + /// + /// The files. + public FilesNode Files + { + get + { + return m_Files; + } + } + + /// + /// Gets the configurations. + /// + /// The configurations. + public ICollection Configurations + { + get + { + return m_Configurations.Values; + } + } + + /// + /// Gets the configurations table. + /// + /// The configurations table. + public Hashtable ConfigurationsTable + { + get + { + return m_Configurations; + } + } + + /// + /// Gets the projects. + /// + /// The projects. + public ICollection Projects + { + get + { + return m_Projects.Values; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public Hashtable ProjectsTable + { + get + { + return m_Projects; + } + } + + /// + /// Gets the projects table. + /// + /// The projects table. + public ArrayList ProjectsTableOrder + { + get + { + return m_ProjectsOrder; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + m_Name = Helper.AttributeValue(node, "name", m_Name); + m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); + m_Path = Helper.AttributeValue(node, "path", m_Path); + + m_FullPath = m_Path; + try + { + m_FullPath = Helper.ResolvePath(m_FullPath); + } + catch + { + throw new WarningException("Could not resolve solution path: {0}", m_Path); + } + + Kernel.Instance.CurrentWorkingDirectory.Push(); + try + { + Helper.SetCurrentDir(m_FullPath); + + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + foreach(XmlNode child in node.ChildNodes) + { + IDataNode dataNode = Kernel.Instance.ParseNode(child, this); + if(dataNode is OptionsNode) + { + m_Options = (OptionsNode)dataNode; + } + else if(dataNode is FilesNode) + { + m_Files = (FilesNode)dataNode; + } + else if(dataNode is ConfigurationNode) + { + m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode; + } + else if(dataNode is ProjectNode) + { + m_Projects[((ProjectNode)dataNode).Name] = dataNode; + m_ProjectsOrder.Add(dataNode); + } + } + } + finally + { + Kernel.Instance.CurrentWorkingDirectory.Pop(); + } + } + + #endregion + } +} -- cgit v1.1