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/Attributes/DataNodeAttribute.cs | 11 +- .../src/Core/Attributes/OptionNodeAttribute.cs | 9 + Prebuild/src/Core/Attributes/TargetAttribute.cs | 9 + Prebuild/src/Core/FatalException.cs | 9 + Prebuild/src/Core/Interfaces/IDataNode.cs | 9 + Prebuild/src/Core/Interfaces/ITarget.cs | 9 + Prebuild/src/Core/Kernel.cs | 149 ++-- Prebuild/src/Core/Nodes/AuthorNode.cs | 9 + Prebuild/src/Core/Nodes/ConfigurationNode.cs | 9 + Prebuild/src/Core/Nodes/DataNode.cs | 59 +- Prebuild/src/Core/Nodes/DatabaseProjectNode.cs | 94 --- Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs | 63 -- Prebuild/src/Core/Nodes/DescriptionNode.cs | 9 + Prebuild/src/Core/Nodes/ExcludeNode.cs | 9 + Prebuild/src/Core/Nodes/FileNode.cs | 42 +- Prebuild/src/Core/Nodes/FilesNode.cs | 14 +- Prebuild/src/Core/Nodes/MatchNode.cs | 51 +- Prebuild/src/Core/Nodes/OptionsNode.cs | 11 + Prebuild/src/Core/Nodes/ProcessNode.cs | 9 + Prebuild/src/Core/Nodes/ProjectNode.cs | 169 ++-- Prebuild/src/Core/Nodes/ReferenceNode.cs | 9 + Prebuild/src/Core/Nodes/ReferencePathNode.cs | 9 + Prebuild/src/Core/Nodes/SolutionNode.cs | 120 +-- Prebuild/src/Core/Parse/IfContext.cs | 9 + Prebuild/src/Core/Parse/Preprocessor.cs | 272 +++---- Prebuild/src/Core/Targets/AutotoolsTarget.cs | 112 +-- Prebuild/src/Core/Targets/DebugTarget.cs | 2 +- Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 9 + Prebuild/src/Core/Targets/NAntTarget.cs | 859 ++++++++++---------- Prebuild/src/Core/Targets/SharpDevelop2Target.cs | 33 +- Prebuild/src/Core/Targets/SharpDevelopTarget.cs | 9 + Prebuild/src/Core/Targets/ToolInfo.cs | 197 ----- Prebuild/src/Core/Targets/VS2002Target.cs | 9 + Prebuild/src/Core/Targets/VS2003Target.cs | 31 + Prebuild/src/Core/Targets/VS2005Target.cs | 837 +++++++++++++++++++- Prebuild/src/Core/Targets/VS2008Target.cs | 152 +--- Prebuild/src/Core/Targets/VSGenericTarget.cs | 881 --------------------- Prebuild/src/Core/Targets/VSVersion.cs | 50 -- Prebuild/src/Core/Targets/XcodeTarget.cs | 9 + .../src/Core/Utilities/CommandLineCollection.cs | 9 + Prebuild/src/Core/Utilities/CurrentDirectory.cs | 9 + Prebuild/src/Core/Utilities/Helper.cs | 25 +- Prebuild/src/Core/Utilities/Log.cs | 9 + 43 files changed, 1966 insertions(+), 2448 deletions(-) delete mode 100644 Prebuild/src/Core/Nodes/DatabaseProjectNode.cs delete mode 100644 Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs delete mode 100644 Prebuild/src/Core/Targets/ToolInfo.cs delete mode 100644 Prebuild/src/Core/Targets/VSGenericTarget.cs delete mode 100644 Prebuild/src/Core/Targets/VSVersion.cs (limited to 'Prebuild/src/Core') diff --git a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs index f1938a2..cdd0e0d 100644 --- a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Collections.Specialized; @@ -31,7 +40,7 @@ namespace Prebuild.Core.Attributes /// /// /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=true)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] public sealed class DataNodeAttribute : Attribute { #region Fields diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs index 2d6a6a7..5cefe68 100644 --- a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; namespace Prebuild.Core.Attributes diff --git a/Prebuild/src/Core/Attributes/TargetAttribute.cs b/Prebuild/src/Core/Attributes/TargetAttribute.cs index 5ad62ee..b17cc5b 100644 --- a/Prebuild/src/Core/Attributes/TargetAttribute.cs +++ b/Prebuild/src/Core/Attributes/TargetAttribute.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; namespace Prebuild.Core.Attributes diff --git a/Prebuild/src/Core/FatalException.cs b/Prebuild/src/Core/FatalException.cs index 3487905..784c35d 100644 --- a/Prebuild/src/Core/FatalException.cs +++ b/Prebuild/src/Core/FatalException.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Runtime.Serialization; diff --git a/Prebuild/src/Core/Interfaces/IDataNode.cs b/Prebuild/src/Core/Interfaces/IDataNode.cs index 986dd2d..7583fd2 100644 --- a/Prebuild/src/Core/Interfaces/IDataNode.cs +++ b/Prebuild/src/Core/Interfaces/IDataNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Xml; diff --git a/Prebuild/src/Core/Interfaces/ITarget.cs b/Prebuild/src/Core/Interfaces/ITarget.cs index 47115c6..77006d7 100644 --- a/Prebuild/src/Core/Interfaces/ITarget.cs +++ b/Prebuild/src/Core/Interfaces/ITarget.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; namespace Prebuild.Core.Interfaces 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"]; diff --git a/Prebuild/src/Core/Nodes/AuthorNode.cs b/Prebuild/src/Core/Nodes/AuthorNode.cs index 20e72c0..03ea934 100644 --- a/Prebuild/src/Core/Nodes/AuthorNode.cs +++ b/Prebuild/src/Core/Nodes/AuthorNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source $ + * $Author: $ + * $Date: $ + * $Revision: $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs index 67d78d5..828bff6 100644 --- a/Prebuild/src/Core/Nodes/ConfigurationNode.cs +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Xml; diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs index 763e6c3..60ed122 100644 --- a/Prebuild/src/Core/Nodes/DataNode.cs +++ b/Prebuild/src/Core/Nodes/DataNode.cs @@ -23,24 +23,31 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; -using System.IO; namespace Prebuild.Core.Nodes { /// /// /// - public abstract class DataNode : IDataNode + public class DataNode : IDataNode { #region Fields private IDataNode parent; - string[] m_WebTypes = new string[] { "aspx", "ascx", "master", "ashx", "asmx" }; #endregion @@ -61,10 +68,7 @@ namespace Prebuild.Core.Nodes parent = value; } } - public string[] WebTypes - { - get { return m_WebTypes; } - } + /// /// Parses the specified node. /// @@ -72,46 +76,7 @@ namespace Prebuild.Core.Nodes public virtual void Parse(XmlNode node) { } - public BuildAction GetBuildActionByFileName(string fileName) - { - string extension = Path.GetExtension(fileName).ToLower(); - foreach (string type in WebTypes) - { - if (extension == type) - return BuildAction.Content; - } - return BuildAction.Compile; - } - /// - /// Parses the file type to figure out what type it is - /// - /// - public SubType GetSubTypeByFileName(string fileName) - { - string extension = System.IO.Path.GetExtension(fileName).ToLower(); - string designer = String.Format(".designer{0}", extension); - string path = fileName.ToLower(); - if (extension == ".resx") - { - return SubType.Designer; - } - else if (path.EndsWith(".settings")) - { - return SubType.Settings; - } - else - { - - foreach (string type in WebTypes) - { - if (path.EndsWith(string.Format("{0}{1}", type, extension))) - { - return SubType.CodeBehind; - } - } - } - return SubType.Code; - } + #endregion } } diff --git a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs deleted file mode 100644 index 8696a79..0000000 --- a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Xml; - -using Prebuild.Core.Attributes; -using Prebuild.Core.Interfaces; -using Prebuild.Core.Utilities; - -namespace Prebuild.Core.Nodes -{ - [DataNode("DatabaseProject")] - public class DatabaseProjectNode : DataNode - { - string name; - string path; - string fullpath; - Guid guid = Guid.NewGuid(); - readonly List authors = new List(); - readonly List references = new List(); - - public Guid Guid - { - get { return guid; } - } - - public string Name - { - get { return name; } - } - - public string Path - { - get { return path; } - } - - public string FullPath - { - get { return fullpath; } - } - - public IEnumerable References - { - get { return references; } - } - - public override void Parse(XmlNode node) - { - name = Helper.AttributeValue(node, "name", name); - path = Helper.AttributeValue(node, "path", name); - - try - { - fullpath = Helper.ResolvePath(path); - } - catch - { - throw new WarningException("Could not resolve Solution path: {0}", path); - } - - Kernel.Instance.CurrentWorkingDirectory.Push(); - - try - { - Helper.SetCurrentDir(fullpath); - - if (node == null) - { - throw new ArgumentNullException("node"); - } - - foreach (XmlNode child in node.ChildNodes) - { - IDataNode dataNode = Kernel.Instance.ParseNode(child, this); - - if (dataNode == null) - continue; - - if (dataNode is AuthorNode) - authors.Add((AuthorNode)dataNode); - else if (dataNode is DatabaseReferenceNode) - references.Add((DatabaseReferenceNode)dataNode); - } - } - finally - { - Kernel.Instance.CurrentWorkingDirectory.Pop(); - } - - base.Parse(node); - } - } -} diff --git a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs deleted file mode 100644 index 97c3964..0000000 --- a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using Prebuild.Core.Attributes; -using Prebuild.Core.Utilities; - -namespace Prebuild.Core.Nodes -{ - [DataNode("DatabaseReference")] - public class DatabaseReferenceNode : DataNode - { - string name; - Guid providerId; - string connectionString; - - public string Name - { - get { return name; } - } - - public Guid ProviderId - { - get { return providerId; } - } - - public string ConnectionString - { - get { return connectionString; } - } - - public override void Parse(System.Xml.XmlNode node) - { - name = Helper.AttributeValue(node, "name", name); - - string providerName = Helper.AttributeValue(node, "providerName", string.Empty); - if (providerName != null) - { - switch (providerName) - { - // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* - // Not sure if these will help other operating systems, or if there's a better way. - case "Microsoft.SqlServerCe.Client.3.5": - providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; - case "System.Data.OleDb": - providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; - case "System.Data.OracleClient": - providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; - case "System.Data.SqlClient": - providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; - case "System.Data.Odbc": - providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; - - default: - throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); - } - } - else - providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); - - connectionString = Helper.AttributeValue(node, "connectionString", connectionString); - - base.Parse(node); - } - } -} diff --git a/Prebuild/src/Core/Nodes/DescriptionNode.cs b/Prebuild/src/Core/Nodes/DescriptionNode.cs index 353a5ae..cff7afc 100644 --- a/Prebuild/src/Core/Nodes/DescriptionNode.cs +++ b/Prebuild/src/Core/Nodes/DescriptionNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source $ + * $Author: $ + * $Date: $ + * $Revision: $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs index 7f04cba..afc869d 100644 --- a/Prebuild/src/Core/Nodes/ExcludeNode.cs +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ + */ +#endregion + using System; using System.Xml; diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs index 1520fcb..083dba5 100644 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ b/Prebuild/src/Core/Nodes/FileNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ + */ +#endregion + using System; using System.IO; using System.Xml; @@ -30,7 +39,6 @@ using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; using Prebuild.Core.Utilities; -using Prebuild.Core.Targets; namespace Prebuild.Core.Nodes { @@ -85,11 +93,7 @@ namespace Prebuild.Core.Nodes /// /// /// - UserControl, - /// - /// - /// - CodeBehind, + UserControl } public enum CopyToOutput @@ -109,9 +113,9 @@ namespace Prebuild.Core.Nodes private string m_Path; private string m_ResourceName = ""; - private BuildAction? m_BuildAction; + private BuildAction m_BuildAction = BuildAction.Compile; private bool m_Valid; - private SubType? m_SubType; + private SubType m_SubType = SubType.Code; private CopyToOutput m_CopyToOutput = CopyToOutput.Never; private bool m_Link = false; private string m_LinkPath = string.Empty; @@ -151,11 +155,7 @@ namespace Prebuild.Core.Nodes { get { - if (m_BuildAction != null) - return m_BuildAction.Value; - else - return GetBuildActionByFileName(this.Path); - + return m_BuildAction; } } @@ -189,10 +189,7 @@ namespace Prebuild.Core.Nodes { get { - if (m_SubType != null) - return m_SubType.Value; - else - return GetSubTypeByFileName(this.Path); + return m_SubType; } } @@ -230,13 +227,10 @@ namespace Prebuild.Core.Nodes /// public override void Parse(XmlNode node) { - string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); - if (buildAction != string.Empty) - m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); - string subType = Helper.AttributeValue(node, "subType", string.Empty); - if (subType != String.Empty) - m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); - + 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)); if ( this.m_Link == true ) diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs index dc306c2..7c1dd19 100644 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; @@ -30,7 +39,6 @@ using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; -using System.IO; namespace Prebuild.Core.Nodes { @@ -216,8 +224,8 @@ namespace Prebuild.Core.Nodes if (!m_Files.Contains(file)) { m_Files.Add(file); - m_BuildActions[ file ] = matchNode.BuildAction == null ? GetBuildActionByFileName(file) : matchNode.BuildAction; - m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; + m_BuildActions[ file ] = matchNode.BuildAction; + m_SubTypes[ file ] = matchNode.SubType; m_ResourceNames[ file ] = matchNode.ResourceName; this.m_PreservePaths[ file ] = matchNode.PreservePath; this.m_Links[ file ] = matchNode.IsLink; diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs index 656d7d0..aeaf3c1 100644 --- a/Prebuild/src/Core/Nodes/MatchNode.cs +++ b/Prebuild/src/Core/Nodes/MatchNode.cs @@ -23,8 +23,16 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ + */ +#endregion + using System; -using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Text.RegularExpressions; @@ -45,16 +53,29 @@ namespace Prebuild.Core.Nodes { #region Fields - private readonly StringCollection m_Files = new StringCollection(); + private StringCollection m_Files; private Regex m_Regex; - private BuildAction? m_BuildAction; - private SubType? m_SubType; + private BuildAction m_BuildAction = BuildAction.Compile; + private SubType m_SubType = SubType.Code; string m_ResourceName = ""; private CopyToOutput m_CopyToOutput; private bool m_Link; private string m_LinkPath; private bool m_PreservePath; - private readonly List m_Exclusions = new List(); + private ArrayList m_Exclusions; + + #endregion + + #region Constructors + + /// + /// + /// + public MatchNode() + { + m_Files = new StringCollection(); + m_Exclusions = new ArrayList(); + } #endregion @@ -74,7 +95,7 @@ namespace Prebuild.Core.Nodes /// /// /// - public BuildAction? BuildAction + public BuildAction BuildAction { get { @@ -85,7 +106,7 @@ namespace Prebuild.Core.Nodes /// /// /// - public SubType? SubType + public SubType SubType { get { @@ -146,7 +167,7 @@ namespace Prebuild.Core.Nodes /// The pattern. /// if set to true [recurse]. /// if set to true [use regex]. - private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, List exclusions) + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, ArrayList exclusions) { Match match; Boolean excludeFile; @@ -258,14 +279,10 @@ namespace Prebuild.Core.Nodes 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")); - string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); - if (buildAction != string.Empty) - m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); - - //TODO: Figure out where the subtype node is being assigned - //string subType = Helper.AttributeValue(node, "subType", string.Empty); - //if (subType != String.Empty) - // m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); + 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)); @@ -312,7 +329,7 @@ namespace Prebuild.Core.Nodes if(dataNode is ExcludeNode) { ExcludeNode excludeNode = (ExcludeNode)dataNode; - m_Exclusions.Add( excludeNode ); + m_Exclusions.Add( dataNode ); } } diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs index b63034b..651c339 100644 --- a/Prebuild/src/Core/Nodes/OptionsNode.cs +++ b/Prebuild/src/Core/Nodes/OptionsNode.cs @@ -23,6 +23,17 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-01-09 01:55:40 +0900 (Tue, 09 Jan 2007) $ + * $Revision: 197 $ + */ +#endregion + + + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs index 6bfbe16..2d2162c 100644 --- a/Prebuild/src/Core/Nodes/ProcessNode.cs +++ b/Prebuild/src/Core/Nodes/ProcessNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs index 0a24abf..e98ab5f 100644 --- a/Prebuild/src/Core/Nodes/ProjectNode.cs +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -23,9 +23,17 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-05-26 06:58:26 +0900 (Sat, 26 May 2007) $ + * $Revision: 244 $ + */ +#endregion + using System; using System.Collections; -using System.Collections.Generic; using System.IO; using System.Xml; @@ -51,11 +59,7 @@ namespace Prebuild.Core.Nodes /// /// The project is a library /// - Library, - /// - /// The project is a website - /// - Web, + Library } /// @@ -72,25 +76,7 @@ namespace Prebuild.Core.Nodes /// Mono } - /// - /// The version of the .NET framework to use (Required for VS2008) - /// We don't need .NET 1.1 in here, it'll default when using vs2003. - /// - public enum FrameworkVersion - { - /// - /// .NET 2.0 - /// - v2_0, - /// - /// .NET 3.0 - /// - v3_0, - /// - /// .NET 3.5 - /// - v3_5, - } + /// /// The Node object representing /Prebuild/Solution/Project elements /// @@ -109,45 +95,49 @@ namespace Prebuild.Core.Nodes private string m_Language = "C#"; private ProjectType m_Type = ProjectType.Exe; private ClrRuntime m_Runtime = ClrRuntime.Microsoft; - private FrameworkVersion m_Framework = FrameworkVersion.v2_0; private string m_StartupObject = ""; private string m_RootNamespace; private string m_FilterGroups = ""; private string m_Version = ""; private Guid m_Guid; - private string m_DebugStartParameters; - private Hashtable m_Configurations = new Hashtable(); - private readonly List m_ReferencePaths = new List(); - private readonly List m_References = new List(); - private readonly List m_Authors = new List(); + private Hashtable m_Configurations; + private ArrayList m_ReferencePaths; + private ArrayList m_References; + private ArrayList m_Authors; private FilesNode m_Files; #endregion - #region Properties + #region Constructors /// - /// Gets the name. + /// Initializes a new instance of the class. /// - /// The name. - public string Name + public ProjectNode() { - get - { - return m_Name; - } + m_Configurations = new Hashtable(); + m_ReferencePaths = new ArrayList(); + m_References = new ArrayList(); + m_Authors = new ArrayList(); } + + #endregion + + #region Properties + /// - /// The version of the .NET Framework to compile under + /// Gets the name. /// - public FrameworkVersion FrameworkVersion + /// The name. + public string Name { get { - return this.m_Framework; + return m_Name; } } + /// /// Gets the path. /// @@ -220,17 +210,17 @@ namespace Prebuild.Core.Nodes } } - /// - /// Gets the app icon. - /// - /// The app icon. - public string ConfigFile - { - get - { - return m_ConfigFile; - } - } + /// + /// Gets the app icon. + /// + /// The app icon. + public string ConfigFile + { + get + { + return m_ConfigFile; + } + } /// /// @@ -279,22 +269,22 @@ namespace Prebuild.Core.Nodes } } - private bool m_GenerateAssemblyInfoFile = false; - - /// - /// - /// - public bool GenerateAssemblyInfoFile - { - get - { - return m_GenerateAssemblyInfoFile; - } - set - { - m_GenerateAssemblyInfoFile = value; - } - } + private bool m_GenerateAssemblyInfoFile = false; + + /// + /// + /// + public bool GenerateAssemblyInfoFile + { + get + { + return m_GenerateAssemblyInfoFile; + } + set + { + m_GenerateAssemblyInfoFile = value; + } + } /// /// Gets the startup object. @@ -324,7 +314,7 @@ namespace Prebuild.Core.Nodes /// Gets the configurations. /// /// The configurations. - public IList Configurations + public ICollection Configurations { get { @@ -350,11 +340,11 @@ namespace Prebuild.Core.Nodes /// Gets the reference paths. /// /// The reference paths. - public List ReferencePaths + public ArrayList ReferencePaths { get { - List tmp = new List(m_ReferencePaths); + ArrayList tmp = new ArrayList(m_ReferencePaths); tmp.Sort(); return tmp; } @@ -364,11 +354,11 @@ namespace Prebuild.Core.Nodes /// Gets the references. /// /// The references. - public List References + public ArrayList References { get { - List tmp = new List(m_References); + ArrayList tmp = new ArrayList(m_References); tmp.Sort(); return tmp; } @@ -378,7 +368,7 @@ namespace Prebuild.Core.Nodes /// Gets the Authors list. /// /// The list of the project's authors. - public List Authors + public ArrayList Authors { get { @@ -434,15 +424,7 @@ namespace Prebuild.Core.Nodes } } - public string DebugStartParameters - { - get - { - return m_DebugStartParameters; - } - } - - #endregion + #endregion #region Private Methods @@ -488,18 +470,13 @@ namespace Prebuild.Core.Nodes 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_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework); m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); - + m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); + int hash = m_Name.GetHashCode(); - Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString()); - m_Guid = new Guid(guid); + m_Guid = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); - m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty); - if(m_AssemblyName == null || m_AssemblyName.Length < 1) { m_AssemblyName = m_Name; @@ -539,15 +516,15 @@ namespace Prebuild.Core.Nodes } else if(dataNode is ReferencePathNode) { - m_ReferencePaths.Add((ReferencePathNode)dataNode); + m_ReferencePaths.Add(dataNode); } else if(dataNode is ReferenceNode) { - m_References.Add((ReferenceNode)dataNode); + m_References.Add(dataNode); } else if(dataNode is AuthorNode) { - m_Authors.Add((AuthorNode)dataNode); + m_Authors.Add(dataNode); } else if(dataNode is FilesNode) { @@ -571,6 +548,6 @@ namespace Prebuild.Core.Nodes return this.m_Name.CompareTo(that.m_Name); } - #endregion + #endregion } } diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs index 9c5d1a3..df0c2e4 100644 --- a/Prebuild/src/Core/Nodes/ReferenceNode.cs +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-07-26 01:56:49 +0900 (Wed, 26 Jul 2006) $ + * $Revision: 132 $ + */ +#endregion + using System; using System.Xml; diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs index f0543c2..d4042ef 100644 --- a/Prebuild/src/Core/Nodes/ReferencePathNode.cs +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs index 2a1b8e2..9473fe6 100644 --- a/Prebuild/src/Core/Nodes/SolutionNode.cs +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs @@ -23,9 +23,17 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-03-01 01:15:42 +0900 (Wed, 01 Mar 2006) $ + * $Revision: 92 $ + */ +#endregion + using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Xml; @@ -40,62 +48,40 @@ namespace Prebuild.Core.Nodes /// /// [DataNode("Solution")] - [DataNode("EmbeddedSolution")] - [DebuggerDisplay("{Name}")] public class SolutionNode : DataNode { #region Fields - - private Guid m_Guid = Guid.NewGuid(); + private string m_Name = "unknown"; private string m_Path = ""; private string m_FullPath = ""; private string m_ActiveConfig = "Debug"; private string m_Version = "1.0.0"; - + private OptionsNode m_Options; private FilesNode m_Files; - private readonly Hashtable m_Configurations = new Hashtable(); - private readonly Hashtable m_Projects = new Hashtable(); - private readonly Hashtable m_DatabaseProjects = new Hashtable(); - private readonly List m_ProjectsOrder = new List(); - private readonly Hashtable m_Solutions = new Hashtable(); + 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 - public override IDataNode Parent - { - get - { - return base.Parent; - } - set - { - if (value is SolutionNode) - { - SolutionNode solution = (SolutionNode)value; - foreach (ConfigurationNode conf in solution.Configurations) - { - m_Configurations[conf.Name] = conf.Clone(); - } - } - - base.Parent = value; - } - } - - public Guid Guid - { - get - { - return m_Guid; - } - set - { - m_Guid = value; - } - } + /// /// Gets or sets the active config. /// @@ -209,36 +195,7 @@ namespace Prebuild.Core.Nodes return m_Configurations; } } - /// - /// Gets the database projects. - /// - public ICollection DatabaseProjects - { - get - { - return m_DatabaseProjects.Values; - } - } - /// - /// Gets the nested solutions. - /// - public ICollection Solutions - { - get - { - return m_Solutions.Values; - } - } - /// - /// Gets the nested solutions hash table. - /// - public Hashtable SolutionsTable - { - get - { - return this.m_Solutions; - } - } + /// /// Gets the projects. /// @@ -269,7 +226,7 @@ namespace Prebuild.Core.Nodes /// Gets the projects table. /// /// The projects table. - public List ProjectsTableOrder + public ArrayList ProjectsTableOrder { get { @@ -330,21 +287,8 @@ namespace Prebuild.Core.Nodes else if(dataNode is ProjectNode) { m_Projects[((ProjectNode)dataNode).Name] = dataNode; - m_ProjectsOrder.Add((ProjectNode)dataNode); + m_ProjectsOrder.Add(dataNode); } - else if(dataNode is SolutionNode) - { - m_Solutions[((SolutionNode)dataNode).Name] = dataNode; - } - else if (dataNode is ProcessNode) - { - ProcessNode p = (ProcessNode)dataNode; - Kernel.Instance.ProcessFile(p, this); - } - else if (dataNode is DatabaseProjectNode) - { - m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = dataNode; - } } } finally diff --git a/Prebuild/src/Core/Parse/IfContext.cs b/Prebuild/src/Core/Parse/IfContext.cs index 3c79d38..fc86885 100644 --- a/Prebuild/src/Core/Parse/IfContext.cs +++ b/Prebuild/src/Core/Parse/IfContext.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; namespace Prebuild.Core.Parse diff --git a/Prebuild/src/Core/Parse/Preprocessor.cs b/Prebuild/src/Core/Parse/Preprocessor.cs index 013f8e1..eea5c30 100644 --- a/Prebuild/src/Core/Parse/Preprocessor.cs +++ b/Prebuild/src/Core/Parse/Preprocessor.cs @@ -23,10 +23,18 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-04-26 17:10:27 +0900 (Thu, 26 Apr 2007) $ + * $Revision: 236 $ + */ +#endregion + using System; using System.Collections; using System.IO; -using System.Text.RegularExpressions; using System.Xml; namespace Prebuild.Core.Parse @@ -71,16 +79,6 @@ namespace Prebuild.Core.Parse /// public class Preprocessor { - #region Constants - - /// - /// Includes the regex to look for file tags in the processing instruction. - /// - private static readonly Regex includeFileRegex = new Regex("file=\"(.+?)\""); - - #endregion - #region Fields XmlDocument m_OutDoc; @@ -140,10 +138,10 @@ namespace Prebuild.Core.Parse return "Win32"; } - if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) - { - return "MACOSX"; - } + if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) + { + return "MACOSX"; + } /* * .NET 1.x, under Mono, the UNIX code is 128. Under @@ -238,7 +236,7 @@ namespace Prebuild.Core.Parse OperatorSymbol oper = OperatorSymbol.None; bool inStr = false; char c; - + for(int i = 0; i < exp.Length; i++) { c = exp[i]; @@ -285,7 +283,7 @@ namespace Prebuild.Core.Parse { oper = OperatorSymbol.NotEqual; } - + break; case '<': @@ -297,7 +295,7 @@ namespace Prebuild.Core.Parse { oper = OperatorSymbol.LessThan; } - + break; case '>': @@ -316,7 +314,7 @@ namespace Prebuild.Core.Parse } } - + if(inStr) { throw new WarningException("Expected end of string in expression"); @@ -394,9 +392,9 @@ namespace Prebuild.Core.Parse /// For invalid use of conditional expressions or for invalid XML syntax. If a XmlValidatingReader is passed, then will also throw exceptions for non-schema-conforming xml /// /// the output xml - public string Process(XmlReader initialReader) + public string Process(XmlReader reader) { - if(initialReader == null) + if(reader == null) { throw new ArgumentException("Invalid XML reader to pre-process"); } @@ -405,175 +403,119 @@ namespace Prebuild.Core.Parse StringWriter xmlText = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(xmlText); writer.Formatting = Formatting.Indented; - - // Create a queue of XML readers and add the initial - // reader to it. Then we process until we run out of - // readers which lets the operation add more - // readers to generate a multi-file parser and not require - // XML fragments that a recursive version would use. - Stack readerStack = new Stack(); - readerStack.Push(initialReader); - - while(readerStack.Count > 0) + while(reader.Read()) { - // Pop off the next reader. - XmlReader reader = (XmlReader) readerStack.Pop(); - - // Process through this XML reader until it is - // completed (or it is replaced by the include - // operation). - while(reader.Read()) + if(reader.NodeType == XmlNodeType.ProcessingInstruction) { - // The prebuild file has a series of processing - // instructions which allow for specific - // inclusions based on operating system or to - // include additional files. - if(reader.NodeType == XmlNodeType.ProcessingInstruction) + bool ignore = false; + switch(reader.LocalName) { - bool ignore = false; - - switch(reader.LocalName) - { - case "include": - // use regular expressions to parse out the attributes. - MatchCollection matches = includeFileRegex.Matches(reader.Value); - - // make sure there is only one file attribute. - if(matches.Count > 1) - { - throw new WarningException("An node was found, but it specified more than one file."); - } - - if(matches.Count == 0) - { - throw new WarningException("An node was found, but it did not specify the file attribute."); - } - - // Pull the file out from the regex and make sure it is a valid file before using it. - string filename = matches[0].Groups[1].Value; - FileInfo includeFile = new FileInfo(filename); - - if(!includeFile.Exists) - { - throw new WarningException("Cannot include file: " + includeFile.FullName); - } - - // Create a new reader object for this file. Then put the old reader back on the stack and start - // processing using this new XML reader. - XmlReader newReader = new XmlTextReader(includeFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read)); - - readerStack.Push(reader); - reader = newReader; - ignore = true; - break; - - case "if": - m_IfStack.Push(context); - context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); - ignore = true; - break; - - case "elseif": - if(m_IfStack.Count == 0) - { - throw new WarningException("Unexpected 'elseif' outside of 'if'"); - } - else if(context.State != IfState.If && context.State != IfState.ElseIf) - { - throw new WarningException("Unexpected 'elseif' outside of 'if'"); - } + case "if": + m_IfStack.Push(context); + context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); + ignore = true; + break; - context.State = IfState.ElseIf; - if(!context.EverKept) - { - context.Keep = ParseExpression(reader.Value); - } - else - { - context.Keep = false; - } + case "elseif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } + else if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'elseif' outside of 'if'"); + } - ignore = true; - break; + context.State = IfState.ElseIf; + if(!context.EverKept) + { + context.Keep = ParseExpression(reader.Value); + } + else + { + context.Keep = false; + } - case "else": - if(m_IfStack.Count == 0) - { - throw new WarningException("Unexpected 'else' outside of 'if'"); - } - else if(context.State != IfState.If && context.State != IfState.ElseIf) - { - throw new WarningException("Unexpected 'else' outside of 'if'"); - } + ignore = true; + break; - context.State = IfState.Else; - context.Keep = !context.EverKept; - ignore = true; - break; + case "else": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } + else if(context.State != IfState.If && context.State != IfState.ElseIf) + { + throw new WarningException("Unexpected 'else' outside of 'if'"); + } - case "endif": - if(m_IfStack.Count == 0) - { - throw new WarningException("Unexpected 'endif' outside of 'if'"); - } + context.State = IfState.Else; + context.Keep = !context.EverKept; + ignore = true; + break; - context = (IfContext)m_IfStack.Pop(); - ignore = true; - break; - } + case "endif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'endif' outside of 'if'"); + } - if(ignore) - { - continue; - } - }//end pre-proc instruction + context = (IfContext)m_IfStack.Pop(); + ignore = true; + break; + } - if(!context.Active || !context.Keep) + if(ignore) { continue; } + }//end pre-proc instruction - switch(reader.NodeType) - { - case XmlNodeType.Element: - bool empty = reader.IsEmptyElement; - writer.WriteStartElement(reader.Name); + if(!context.Active || !context.Keep) + { + continue; + } - while (reader.MoveToNextAttribute()) - { - writer.WriteAttributeString(reader.Name, reader.Value); - } + switch(reader.NodeType) + { + case XmlNodeType.Element: + bool empty = reader.IsEmptyElement; + writer.WriteStartElement(reader.Name); - if(empty) - { - writer.WriteEndElement(); - } - - break; + while (reader.MoveToNextAttribute()) + { + writer.WriteAttributeString(reader.Name, reader.Value); + } - case XmlNodeType.EndElement: + if(empty) + { writer.WriteEndElement(); - break; + } + + break; - case XmlNodeType.Text: - writer.WriteString(reader.Value); - break; + case XmlNodeType.EndElement: + writer.WriteEndElement(); + break; - case XmlNodeType.CDATA: - writer.WriteCData(reader.Value); - break; + case XmlNodeType.Text: + writer.WriteString(reader.Value); + break; - default: - break; - } - } + case XmlNodeType.CDATA: + writer.WriteCData(reader.Value); + break; - if(m_IfStack.Count != 0) - { - throw new WarningException("Mismatched 'if', 'endif' pair"); + default: + break; } } - + + if(m_IfStack.Count != 0) + { + throw new WarningException("Mismatched 'if', 'endif' pair"); + } + return xmlText.ToString(); } diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs index 5dcbb38..f102038 100644 --- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs @@ -65,9 +65,18 @@ POSSIBILITY OF SUCH DAMAGE. */ #endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-07-28 22:43:24 -0700 (Fri, 28 Jul 2006) $ + * $Revision: 136 $ + */ +#endregion + using System; using System.Collections; -using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Reflection; @@ -173,7 +182,8 @@ namespace Prebuild.Core.Targets Hashtable assemblyPathToPackage = new Hashtable(); Hashtable assemblyFullNameToPath = new Hashtable(); Hashtable packagesHash = new Hashtable(); - readonly List packages = new List(); + ArrayList packages = new ArrayList(); + ClrVersion currentVersion; #endregion @@ -193,6 +203,22 @@ namespace Prebuild.Core.Targets di.Create(); } + private void mkStubFiles(string dirName, ArrayList fileNames) + { + for (int i = 0; i < fileNames.Count; i++) + { + string tmpFile = dirName + "/" + (string)fileNames[i]; + + FileStream tmpFileStream = + new FileStream(tmpFile, FileMode.Create); + + StreamWriter sw = new StreamWriter(tmpFileStream); + sw.WriteLine("These are not the files you are looking for."); + sw.Flush(); + tmpFileStream.Close(); + } + } + private void chkMkDir(string dirName) { System.IO.DirectoryInfo di = @@ -247,11 +273,11 @@ namespace Prebuild.Core.Targets } } - private List GetAssembliesWithLibInfo(string line, string file) + private ArrayList GetAssembliesWithLibInfo(string line, string file) { - List references = new List(); - List libdirs = new List(); - List retval = new List(); + ArrayList references = new ArrayList(); + ArrayList libdirs = new ArrayList(); + ArrayList retval = new ArrayList(); foreach (string piece in line.Split(' ')) { if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) @@ -278,9 +304,9 @@ namespace Prebuild.Core.Targets return retval; } - private List GetAssembliesWithoutLibInfo(string line, string file) + private ArrayList GetAssembliesWithoutLibInfo(string line, string file) { - List references = new List(); + ArrayList references = new ArrayList(); foreach (string reference in line.Split(' ')) { if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) @@ -330,7 +356,7 @@ namespace Prebuild.Core.Targets if (packagesHash.Contains(pname)) return; - List fullassemblies = null; + ArrayList fullassemblies = null; string version = ""; string desc = ""; @@ -378,7 +404,7 @@ namespace Prebuild.Core.Targets package.Initialize(pname, version, desc, - fullassemblies.ToArray(), + (string[])fullassemblies.ToArray(typeof(string)), ClrVersion.Default, false); packages.Add(package); @@ -388,7 +414,7 @@ namespace Prebuild.Core.Targets void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) { SystemPackage package = new SystemPackage(); - List list = new List(); + ArrayList list = new ArrayList(); string dir = Path.Combine(prefix, version); if (!Directory.Exists(dir)) @@ -405,7 +431,7 @@ namespace Prebuild.Core.Targets package.Initialize("mono", version, "The Mono runtime", - list.ToArray(), + (string[])list.ToArray(typeof(string)), ver, false); packages.Add(package); @@ -418,10 +444,12 @@ namespace Prebuild.Core.Targets if (Environment.Version.Major == 1) { versionDir = "1.0"; + currentVersion = ClrVersion.Net_1_1; } else { versionDir = "2.0"; + currentVersion = ClrVersion.Net_2_0; } //Pull up assemblies from the installed mono system. @@ -455,9 +483,9 @@ namespace Prebuild.Core.Targets } } search_dirs += Path.PathSeparator + libpath; - if (!string.IsNullOrEmpty(search_dirs)) + if (search_dirs != null && search_dirs.Length > 0) { - List scanDirs = new List(); + ArrayList scanDirs = new ArrayList(); foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) { if (!scanDirs.Contains(potentialDir)) @@ -735,22 +763,20 @@ namespace Prebuild.Core.Targets bool hasAssemblyConfig = false; chkMkDir(projectDir); - List - compiledFiles = new List(), - contentFiles = new List(), - embeddedFiles = new List(), - - binaryLibs = new List(), - pkgLibs = new List(), - systemLibs = new List(), - runtimeLibs = new List(), + ArrayList + compiledFiles = new ArrayList(), + contentFiles = new ArrayList(), + embeddedFiles = new ArrayList(), - extraDistFiles = new List(), - localCopyTargets = new List(); + binaryLibs = new ArrayList(), + pkgLibs = new ArrayList(), + systemLibs = new ArrayList(), + runtimeLibs = new ArrayList(), - // If there exists a .config file for this assembly, copy - // it to the project folder + extraDistFiles = new ArrayList(), + localCopyTargets = new ArrayList(); + // If there exists a .config file for this assembly, copy it to the project folder // TODO: Support copying .config.osx files // TODO: support processing the .config file for native library deps string projectAssemblyName = project.Name; @@ -813,15 +839,11 @@ namespace Prebuild.Core.Targets foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) Console.WriteLine("Error! '{0}'", error.ErrorText); - try { - string projectFullName = cr.CompiledAssembly.FullName; - Regex verRegex = new Regex("Version=([\\d\\.]+)"); - Match verMatch = verRegex.Match(projectFullName); - if (verMatch.Success) + string projectFullName = cr.CompiledAssembly.FullName; + Regex verRegex = new Regex("Version=([\\d\\.]+)"); + Match verMatch = verRegex.Match(projectFullName); + if (verMatch.Success) projectVersion = verMatch.Groups[1].Value; - }catch{ - Console.WriteLine("Couldn't compile AssemblyInfo.cs"); - } // Clean up the temp file try @@ -831,7 +853,7 @@ namespace Prebuild.Core.Targets } catch { - Console.WriteLine("Error! '{0}'", e.ToString()); + //Console.WriteLine("Error! '{0}'", e.ToString()); } } @@ -991,46 +1013,46 @@ namespace Prebuild.Core.Targets } } - const string lineSep = " \\\n\t"; + string lineSep = " \\\n\t"; string compiledFilesString = string.Empty; if (compiledFiles.Count > 0) compiledFilesString = - lineSep + string.Join(lineSep, compiledFiles.ToArray()); + lineSep + string.Join(lineSep, (string[])compiledFiles.ToArray(typeof(string))); string embeddedFilesString = ""; if (embeddedFiles.Count > 0) embeddedFilesString = - lineSep + string.Join(lineSep, embeddedFiles.ToArray()); + lineSep + string.Join(lineSep, (string[])embeddedFiles.ToArray(typeof(string))); string contentFilesString = ""; if (contentFiles.Count > 0) contentFilesString = - lineSep + string.Join(lineSep, contentFiles.ToArray()); + lineSep + string.Join(lineSep, (string[])contentFiles.ToArray(typeof(string))); string extraDistFilesString = ""; if (extraDistFiles.Count > 0) extraDistFilesString = - lineSep + string.Join(lineSep, extraDistFiles.ToArray()); + lineSep + string.Join(lineSep, (string[])extraDistFiles.ToArray(typeof(string))); string pkgLibsString = ""; if (pkgLibs.Count > 0) pkgLibsString = - lineSep + string.Join(lineSep, pkgLibs.ToArray()); + lineSep + string.Join(lineSep, (string[])pkgLibs.ToArray(typeof(string))); string binaryLibsString = ""; if (binaryLibs.Count > 0) binaryLibsString = - lineSep + string.Join(lineSep, binaryLibs.ToArray()); + lineSep + string.Join(lineSep, (string[])binaryLibs.ToArray(typeof(string))); string systemLibsString = ""; if (systemLibs.Count > 0) systemLibsString = - lineSep + string.Join(lineSep, systemLibs.ToArray()); + lineSep + string.Join(lineSep, (string[])systemLibs.ToArray(typeof(string))); string localCopyTargetsString = ""; if (localCopyTargets.Count > 0) localCopyTargetsString = - string.Join("\n", localCopyTargets.ToArray()); + string.Join("\n", (string[])localCopyTargets.ToArray(typeof(string))); string monoPath = ""; foreach (string runtimeLib in runtimeLibs) diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs index dc4e666..db19e05 100644 --- a/Prebuild/src/Core/Targets/DebugTarget.cs +++ b/Prebuild/src/Core/Targets/DebugTarget.cs @@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O /* * $Source$ * $Author: jendave $ - * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Date: 2006-09-20 16:42:51 +0900 (Wed, 20 Sep 2006) $ * $Revision: 164 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index c8401fd..5a5dc55 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: cjcollier $ + * $Date: 2007-04-11 07:10:35 +0900 (Wed, 11 Apr 2007) $ + * $Revision: 231 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs index 9a6ee17..eb5325d 100644 --- a/Prebuild/src/Core/Targets/NAntTarget.cs +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -1,9 +1,9 @@ #region BSD License /* Copyright (c) 2004 - 2008 -Matthew Holmes (matthew@wildfiregames.com), -Dan Moorehead (dan05a@gmail.com), -C.J. Adams-Collier (cjac@colliertech.org), +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +C.J. Adams-Collier (cjac@colliertech.org), Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -35,6 +35,15 @@ POSSIBILITY OF SUCH DAMAGE. #endregion +#region CVS Information +/* + * $Source$ + * $Author: cjcollier $ + * $Date: 2008-02-07 10:22:36 +0900 (Thu, 07 Feb 2008) $ + * $Revision: 255 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; @@ -49,73 +58,85 @@ using Prebuild.Core.Utilities; namespace Prebuild.Core.Targets { - /// - /// - /// - [Target("nant")] - public class NAntTarget : ITarget - { - #region Fields - - private Kernel m_Kernel; - - #endregion - - #region Private Methods - - private static string PrependPath(string path) - { - string tmpPath = Helper.NormalizePath(path, '/'); - Regex regex = new Regex(@"(\w):/(\w+)"); - Match match = regex.Match(tmpPath); - //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') - //{ - tmpPath = Helper.NormalizePath(tmpPath); - //} - // else - // { - // tmpPath = Helper.NormalizePath("./" + tmpPath); - // } - - return tmpPath; - } + /// + /// + /// + [Target("nant")] + public class NAntTarget : ITarget + { + #region Fields + + private Kernel m_Kernel; + + #endregion + + #region Private Methods + + private static string PrependPath(string path) + { + string tmpPath = Helper.NormalizePath(path, '/'); + Regex regex = new Regex(@"(\w):/(\w+)"); + Match match = regex.Match(tmpPath); + //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') + //{ + tmpPath = Helper.NormalizePath(tmpPath); + //} + // else + // { + // tmpPath = Helper.NormalizePath("./" + tmpPath); + // } + + return tmpPath; + } private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) { + string ret = ""; + string referencePath = ((ReferencePathNode)currentProject.ReferencePaths[0]).Path; - if (!String.IsNullOrEmpty(refr.Path)) + if (String.IsNullOrEmpty(refr.Path)) { - return refr.Path; - } - - if (solution.ProjectsTable.ContainsKey(refr.Name)) - { - ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name]; - string finalPath = - Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/'); - return finalPath; - } + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode) solution.ProjectsTable[refr.Name]; + string finalPath = + Helper.NormalizePath(referencePath + refr.Name + GetProjectExtension(project), '/'); + return finalPath; + } + else + { + ProjectNode project = (ProjectNode) refr.Parent; - ProjectNode project = (ProjectNode) refr.Parent; + // Do we have an explicit file reference? + string fileRef = FindFileReference(refr.Name, project); + if (fileRef != null) + { + return fileRef; + } - // Do we have an explicit file reference? - string fileRef = FindFileReference(refr.Name, project); - if (fileRef != null) - { - return fileRef; - } + // Is there an explicit path in the project ref? + if (refr.Path != null) + { + return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); + } - // Is there an explicit path in the project ref? - if (refr.Path != null) + // Is it a specified extension (dll or exe?) + if (ExtensionSpecified(refr.Name)) + { + return Helper.NormalizePath(referencePath + GetRefFileName(refr.Name), '/'); + } + + // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway + return refr.Name + ".dll"; + } + } + else { - return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); + return refr.Path; } - - // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway - return refr.Name + ".dll"; } - public static string GetRefFileName(string refName) + public static string GetRefFileName(string refName) { if (ExtensionSpecified(refName)) { @@ -123,7 +144,7 @@ namespace Prebuild.Core.Targets } else { - return refName + ".dll"; + return refName + ".dll"; } } @@ -135,235 +156,268 @@ namespace Prebuild.Core.Targets private static string GetProjectExtension(ProjectNode project) { string extension = ".dll"; - if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) + if (project.Type == ProjectType.Exe) { extension = ".exe"; } return extension; } - private static string FindFileReference(string refName, ProjectNode project) - { - foreach (ReferencePathNode refPath in project.ReferencePaths) - { - string fullPath = Helper.MakeFilePath(refPath.Path, refName); + //private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + //{ + // string ret = ""; + // if (solution.ProjectsTable.ContainsKey(refr.Name)) + // { + // ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + // string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); + // return finalPath; + // } + // else + // { + // if (refr.Path == null) + // { + // ProjectNode project = (ProjectNode) refr.Parent; + // string fileRef = FindFileReference(refr.Name, project); + + // if (refr.Path != null || fileRef != null) + // { + // string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; + // ret += finalPath; + // return ret; + // } + + // try + // { + // Assembly assem = Assembly.Load(refr.Name); + // if (assem != null) + // { + // ret += ""; + // } + // else + // { + // ret += ""; + // } + // } + // catch (System.NullReferenceException e) + // { + // e.ToString(); + // ret += ""; + // } + // } + // else + // { + // ret = refr.Path; + // } + // } + // return ret; + //} + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); if (File.Exists(fullPath)) { return fullPath; } - fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); - - if (File.Exists(fullPath)) - { - return fullPath; - } - fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe"); if (File.Exists(fullPath)) { return fullPath; } - } - - return null; - } - - /// - /// Gets the XML doc file. - /// - /// The project. - /// The conf. - /// - public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) - { - if (conf == null) - { - throw new ArgumentNullException("conf"); - } - if (project == null) - { - throw new ArgumentNullException("project"); - } - string docFile = (string)conf.Options["XmlDocFile"]; - // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified - // { - // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; - // } - return docFile; - } - - private void WriteProject(SolutionNode solution, ProjectNode project) - { + } + + return null; + } + + /// + /// Gets the XML doc file. + /// + /// The project. + /// The conf. + /// + public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) + { + if (conf == null) + { + throw new ArgumentNullException("conf"); + } + if (project == null) + { + throw new ArgumentNullException("project"); + } + string docFile = (string)conf.Options["XmlDocFile"]; + // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified + // { + // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; + // } + return docFile; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build"); - StreamWriter ss = new StreamWriter(projFile); - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); - bool hasDoc = false; - - using (ss) - { - ss.WriteLine(""); - ss.WriteLine("", project.Name); - ss.WriteLine(" ", "build"); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - foreach (ReferenceNode refr in project.References) - { - if (refr.LocalCopy) - { - ss.WriteLine(" ", '/')); - } - } - - ss.WriteLine(" "); - ss.WriteLine(" "); - if (project.ConfigFile != null && project.ConfigFile.Length!=0) - { - ss.Write(" "); - } - - // Add the content files to just be copied - ss.WriteLine(" {0}", ""); - ss.WriteLine(" {0}", ""); - - foreach (string file in project.Files) - { - // Ignore if we aren't content - if (project.Files.GetBuildAction(file) != BuildAction.Content) - continue; - - // Create a include tag - ss.WriteLine(" {0}", ""); - } - - ss.WriteLine(" {0}", ""); - ss.WriteLine(" {0}", ""); - - ss.Write(" "); - ss.WriteLine(" ", project.RootNamespace); - foreach (string file in project.Files) - { - switch (project.Files.GetBuildAction(file)) - { - case BuildAction.EmbeddedResource: - ss.WriteLine(" {0}", ""); - break; - default: - if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) - { - ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); - } - break; - } - } - //if (project.Files.GetSubType(file).ToString() != "Code") - //{ - // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); - - ss.WriteLine(" "); - ss.WriteLine(" "); - foreach (string file in project.Files) - { - switch (project.Files.GetBuildAction(file)) - { - case BuildAction.Compile: - ss.WriteLine(" "); - break; - default: - break; - } - } - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - foreach(ReferencePathNode refPath in project.ReferencePaths) + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + bool hasDoc = false; + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", project.Name); + ss.WriteLine(" ", "build"); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (refr.LocalCopy) + { + ss.WriteLine(" ", '/')); + } + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + if (project.ConfigFile != null && project.ConfigFile.Length!=0) + { + ss.Write(" "); + } + + // Add the content files to just be copied + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + foreach (string file in project.Files) + { + // Ignore if we aren't content + if (project.Files.GetBuildAction(file) != BuildAction.Content) + continue; + + // Create a include tag + ss.WriteLine(" {0}", ""); + } + + ss.WriteLine(" {0}", ""); + ss.WriteLine(" {0}", ""); + + ss.Write(" "); + ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); + break; } - ss.WriteLine(" "); - foreach (ReferenceNode refr in project.References) - { - string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); + foreach (ConfigurationNode conf in project.Configurations) + { + ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors); + break; + } + foreach (ConfigurationNode conf in project.Configurations) + { + ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); + break; + } + ss.Write(" main=\"{0}\"", project.StartupObject); + + foreach (ConfigurationNode conf in project.Configurations) + { + if (GetXmlDocFile(project, conf) != "") + { + ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); + hasDoc = true; + } + break; + } + ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); + if (project.Type == ProjectType.Library) + { + ss.Write(".dll\""); + } + else + { + ss.Write(".exe\""); + } + if (project.AppIcon != null && project.AppIcon.Length != 0) + { + ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); + } + ss.WriteLine(">"); + ss.WriteLine(" ", project.RootNamespace); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.WriteLine(" {0}", ""); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + } + break; + } + } + //if (project.Files.GetSubType(file).ToString() != "Code") + //{ + // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine(" "); + break; + default: + break; + } + } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); ss.WriteLine(" "); - } - ss.WriteLine(" "); + } + ss.WriteLine(" "); - ss.WriteLine(" "); + ss.WriteLine(" "); - foreach (ConfigurationNode conf in project.Configurations) + foreach (ConfigurationNode conf in project.Configurations) { if (!String.IsNullOrEmpty(conf.Options.OutputPath)) { @@ -378,160 +432,149 @@ namespace Prebuild.Core.Targets ss.WriteLine(" "); ss.WriteLine(" "); ss.WriteLine(" "); - ss.WriteLine(" "); ss.WriteLine(" "); ss.WriteLine(" "); break; } } - ss.WriteLine(" "); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - - ss.WriteLine(" "); - if (hasDoc) - { - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.Write(" "); - } - else - { - ss.WriteLine(".exe\" />"); - } - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - // foreach(ReferenceNode refr in project.References) - // { - // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); - // if (path != "") - // { - // ss.WriteLine(" ", path); - // } - // } - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - } - ss.WriteLine(" "); - ss.WriteLine(""); - } - m_Kernel.CurrentWorkingDirectory.Pop(); - } - - private void WriteCombine(SolutionNode solution) - { - m_Kernel.Log.Write("Creating NAnt build files"); - foreach (ProjectNode project in solution.Projects) - { - if (m_Kernel.AllowProject(project.FilterGroups)) - { - m_Kernel.Log.Write("...Creating project: {0}", project.Name); - WriteProject(solution, project); - } - } - - m_Kernel.Log.Write(""); - string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); - StreamWriter ss = new StreamWriter(combFile); - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); - - using (ss) - { - ss.WriteLine(""); - ss.WriteLine("", solution.Name); - ss.WriteLine(" "); - ss.WriteLine(); - - //ss.WriteLine(" "); - //ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + if (hasDoc) + { + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.Write(" "); + } + else + { + ss.WriteLine(".exe\" />"); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + // foreach(ReferenceNode refr in project.References) + // { + // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); + // if (path != "") + // { + // ss.WriteLine(" ", path); + // } + // } + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + } + ss.WriteLine(" "); + ss.WriteLine(""); + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating NAnt build files"); + foreach (ProjectNode project in solution.Projects) + { + if (m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + ss.WriteLine(""); + ss.WriteLine("", solution.Name); + ss.WriteLine(" "); + ss.WriteLine(); + + //ss.WriteLine(" "); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); // actually use active config out of prebuild.xml ss.WriteLine(" ", solution.ActiveConfig); - foreach (ConfigurationNode conf in solution.Configurations) - { - ss.WriteLine(); - ss.WriteLine(" ", conf.Name); - ss.WriteLine(" ", conf.Name); - ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); - ss.WriteLine(" "); - ss.WriteLine(); - } - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); - - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - ss.WriteLine(); + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine(); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Name); + ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower()); + ss.WriteLine(" "); + ss.WriteLine(); + } + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); ss.WriteLine(" "); ss.WriteLine(" "); diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs index 66dd1bc..0d78796 100644 --- a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-27 16:49:58 -0800 (Fri, 27 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using Prebuild.Core.Attributes; @@ -34,38 +43,18 @@ namespace Prebuild.Core.Targets /// [Target("sharpdev2")] public class SharpDevelop2Target : VS2005Target - { - #region Properties - public override string VersionName + { + protected override string VersionName { get { return "SharpDevelop2"; } } - #endregion #region Public Methods /// - /// Writes the specified kern. - /// - /// The kern. - public override void Write(Kernel kern) - { - base.Write(kern); - } - - /// - /// Cleans the specified kern. - /// - /// The kern. - public override void Clean(Kernel kern) - { - base.Clean(kern); - } - - /// /// Gets the name. /// /// The name. diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs index cf7ce02..6fe038b 100644 --- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $ + * $Revision: 205 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Targets/ToolInfo.cs b/Prebuild/src/Core/Targets/ToolInfo.cs deleted file mode 100644 index 935c674..0000000 --- a/Prebuild/src/Core/Targets/ToolInfo.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Prebuild.Core.Targets -{ - /// - /// - /// - public struct ToolInfo - { - string name; - string guid; - string fileExtension; - string xmlTag; - string importProject; - - /// - /// Gets or sets the name. - /// - /// The name. - public string Name - { - get - { - return name; - } - set - { - name = value; - } - } - - /// - /// Gets or sets the GUID. - /// - /// The GUID. - public string Guid - { - get - { - return guid; - } - set - { - guid = value; - } - } - - /// - /// Gets or sets the file extension. - /// - /// The file extension. - public string FileExtension - { - get - { - return fileExtension; - } - set - { - fileExtension = value; - } - } - public string LanguageExtension - { - get - { - switch (this.Name) - { - case "C#": - return ".cs"; - case "VisualBasic": - return ".vb"; - case "Boo": - return ".boo"; - default: - return ".cs"; - } - } - } - /// - /// Gets or sets the XML tag. - /// - /// The XML tag. - public string XmlTag - { - get - { - return xmlTag; - } - set - { - xmlTag = value; - } - } - - /// - /// Gets or sets the import project property. - /// - /// The ImportProject tag. - public string ImportProject - { - get - { - return importProject; - } - set - { - importProject = value; - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The GUID. - /// The file extension. - /// The XML. - /// The import project. - public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) - { - this.name = name; - this.guid = guid; - this.fileExtension = fileExtension; - this.xmlTag = xml; - this.importProject = importProject; - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The GUID. - /// The file extension. - /// The XML. - public ToolInfo(string name, string guid, string fileExtension, string xml) - { - this.name = name; - this.guid = guid; - this.fileExtension = fileExtension; - this.xmlTag = xml; - this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; - } - - /// - /// Equals operator - /// - /// ToolInfo to compare - /// true if toolInfos are equal - public override bool Equals(object obj) - { - if (obj == null) - { - throw new ArgumentNullException("obj"); - } - if (obj.GetType() != typeof(ToolInfo)) - return false; - - ToolInfo c = (ToolInfo)obj; - return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); - } - - /// - /// Equals operator - /// - /// ToolInfo to compare - /// ToolInfo to compare - /// True if toolInfos are equal - public static bool operator ==(ToolInfo c1, ToolInfo c2) - { - return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); - } - - /// - /// Not equals operator - /// - /// ToolInfo to compare - /// ToolInfo to compare - /// True if toolInfos are not equal - public static bool operator !=(ToolInfo c1, ToolInfo c2) - { - return !(c1 == c2); - } - - /// - /// Hash Code - /// - /// Hash code - public override int GetHashCode() - { - return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); - - } - } -} diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs index 2292624..7067cf3 100644 --- a/Prebuild/src/Core/Targets/VS2002Target.cs +++ b/Prebuild/src/Core/Targets/VS2002Target.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using Prebuild.Core.Attributes; diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs index 1bcb7dc..4bf05cb 100644 --- a/Prebuild/src/Core/Targets/VS2003Target.cs +++ b/Prebuild/src/Core/Targets/VS2003Target.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-09-30 04:11:40 +0900 (Sat, 30 Sep 2006) $ + * $Revision: 177 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; @@ -35,6 +44,28 @@ using Prebuild.Core.Utilities; namespace Prebuild.Core.Targets { + /// + /// + /// + public enum VSVersion + { + /// + /// + /// + VS70, + /// + /// + /// + VS71, + /// + /// + /// + VS80 + } + + /// + /// + /// [Target("vs2003")] public class VS2003Target : ITarget { diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs index 63461c9..5b7ad07 100644 --- a/Prebuild/src/Core/Targets/VS2005Target.cs +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; @@ -39,8 +48,182 @@ namespace Prebuild.Core.Targets /// /// /// + public struct ToolInfo + { + string name; + string guid; + string fileExtension; + string xmlTag; + string importProject; + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name + { + get + { + return name; + } + set + { + name = value; + } + } + + /// + /// Gets or sets the GUID. + /// + /// The GUID. + public string Guid + { + get + { + return guid; + } + set + { + guid = value; + } + } + + /// + /// Gets or sets the file extension. + /// + /// The file extension. + public string FileExtension + { + get + { + return fileExtension; + } + set + { + fileExtension = value; + } + } + /// + /// Gets or sets the XML tag. + /// + /// The XML tag. + public string XmlTag + { + get + { + return xmlTag; + } + set + { + xmlTag = value; + } + } + + /// + /// Gets or sets the import project property. + /// + /// The ImportProject tag. + public string ImportProject + { + get + { + return importProject; + } + set + { + importProject = value; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + /// The import project. + public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = importProject; + } + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The GUID. + /// The file extension. + /// The XML. + public ToolInfo(string name, string guid, string fileExtension, string xml) + { + this.name = name; + this.guid = guid; + this.fileExtension = fileExtension; + this.xmlTag = xml; + this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// true if toolInfos are equal + public override bool Equals(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + if (obj.GetType() != typeof(ToolInfo)) + return false; + + ToolInfo c = (ToolInfo)obj; + return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); + } + + /// + /// Equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are equal + public static bool operator ==(ToolInfo c1, ToolInfo c2) + { + return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); + } + + /// + /// Not equals operator + /// + /// ToolInfo to compare + /// ToolInfo to compare + /// True if toolInfos are not equal + public static bool operator !=(ToolInfo c1, ToolInfo c2) + { + return !(c1 == c2); + } + + /// + /// Hash Code + /// + /// Hash code + public override int GetHashCode() + { + return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); + + } + } + + /// + /// + /// [Target("vs2005")] - public class VS2005Target : VSGenericTarget + public class VS2005Target : ITarget { #region Inner Classes @@ -48,100 +231,694 @@ namespace Prebuild.Core.Targets #region Fields - string solutionVersion = "9.00"; - string productVersion = "8.0.50727"; string schemaVersion = "2.0"; - string versionName = "Visual C# 2005"; - string name = "vs2005"; - VSVersion version = VSVersion.VS80; - public override string SolutionTag + Hashtable tools; + Kernel kernel; + + protected virtual string ToolsVersionXml { - get { return "# Visual Studio 2005"; } + get + { + return String.Empty; + } } - protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + protected virtual string SolutionTag { - return string.Empty; + get { return "# Visual Studio 2005"; } } + /// /// Gets or sets the solution version. /// /// The solution version. - public override string SolutionVersion + protected virtual string SolutionVersion { get { - return solutionVersion; + return "9.00"; } } + /// /// Gets or sets the product version. /// /// The product version. - public override string ProductVersion + protected virtual string ProductVersion { get { - return productVersion; + return "8.0.50727"; } } + /// /// Gets or sets the schema version. /// /// The schema version. - public override string SchemaVersion + protected string SchemaVersion { get { - return schemaVersion; + return this.schemaVersion; + } + set + { + this.schemaVersion = value; } } + /// /// Gets or sets the name of the version. /// /// The name of the version. - public override string VersionName + protected virtual string VersionName { get { - return versionName; + return "Visual C# 2005"; } } + /// /// Gets or sets the version. /// /// The version. - public override VSVersion Version + protected VSVersion Version { get { - return version; + return this.version; + } + set + { + this.version = value; } } + + #endregion + + #region Constructors + /// - /// Gets the name. + /// Initializes a new instance of the class. /// - /// The name. - public override string Name + public VS2005Target() { - get + this.tools = new Hashtable(); + + this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); + this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); + this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach (ReferencePathNode node in project.ReferencePaths) { - return name; + try + { + string fullPath = Helper.ResolvePath(node.Path); + if (ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch (ArgumentException) + { + this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private static bool ExtensionSpecified(string refName) + { + return refName.EndsWith(".dll") || refName.EndsWith(".exe"); + } + + private static string GetProjectExtension(ProjectNode project) + { + string extension = ".dll"; + if (project.Type == ProjectType.Exe) + { + extension = ".exe"; + } + return extension; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + #region Project File + using (ps) + { + ps.WriteLine("", ToolsVersionXml); + //ps.WriteLine(" <{0}", toolInfo.XMLTag); + ps.WriteLine(" "); + ps.WriteLine(" Local"); + ps.WriteLine(" {0}", this.ProductVersion); + ps.WriteLine(" {0}", this.SchemaVersion); + ps.WriteLine(" {{{0}}}", project.Guid.ToString().ToUpper()); + + ps.WriteLine(" Debug"); + ps.WriteLine(" AnyCPU"); + //ps.WriteLine(" "); + + //ps.WriteLine(" {0}", project.AppIcon); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", project.AssemblyName); + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ps.WriteLine(" {0}", conf.Options.KeyFile); + ps.WriteLine(" true"); + break; + } + } + ps.WriteLine(" JScript"); + ps.WriteLine(" Grid"); + ps.WriteLine(" IE50"); + ps.WriteLine(" false"); + + //if(m_Version == VSVersion.VS70) + // ps.WriteLine(" NoStandardLibraries = \"false\""); + + ps.WriteLine(" {0}", project.Type.ToString()); + ps.WriteLine(" {0}", project.DesignerFolder); + ps.WriteLine(" {0}", project.RootNamespace); + ps.WriteLine(" {0}", project.StartupObject); + //ps.WriteLine(" >"); + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" ", conf.Name); + ps.WriteLine(" {0}", conf.Options["AllowUnsafe"]); + ps.WriteLine(" {0}", conf.Options["BaseAddress"]); + ps.WriteLine(" {0}", conf.Options["CheckUnderflowOverflow"]); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); + ps.WriteLine(" {0}", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); + ps.WriteLine(" {0}", conf.Options["DebugInformation"]); + ps.WriteLine(" {0}", conf.Options["FileAlignment"]); + // ps.WriteLine(" {0}", conf.Options["OptimizeCode"]); + ps.WriteLine(" {0}", + Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); + ps.WriteLine(" {0}", conf.Options["RegisterComInterop"]); + ps.WriteLine(" {0}", conf.Options["RemoveIntegerChecks"]); + ps.WriteLine(" {0}", conf.Options["WarningsAsErrors"]); + ps.WriteLine(" {0}", conf.Options["WarningLevel"]); + ps.WriteLine(" {0}", conf.Options["SuppressWarnings"]); + ps.WriteLine(" "); + } + + //ps.WriteLine(" "); + + // Assembly References + ps.WriteLine(" "); + string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path; + + foreach (ReferenceNode refr in project.References) + { + if (!solution.ProjectsTable.ContainsKey(refr.Name)) + { + ps.Write(" "); + + string path; + + if (String.IsNullOrEmpty(refr.Path)) + { + if ( ExtensionSpecified( refr.Name ) ) + { + path = Helper.NormalizePath(Path.Combine(refPath, refr.Name), '\\'); + } + else + { + path = refr.Name + ".dll"; + } + } + else + { + path = refr.Path; + } + + // TODO: Allow reference to *.exe files + ps.WriteLine(" {0}", path ); + ps.WriteLine(" {0}", refr.LocalCopy); + ps.WriteLine(" "); + } + } + ps.WriteLine(" "); + + //Project References + ps.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; + // TODO: Allow reference to visual basic projects + string path = + Helper.MakePathRelativeTo(project.FullPath, + Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj")); + ps.WriteLine(" ", path ); + // + ps.WriteLine(" {0}", refProject.Name); + // RealmForge.Utility + ps.WriteLine(" {{{0}}}", refProject.Guid.ToString().ToUpper()); + // {6880D1D3-69EE-461B-B841-5319845B20D3} + ps.WriteLine(" {0}", toolInfo.Guid.ToString().ToUpper()); + // {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ps.WriteLine("\t\t\t{0}", refr.LocalCopy); + ps.WriteLine(" "); + // + } + else + { + } + } + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ps.WriteLine(" "); + + // ps.WriteLine(" "); + ArrayList list = new ArrayList(); + foreach (string file in project.Files) + { + // if (file == "Properties\\Bind.Designer.cs") + // { + // Console.WriteLine("Wait a minute!"); + // Console.WriteLine(project.Files.GetSubType(file).ToString()); + // } + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + + int slash = file.LastIndexOf('\\'); + if (slash == -1) + { + ps.WriteLine(" {0}", file); + } + else + { + ps.WriteLine(" {0}", file.Substring(slash + 1, file.Length - slash - 1)); + } + ps.WriteLine(" Designer"); + ps.WriteLine(" "); + // + } + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) + { + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); + ps.WriteLine(" " + project.Files.GetSubType(file) + ""); + ps.WriteLine(" ResXFileCodeGenerator"); + ps.WriteLine(" Resources.Designer.cs"); + ps.WriteLine(" "); + ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + ps.WriteLine(" Resources.resx"); + ps.WriteLine(" "); + list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); + } + if (project.Files.GetSubType(file).ToString() == "Settings") + { + //Console.WriteLine("File: " + file); + //Console.WriteLine("Last index: " + file.LastIndexOf('.')); + //Console.WriteLine("Length: " + file.Length); + ps.Write(" <{0} ", project.Files.GetBuildAction(file)); + ps.WriteLine("Include=\"{0}\">", file); + int slash = file.LastIndexOf('\\'); + string fileName = file.Substring(slash + 1, file.Length - slash - 1); + if (project.Files.GetBuildAction(file) == BuildAction.None) + { + ps.WriteLine(" SettingsSingleFileGenerator"); + + //Console.WriteLine("FileName: " + fileName); + //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); + //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); + if (slash == -1) + { + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + else + { + ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); + } + } + else + { + ps.WriteLine(" Code"); + ps.WriteLine(" True"); + ps.WriteLine(" True"); + string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); + string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); + ps.WriteLine(" {0}", fileNameShorter + ".settings"); + } + ps.WriteLine(" ", project.Files.GetBuildAction(file)); + } + else if (project.Files.GetSubType(file) != SubType.Designer) + { + if (!list.Contains(file)) + { + ps.Write(" <{0} ", project.Files.GetBuildAction(file)); + + int startPos = 0; + if ( project.Files.GetPreservePath( file ) ) + { + while ( ( @"./\" ).IndexOf( file.Substring( startPos, 1 ) ) != -1 ) + startPos++; + + } + else + { + startPos = file.LastIndexOf( Path.GetFileName( file ) ); + } + ps.WriteLine("Include=\"{0}\">", Helper.NormalizePath(file)); + + + if (file.Contains("Designer.cs")) + { + string d = ".Designer.cs"; + int index = file.Contains("\\") ? file.IndexOf("\\") + 1 : 0; + ps.WriteLine(" {0}", file.Substring(index, file.Length - index - d.Length) + ".cs"); + } + + if (project.Files.GetIsLink(file)) + { + string alias = project.Files.GetLinkPath( file ); + alias += file.Substring( startPos ); + alias = Helper.NormalizePath( alias ); + ps.WriteLine( " {0}", alias ); + } + else if (project.Files.GetBuildAction(file) != BuildAction.None) + { + if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) + { + ps.WriteLine(" {0}", project.Files.GetSubType(file)); + } + } + + if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) + { + ps.WriteLine(" {0}", project.Files.GetCopyToOutput(file)); + } + + ps.WriteLine(" ", project.Files.GetBuildAction(file)); + } + } + } + // ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + ps.WriteLine(" "); + // ps.WriteLine(" ", toolInfo.XMLTag); + ps.WriteLine(""); + } + #endregion + + #region User File + + ps = new StreamWriter(projectFile + ".user"); + using (ps) + { + ps.WriteLine(""); + //ps.WriteLine( "" ); + //ps.WriteLine(" <{0}>", toolInfo.XMLTag); + //ps.WriteLine(" "); + ps.WriteLine(" "); + //ps.WriteLine(" ", MakeRefPath(project)); + + ps.WriteLine(" Debug"); + + if (projectFile.Contains( "OpenSim.csproj" )) + { + ps.WriteLine(" -loginserver -sandbox -accounts"); + } + + ps.WriteLine(" AnyCPU"); + ps.WriteLine(" {0}", MakeRefPath(project)); + ps.WriteLine(" {0}", this.ProductVersion); + ps.WriteLine(" ProjectFiles"); + ps.WriteLine(" 0"); + ps.WriteLine(" "); + foreach (ConfigurationNode conf in project.Configurations) + { + ps.Write(" "); + } + + ps.WriteLine(""); + } + #endregion + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteSolution(SolutionNode solution) + { + kernel.Log.Write("Creating {0} solution and project files", this.VersionName); + + foreach (ProjectNode project in solution.Projects) + { + kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); } + + kernel.Log.Write(""); + string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + using (StreamWriter ss = new StreamWriter(solutionFile)) + { + kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + using (ss) + { + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); + ss.WriteLine(SolutionTag); + foreach (ProjectNode project in solution.Projects) + { + if (!tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", + toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, + toolInfo.FileExtension), project.Guid.ToString().ToUpper()); + + //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); + //ss.WriteLine(" EndProjectSection"); + + ss.WriteLine("EndProject"); + } + + if (solution.Files != null) + { + ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); + ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); + foreach (string file in solution.Files) + ss.WriteLine("\t\t{0} = {0}", file); + ss.WriteLine("\tEndProjectSection"); + ss.WriteLine("EndProject"); + } + + ss.WriteLine("Global"); + + ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); + } + ss.WriteLine(" EndGlobalSection"); + + if (solution.Projects.Count > 1) + { + ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); + } + foreach (ProjectNode project in solution.Projects) + { + for (int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = (ReferenceNode)project.References[i]; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; + ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", + project.Guid.ToString().ToUpper() + , i, + refProject.Guid.ToString().ToUpper() + ); + } + } + } + if (solution.Projects.Count > 1) + { + ss.WriteLine(" EndGlobalSection"); + } + ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); + foreach (ProjectNode project in solution.Projects) + { + foreach (ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", + project.Guid.ToString().ToUpper(), + conf.Name); + + ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", + project.Guid.ToString().ToUpper(), + conf.Name); + } + } + ss.WriteLine(" EndGlobalSection"); + ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); + ss.WriteLine(" HideSolutionNode = FALSE"); + ss.WriteLine(" EndGlobalSection"); + + ss.WriteLine("EndGlobal"); + } + } + + kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = (ToolInfo)tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + kernel.Log.Write(""); } #endregion - #region Constructors + #region ITarget Members /// - /// Initializes a new instance of the class. + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + WriteSolution(sol); + } + kernel = null; + } + + /// + /// Cleans the specified kern. /// - public VS2005Target() - : base() - { + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + kernel = kern; + foreach (SolutionNode sol in kernel.Solutions) + { + CleanSolution(sol); + } + kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2005"; + } } #endregion diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs index f30017b..88bb5e6 100644 --- a/Prebuild/src/Core/Targets/VS2008Target.cs +++ b/Prebuild/src/Core/Targets/VS2008Target.cs @@ -1,132 +1,56 @@ using System; -using System.Collections; -using System.Collections.Specialized; -using System.IO; +using System.Collections.Generic; using System.Text; - using Prebuild.Core.Attributes; -using Prebuild.Core.Interfaces; -using Prebuild.Core.Nodes; -using Prebuild.Core.Utilities; -using System.CodeDom.Compiler; namespace Prebuild.Core.Targets { + [Target("vs2008")] + public class VS2008Target : VS2005Target + { + protected override string SolutionTag + { + get { return "# Visual Studio 2008"; } + } - /// - /// - /// - [Target("vs2008")] - public class VS2008Target : VSGenericTarget - { - #region Fields - string solutionVersion = "10.00"; - string productVersion = "9.0.21022"; - string schemaVersion = "2.0"; - string versionName = "Visual Studio 2008"; - string name = "vs2008"; - VSVersion version = VSVersion.VS90; - - Hashtable tools; - Kernel kernel; - - /// - /// Gets or sets the solution version. - /// - /// The solution version. - public override string SolutionVersion - { - get - { - return solutionVersion; - } - } - /// - /// Gets or sets the product version. - /// - /// The product version. - public override string ProductVersion - { - get - { - return productVersion; - } - } - /// - /// Gets or sets the schema version. - /// - /// The schema version. - public override string SchemaVersion - { - get - { - return schemaVersion; - } - } - /// - /// Gets or sets the name of the version. - /// - /// The name of the version. - public override string VersionName - { - get - { - return versionName; - } - } - /// - /// Gets or sets the version. - /// - /// The version. - public override VSVersion Version - { - get - { - return version; - } - } - /// - /// Gets the name. - /// - /// The name. - public override string Name - { - get - { - return name; - } - } - - protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) + protected override string SolutionVersion { - switch (frameworkVersion) + get { - case FrameworkVersion.v3_5: - return "ToolsVersion=\"3.5\""; - case FrameworkVersion.v3_0: - return "ToolsVersion=\"3.0\""; - default: - return "ToolsVersion=\"2.0\""; + return "10.00"; } } - public override string SolutionTag + protected override string VersionName { - get { return "# Visual Studio 2008"; } + get + { + return "Visual C# 2008"; + } } - #endregion - - #region Constructors + protected override string ToolsVersionXml + { + get + { + return " ToolsVersion=\"3.5\""; + } + } - /// - /// Initializes a new instance of the class. - /// - public VS2008Target() - : base() - { - } + protected override string ProductVersion + { + get + { + return "9.0.21022"; + } + } - #endregion - } + public override string Name + { + get + { + return "vs2008"; + } + } + } } diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs deleted file mode 100644 index 401331d..0000000 --- a/Prebuild/src/Core/Targets/VSGenericTarget.cs +++ /dev/null @@ -1,881 +0,0 @@ -#region BSD License -/* -Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@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 - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; -using System.Text; - -using Prebuild.Core.Attributes; -using Prebuild.Core.Interfaces; -using Prebuild.Core.Nodes; -using Prebuild.Core.Utilities; -using System.CodeDom.Compiler; - -namespace Prebuild.Core.Targets -{ - - /// - /// - /// - public abstract class VSGenericTarget : ITarget - { - #region Fields - - readonly Hashtable tools = new Hashtable(); - Kernel kernel; - #endregion - - #region Properties - /// - /// Gets or sets the solution version. - /// - /// The solution version. - public abstract string SolutionVersion { get; } - /// - /// Gets or sets the product version. - /// - /// The product version. - public abstract string ProductVersion { get; } - /// - /// Gets or sets the schema version. - /// - /// The schema version. - public abstract string SchemaVersion { get; } - /// - /// Gets or sets the name of the version. - /// - /// The name of the version. - public abstract string VersionName { get; } - /// - /// Gets or sets the version. - /// - /// The version. - public abstract VSVersion Version { get; } - /// - /// Gets the name. - /// - /// The name. - public abstract string Name { get; } - - protected abstract string GetToolsVersionXml(FrameworkVersion version); - public abstract string SolutionTag { get; } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - protected VSGenericTarget() - { - this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); - this.tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); - this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); - this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); - this.tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); - } - - #endregion - - #region Private Methods - - private string MakeRefPath(ProjectNode project) - { - string ret = ""; - foreach (ReferencePathNode node in project.ReferencePaths) - { - try - { - string fullPath = Helper.ResolvePath(node.Path); - if (ret.Length < 1) - { - ret = fullPath; - } - else - { - ret += ";" + fullPath; - } - } - catch (ArgumentException) - { - this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); - } - } - - return ret; - } - - private static ProjectNode FindProjectInSolution(string name, SolutionNode solution) - { - SolutionNode node = solution; - - while (node.Parent is SolutionNode) - node = node.Parent as SolutionNode; - - return FindProjectInSolutionRecursively(name, node); - } - - private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution) - { - if (solution.ProjectsTable.ContainsKey(name)) - return (ProjectNode)solution.ProjectsTable[name]; - - foreach (SolutionNode child in solution.Solutions) - { - ProjectNode node = FindProjectInSolutionRecursively(name, child); - if (node != null) - return node; - } - - return null; - } - - private void WriteProject(SolutionNode solution, ProjectNode project) - { - if (!tools.ContainsKey(project.Language)) - { - throw new UnknownLanguageException("Unknown .NET language: " + project.Language); - } - - ToolInfo toolInfo = (ToolInfo)tools[project.Language]; - string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); - StreamWriter ps = new StreamWriter(projectFile); - - kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); - - #region Project File - using (ps) - { - ps.WriteLine("", GetToolsVersionXml(project.FrameworkVersion)); - ps.WriteLine(" "); - ps.WriteLine(" Local"); - ps.WriteLine(" {0}", this.ProductVersion); - ps.WriteLine(" {0}", this.SchemaVersion); - ps.WriteLine(" {{{0}}}", project.Guid.ToString().ToUpper()); - - // Visual Studio has a hard coded guid for the project type - if (project.Type == ProjectType.Web) - ps.WriteLine(" {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}"); - ps.WriteLine(" Debug"); - ps.WriteLine(" AnyCPU"); - ps.WriteLine(" {0}", project.AppIcon); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" {0}", project.AssemblyName); - foreach (ConfigurationNode conf in project.Configurations) - { - if (conf.Options.KeyFile != "") - { - ps.WriteLine(" {0}", conf.Options.KeyFile); - ps.WriteLine(" true"); - break; - } - } - ps.WriteLine(" JScript"); - ps.WriteLine(" Grid"); - ps.WriteLine(" IE50"); - ps.WriteLine(" false"); - ps.WriteLine(" {0}", project.FrameworkVersion.ToString().Replace("_", ".")); - - ps.WriteLine(" {0}", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); - ps.WriteLine(" {0}", project.DesignerFolder); - ps.WriteLine(" {0}", project.RootNamespace); - ps.WriteLine(" {0}", project.StartupObject); - if (string.IsNullOrEmpty(project.DebugStartParameters)) - { - ps.WriteLine(" {0}", project.DebugStartParameters); - } - ps.WriteLine(" "); - ps.WriteLine(" "); - - ps.WriteLine(" "); - - foreach (ConfigurationNode conf in project.Configurations) - { - ps.Write(" ", conf.Name); - ps.WriteLine(" {0}", conf.Options["AllowUnsafe"]); - ps.WriteLine(" {0}", conf.Options["BaseAddress"]); - ps.WriteLine(" {0}", conf.Options["CheckUnderflowOverflow"]); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); - ps.WriteLine(" {0}", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); - ps.WriteLine(" {0}", conf.Options["DebugInformation"]); - ps.WriteLine(" {0}", conf.Options["FileAlignment"]); - ps.WriteLine(" {0}", conf.Options["OptimizeCode"]); - if (project.Type != ProjectType.Web) - ps.WriteLine(" {0}", - Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); - else - ps.WriteLine(" {0}", - Helper.EndPath(Helper.NormalizePath("bin\\"))); - - ps.WriteLine(" {0}", conf.Options["RegisterComInterop"]); - ps.WriteLine(" {0}", conf.Options["RemoveIntegerChecks"]); - ps.WriteLine(" {0}", conf.Options["WarningsAsErrors"]); - ps.WriteLine(" {0}", conf.Options["WarningLevel"]); - ps.WriteLine(" {0}", conf.Options["NoStdLib"]); - ps.WriteLine(" {0}", conf.Options["SuppressWarnings"]); - ps.WriteLine(" "); - } - - //ps.WriteLine(" "); - - List projectReferences = new List(); - List otherReferences = new List(); - - foreach (ReferenceNode refr in project.References) - { - ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); - - if (projectNode == null) - otherReferences.Add(refr); - else - projectReferences.Add(projectNode); - } - // Assembly References - ps.WriteLine(" "); - - foreach (ReferenceNode refr in otherReferences) - { - ps.Write(" "); - ps.Write(" "); - ps.Write(refr.Name); - ps.WriteLine(""); - // TODO: Allow reference to *.exe files - ps.WriteLine(" {0}", refr.LocalCopy); - ps.WriteLine(" "); - } - ps.WriteLine(" "); - - //Project References - ps.WriteLine(" "); - foreach (ProjectNode projectReference in projectReferences) - { - ToolInfo tool = (ToolInfo)tools[projectReference.Language]; - if (tools == null) - throw new UnknownLanguageException(); - - string path = - Helper.MakePathRelativeTo(project.FullPath, - Helper.MakeFilePath(projectReference.FullPath, projectReference.Name, tool.FileExtension)); - ps.WriteLine(" ", path); - - // TODO: Allow reference to visual basic projects - ps.WriteLine(" {0}", projectReference.Name); - ps.WriteLine(" {0}", projectReference.Guid.ToString("B").ToUpper()); - ps.WriteLine(" {0}", tool.Guid.ToUpper()); - ps.WriteLine(" "); - } - ps.WriteLine(" "); - - // ps.WriteLine(" "); - ps.WriteLine(" "); - - // ps.WriteLine(" "); - List list = new List(); - - foreach (string path in project.Files) - { - string lower = path.ToLower(); - if (lower.EndsWith(".resx")) - { - string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); - if (!list.Contains(codebehind)) - list.Add(codebehind); - } - } - - foreach (string file in project.Files) - { - // if (file == "Properties\\Bind.Designer.cs") - // { - // Console.WriteLine("Wait a minute!"); - // Console.WriteLine(project.Files.GetSubType(file).ToString()); - // } - - SubType subType = project.Files.GetSubType(file); - - if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer - && subType != SubType.CodeBehind) - { - ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx"); - ps.WriteLine(" {0}", Path.GetFileName(file)); - ps.WriteLine(" Designer"); - ps.WriteLine(" "); - // - } - - if (subType == SubType.Designer) - { - ps.WriteLine(" ", file); - ps.WriteLine(" " + subType + ""); - ps.WriteLine(" ResXFileCodeGenerator"); - - string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; - string dependent_name = file.Substring(0, file.LastIndexOf('.')) + ".cs"; - - ps.WriteLine(" {0}", autogen_name); - - // Check for a parent .cs file with the same name as this designer file - if (File.Exists(dependent_name)) - ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); - - ps.WriteLine(" "); - if (File.Exists(autogen_name)) - { - ps.WriteLine(" ", autogen_name); - ps.WriteLine(" True"); - ps.WriteLine(" True"); - - // If a parent .cs file exists, link this autogen file to it. Otherwise link - // to the designer file - if (File.Exists(dependent_name)) - ps.WriteLine(" {0}", Path.GetFileName(dependent_name)); - else - ps.WriteLine(" {0}", Path.GetFileName(file)); - - ps.WriteLine(" "); - } - list.Add(autogen_name); - } - if (subType == SubType.Settings) - { - ps.Write(" <{0} ", project.Files.GetBuildAction(file)); - ps.WriteLine("Include=\"{0}\">", file); - string fileName = Path.GetFileName(file); - if (project.Files.GetBuildAction(file) == BuildAction.None) - { - ps.WriteLine(" SettingsSingleFileGenerator"); - ps.WriteLine(" {0}", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); - } - else - { - ps.WriteLine(" Code"); - ps.WriteLine(" True"); - ps.WriteLine(" True"); - string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); - string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); - ps.WriteLine(" {0}", Path.GetFileName(fileNameShorter + ".settings")); - } - ps.WriteLine(" ", project.Files.GetBuildAction(file)); - } - else if (subType != SubType.Designer) - { - string path = Helper.NormalizePath(file); - string path_lower = path.ToLower(); - - if (!list.Contains(file)) - { - ps.Write(" <{0} ", project.Files.GetBuildAction(path)); - - int startPos = 0; - if (project.Files.GetPreservePath(file)) - { - while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) - startPos++; - - } - else - { - startPos = file.LastIndexOf(Path.GetFileName(path)); - } - - ps.WriteLine("Include=\"{0}\">", path); - - int last_period_index = file.LastIndexOf('.'); - string short_file_name = file.Substring(0, last_period_index); - string extension = Path.GetExtension(path); - string designer_format = string.Format(".designer{0}", extension); - - if (path_lower.EndsWith(designer_format)) - { - int designer_index = path_lower.IndexOf(designer_format); - string file_name = path.Substring(0, designer_index); - - if (File.Exists(file_name)) - ps.WriteLine(" {0}", Path.GetFileName(file_name)); - else if (File.Exists(file_name + ".resx")) - ps.WriteLine(" {0}", Path.GetFileName(file_name + ".resx")); - } - else if (subType == SubType.CodeBehind) - { - ps.WriteLine(" {0}", Path.GetFileName(short_file_name)); - } - if (project.Files.GetIsLink(file)) - { - string alias = project.Files.GetLinkPath(file); - alias += file.Substring(startPos); - alias = Helper.NormalizePath(alias); - ps.WriteLine(" {0}", alias); - } - else if (project.Files.GetBuildAction(file) != BuildAction.None) - { - if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) - { - ps.WriteLine(" {0}", subType); - } - } - - if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) - { - ps.WriteLine(" {0}", project.Files.GetCopyToOutput(file)); - } - - ps.WriteLine(" ", project.Files.GetBuildAction(file)); - } - } - } - - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(" "); - ps.WriteLine(""); - } - #endregion - - #region User File - - ps = new StreamWriter(projectFile + ".user"); - using (ps) - { - ps.WriteLine(""); - //ps.WriteLine( "" ); - //ps.WriteLine(" <{0}>", toolInfo.XMLTag); - //ps.WriteLine(" "); - ps.WriteLine(" "); - //ps.WriteLine(" ", MakeRefPath(project)); - ps.WriteLine(" Debug"); - ps.WriteLine(" AnyCPU"); - ps.WriteLine(" {0}", MakeRefPath(project)); - ps.WriteLine(" {0}", this.ProductVersion); - ps.WriteLine(" ProjectFiles"); - ps.WriteLine(" 0"); - ps.WriteLine(" "); - foreach (ConfigurationNode conf in project.Configurations) - { - ps.Write(" "); - } - ps.WriteLine(""); - } - #endregion - - kernel.CurrentWorkingDirectory.Pop(); - } - - private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk) - { - kernel.Log.Write("Creating {0} solution and project files", this.VersionName); - - foreach (SolutionNode child in solution.Solutions) - { - kernel.Log.Write("...Creating folder: {0}", child.Name); - WriteSolution(child, false); - } - - foreach (ProjectNode project in solution.Projects) - { - kernel.Log.Write("...Creating project: {0}", project.Name); - WriteProject(solution, project); - } - - foreach (DatabaseProjectNode project in solution.DatabaseProjects) - { - kernel.Log.Write("...Creating database project: {0}", project.Name); - WriteDatabaseProject(solution, project); - } - - if (writeSolutionToDisk) // only write main solution - { - kernel.Log.Write(""); - string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); - - using (StreamWriter ss = new StreamWriter(solutionFile)) - { - kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); - - ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); - ss.WriteLine(SolutionTag); - - WriteProjectDeclarations(ss, solution, solution); - - ss.WriteLine("Global"); - - ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); - foreach (ConfigurationNode conf in solution.Configurations) - { - ss.WriteLine("\t\t{0}|Any CPU = {0}|Any CPU", conf.Name); - } - ss.WriteLine("\tEndGlobalSection"); - - ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); - WriteConfigurationLines(solution.Configurations, solution, ss); - ss.WriteLine("\tEndGlobalSection"); - - if (solution.Solutions.Count > 0) - { - ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution"); - foreach (SolutionNode embeddedSolution in solution.Solutions) - { - WriteNestedProjectMap(ss, embeddedSolution); - } - ss.WriteLine("\tEndGlobalSection"); - } - - ss.WriteLine("EndGlobal"); - } - - kernel.CurrentWorkingDirectory.Pop(); - } - } - - private void WriteProjectDeclarations(StreamWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution) - { - foreach (SolutionNode childSolution in embeddedSolution.Solutions) - { - WriteEmbeddedSolution(writer, childSolution); - WriteProjectDeclarations(writer, actualSolution, childSolution); - } - - foreach (ProjectNode project in embeddedSolution.Projects) - { - WriteProject(actualSolution, writer, project); - } - - foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) - { - WriteProject(actualSolution, writer, dbProject); - } - - if (actualSolution.Guid == embeddedSolution.Guid) - { - WriteSolutionFiles(actualSolution, writer); - } - } - - private static void WriteNestedProjectMap(StreamWriter writer, SolutionNode embeddedSolution) - { - foreach (ProjectNode project in embeddedSolution.Projects) - { - WriteNestedProject(writer, embeddedSolution, project.Guid); - } - - foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects) - { - WriteNestedProject(writer, embeddedSolution, dbProject.Guid); - } - - foreach (SolutionNode child in embeddedSolution.Solutions) - { - WriteNestedProject(writer, embeddedSolution, child.Guid); - WriteNestedProjectMap(writer, child); - } - } - - private static void WriteNestedProject(StreamWriter writer, SolutionNode solution, Guid projectGuid) - { - WriteNestedFolder(writer, solution.Guid, projectGuid); - } - - private static void WriteNestedFolder(StreamWriter writer, Guid parentGuid, Guid childGuid) - { - writer.WriteLine("\t\t{0} = {1}", - childGuid.ToString("B").ToUpper(), - parentGuid.ToString("B").ToUpper()); - } - - private static void WriteConfigurationLines(ICollection configurations, SolutionNode solution, StreamWriter ss) - { - foreach (ProjectNode project in solution.Projects) - { - foreach (ConfigurationNode conf in configurations) - { - ss.WriteLine("\t\t{0}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", - project.Guid.ToString("B").ToUpper(), - conf.Name); - - ss.WriteLine("\t\t{0}.{1}|Any CPU.Build.0 = {1}|Any CPU", - project.Guid.ToString("B").ToUpper(), - conf.Name); - } - } - - foreach (SolutionNode child in solution.Solutions) - { - WriteConfigurationLines(configurations, child, ss); - } - } - - private void WriteSolutionFiles(SolutionNode solution, StreamWriter ss) - { - WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files); - } - - private void WriteEmbeddedSolution(StreamWriter writer, SolutionNode embeddedSolution) - { - WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files); - } - - private void WriteProject(SolutionNode solution, StreamWriter ss, ProjectNode project) - { - WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); - } - - private void WriteProject(SolutionNode solution, StreamWriter ss, DatabaseProjectNode dbProject) - { - if (solution.Files != null && solution.Files.Count > 0) - WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath); - } - - private static bool ExtensionSpecified(string refName) - { - return refName.EndsWith(".dll") || refName.EndsWith(".exe"); - } - - private static string GetProjectExtension(ProjectNode project) - { - string extension = ".dll"; - if (project.Type == ProjectType.Exe) - { - extension = ".exe"; - } - return extension; - } - - const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\""; - const string ProjectDeclarationEndFormat = "EndProject"; - - private void WriteProject(StreamWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) - { - if (!tools.ContainsKey(language)) - throw new UnknownLanguageException("Unknown .NET language: " + language); - - ToolInfo toolInfo = (ToolInfo)tools[language]; - - string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); - - path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); - - WriteProject(ss, language, guid, name, path); - } - - private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location) - { - WriteProject(writer, language, projectGuid, name, location, null); - } - - private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files) - { - if (!tools.ContainsKey(language)) - throw new UnknownLanguageException("Unknown .NET language: " + language); - - ToolInfo toolInfo = (ToolInfo)tools[language]; - - writer.WriteLine(ProjectDeclarationBeginFormat, - toolInfo.Guid, - name, - location, - projectGuid.ToString("B").ToUpper()); - - if (files != null) - { - writer.WriteLine("\tProjectSection(SolutionItems) = preProject"); - - foreach (string file in files) - writer.WriteLine("\t\t{0} = {0}", file); - - writer.WriteLine("\tEndProjectSection"); - } - - writer.WriteLine(ProjectDeclarationEndFormat); - } - - private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project) - { - string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp"); - IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " "); - - kernel.CurrentWorkingDirectory.Push(); - - Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); - - using (ps) - { - ps.WriteLine("# Microsoft Developer Studio Project File - Database Project"); - ps.WriteLine("Begin DataProject = \"{0}\"", project.Name); - ps.Indent++; - ps.WriteLine("MSDTVersion = \"80\""); - // TODO: Use the project.Files property - if (ContainsSqlFiles(Path.GetDirectoryName(projectFile))) - WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile)); - - ps.WriteLine("Begin DBRefFolder = \"Database References\""); - ps.Indent++; - foreach (DatabaseReferenceNode reference in project.References) - { - ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name); - ps.Indent++; - ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString); - ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper()); - //ps.WriteLine("Colorizer = 5"); - ps.Indent--; - ps.WriteLine("End"); - } - ps.Indent--; - ps.WriteLine("End"); - ps.Indent--; - ps.WriteLine("End"); - - ps.Flush(); - } - - kernel.CurrentWorkingDirectory.Pop(); - } - - private bool ContainsSqlFiles(string folder) - { - foreach (string file in Directory.GetFiles(folder, "*.sql")) - { - return true; // if the folder contains 1 .sql file, that's good enough - } - - foreach (string child in Directory.GetDirectories(folder)) - { - if (ContainsSqlFiles(child)) - return true; // if 1 child folder contains a .sql file, still good enough - } - - return false; - } - - private void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder) - { - foreach (string child in Directory.GetDirectories(folder)) - { - if (ContainsSqlFiles(child)) - { - writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child)); - writer.Indent++; - WriteDatabaseFoldersAndFiles(writer, child); - writer.Indent--; - writer.WriteLine("End"); - } - } - foreach (string file in Directory.GetFiles(folder, "*.sql")) - { - writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file)); - } - } - - private void CleanProject(ProjectNode project) - { - kernel.Log.Write("...Cleaning project: {0}", project.Name); - - ToolInfo toolInfo = (ToolInfo)tools[project.Language]; - string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); - string userFile = projectFile + ".user"; - - Helper.DeleteIfExists(projectFile); - Helper.DeleteIfExists(userFile); - } - - private void CleanSolution(SolutionNode solution) - { - kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); - - string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); - string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); - - Helper.DeleteIfExists(slnFile); - Helper.DeleteIfExists(suoFile); - - foreach (ProjectNode project in solution.Projects) - { - CleanProject(project); - } - - kernel.Log.Write(""); - } - - #endregion - - #region ITarget Members - - /// - /// Writes the specified kern. - /// - /// The kern. - public virtual void Write(Kernel kern) - { - if (kern == null) - { - throw new ArgumentNullException("kern"); - } - kernel = kern; - foreach (SolutionNode sol in kernel.Solutions) - { - WriteSolution(sol, true); - } - kernel = null; - } - - /// - /// Cleans the specified kern. - /// - /// The kern. - public virtual void Clean(Kernel kern) - { - if (kern == null) - { - throw new ArgumentNullException("kern"); - } - kernel = kern; - foreach (SolutionNode sol in kernel.Solutions) - { - CleanSolution(sol); - } - kernel = null; - } - - #endregion - } -} diff --git a/Prebuild/src/Core/Targets/VSVersion.cs b/Prebuild/src/Core/Targets/VSVersion.cs deleted file mode 100644 index f477086..0000000 --- a/Prebuild/src/Core/Targets/VSVersion.cs +++ /dev/null @@ -1,50 +0,0 @@ -#region BSD License -/* -Copyright (c) 2008-2009 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), John Anderson (sontek@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 - -namespace Prebuild.Core.Targets -{ - /// - /// - /// - public enum VSVersion - { - /// - /// Visual Studio 2002 - /// - VS70, - /// - /// Visual Studio 2003 - /// - VS71, - /// - /// Visual Studio 2005 - /// - VS80, - /// - /// Visual Studio 2008 - /// - VS90 - } -} diff --git a/Prebuild/src/Core/Targets/XcodeTarget.cs b/Prebuild/src/Core/Targets/XcodeTarget.cs index d96f65b..ee3b241 100644 --- a/Prebuild/src/Core/Targets/XcodeTarget.cs +++ b/Prebuild/src/Core/Targets/XcodeTarget.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 12:58:03 -0800 (Tue, 13 Feb 2007) $ + * $Revision: 205 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs index 22752aa..5733547 100644 --- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs +++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: robloach $ + * $Date: 2006-09-26 07:30:53 +0900 (Tue, 26 Sep 2006) $ + * $Revision: 165 $ + */ +#endregion + using System; using System.Collections; using System.Collections.Specialized; diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs index 5fabdf0..abbed52 100644 --- a/Prebuild/src/Core/Utilities/CurrentDirectory.cs +++ b/Prebuild/src/Core/Utilities/CurrentDirectory.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.Collections; diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs index 9a0d131..19093ce 100644 --- a/Prebuild/src/Core/Utilities/Helper.cs +++ b/Prebuild/src/Core/Utilities/Helper.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $ + * $Revision: 205 $ + */ +#endregion + using System; using System.Collections; using System.Diagnostics; @@ -280,8 +289,6 @@ namespace Prebuild.Core.Utilities return true; } - static readonly char seperator = Path.DirectorySeparatorChar; - // This little gem was taken from the NeL source, thanks guys! /// /// Makes a relative path @@ -291,8 +298,8 @@ namespace Prebuild.Core.Utilities /// Path that will get from startPath to endPath public static string MakePathRelativeTo(string startPath, string endPath) { - string tmp = NormalizePath(startPath, seperator); - string src = NormalizePath(endPath, seperator); + string tmp = NormalizePath(startPath, '/'); + string src = NormalizePath(endPath, '/'); string prefix = ""; while(true) @@ -305,14 +312,14 @@ namespace Prebuild.Core.Utilities { return "./"; } - if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) + if ((src.Length > tmp.Length) && src[tmp.Length-1] != '/' && src[tmp.Length-1] != '\\') { } else { ret = prefix + endPath.Substring(size, endPath.Length - size); ret = ret.Trim(); - if(ret[0] == seperator) + if(ret[0] == '/' || ret[0] == '\\') { ret = "." + ret; } @@ -327,8 +334,8 @@ namespace Prebuild.Core.Utilities break; } - int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); - int prevPos = tmp.IndexOf(seperator); + int lastPos = tmp.LastIndexOf('/', tmp.Length - 2); + int prevPos = tmp.IndexOf('/'); if((lastPos == prevPos) || (lastPos == -1)) { @@ -336,7 +343,7 @@ namespace Prebuild.Core.Utilities } tmp = tmp.Substring(0, lastPos + 1); - prefix += ".." + seperator.ToString(); + prefix += "../"; } return endPath; diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs index 548e987..e8105ac 100644 --- a/Prebuild/src/Core/Utilities/Log.cs +++ b/Prebuild/src/Core/Utilities/Log.cs @@ -23,6 +23,15 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O */ #endregion +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ + * $Revision: 71 $ + */ +#endregion + using System; using System.IO; -- cgit v1.1