From dd9640cda82bca8125289f292238ea6b447cc6e9 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 19 Feb 2009 12:48:38 +0000 Subject: === PREBUILD UPSTREAMS UPDATE : POTENTIAL BREAKAGE === * Applied upstreams changes to allow for auditing and debugging in our various environments. * This should, in theory, bring back 'multiple ref dirs'. * Temporarily Removed xmlns because prebuild-1.7 schema does not allow for multiple solutions per prebuild node (This will be a moot issue once the Prebuild node is moved out of prebuild.xml) * Autotools target: Various minor fixes * MonoDevelop Target : No changes. * Nant Target: Various minor fixes, support for net-3.5 and mono-2.0/3.5 targets * Sharpdevelop targets: No changes. * VS Targets: Refactored into using VSGenericTarget, and supports 2.0-3.5 * XCode Target: No changes. --- Regressions and outstanding issues --- * The Solution is assigned a random Guid - will lead to unnecessary reloads and loss of user settings. --- New features of Prebuild 2.0.4 --- * (Better) support for Web, WinForms and Database Projects and build actions * Conditional Framework Version compilation support (1.1, 2.0-3.5) * ArrayList -> List<>, ICollection -> IList (this means Prebuild can generate 1.1 solutions, but can't itself be built under 1.1 - how very meta) * Added preprocessor directive. --- Prebuild/AUTHORS | 5 +- Prebuild/ChangeLog | 87 ++ Prebuild/prebuild.xml | 2 +- Prebuild/scripts/VS2008.bat | 4 + 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 - Prebuild/src/Prebuild.cs | 2 +- Prebuild/src/Properties/AssemblyInfo.cs | 11 +- Prebuild/src/data/prebuild-1.7.xsd | 120 ++- Prebuild/tests/Makefile | 24 + Prebuild/tests/README.txt | 5 + Prebuild/tests/include-001.expected | 46 ++ Prebuild/tests/include-001.include | 33 + Prebuild/tests/include-001.prebuild | 22 + Prebuild/tests/include-002-2.include | 8 + Prebuild/tests/include-002.expected | 26 + Prebuild/tests/include-002.include | 14 + Prebuild/tests/include-002.prebuild | 7 + 59 files changed, 2820 insertions(+), 2010 deletions(-) create mode 100644 Prebuild/scripts/VS2008.bat create mode 100644 Prebuild/src/Core/Nodes/DatabaseProjectNode.cs create mode 100644 Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs create mode 100644 Prebuild/src/Core/Targets/ToolInfo.cs create mode 100644 Prebuild/src/Core/Targets/VSGenericTarget.cs create mode 100644 Prebuild/src/Core/Targets/VSVersion.cs create mode 100644 Prebuild/tests/Makefile create mode 100644 Prebuild/tests/README.txt create mode 100644 Prebuild/tests/include-001.expected create mode 100644 Prebuild/tests/include-001.include create mode 100644 Prebuild/tests/include-001.prebuild create mode 100644 Prebuild/tests/include-002-2.include create mode 100644 Prebuild/tests/include-002.expected create mode 100644 Prebuild/tests/include-002.include create mode 100644 Prebuild/tests/include-002.prebuild (limited to 'Prebuild') diff --git a/Prebuild/AUTHORS b/Prebuild/AUTHORS index d794c5e..9e86ac0 100644 --- a/Prebuild/AUTHORS +++ b/Prebuild/AUTHORS @@ -4,4 +4,7 @@ Dan Moorehead (dan05a@gmail.com) Rob Loach (http://www.robloach.net) C.J. Adams-Collier (cjac@colliertech.org) - +Patch Contributers +lbsa71 +chi11ken +sdague diff --git a/Prebuild/ChangeLog b/Prebuild/ChangeLog index 89ddbe4..bb8e7b0 100644 --- a/Prebuild/ChangeLog +++ b/Prebuild/ChangeLog @@ -1,3 +1,90 @@ +2008-12-09T02:15 D. Moonfire + * src/Core/Kernel.cs + - Added a /ppi target to get the results of processing but before + processing the actual results. + * src/Core/Preprocessor.cs + - Applied the patch from kanato with formatting changes. + - Uses the format. + * tests/ + - Added some lightweight tests to test the functionality of the + include patch. + +2008-06-19T09:37 John Anderson + * src/Core/Kernel.cs + - Only Loop through targets that are not abstract. + * src/Core/Targets/VSGenericTarget.cs + - Marked abstract and removed the Target attribute. + +2008-06-16T17:37 John Anderson + * src/Core/Nodes/ProjectNode.cs,data/prebuild-1.7.xsd + - Added the ability to hardcode guid's in the projects + +2008-05-21T0737 C.J. Adams-Collier + * src/Core/Targets/AutotoolsTarget.cs + - catch exception when unable to compile AssemblyInfo.cs + +2008-05-07T17:29 John Anderson + * src/Core/Targets/VSGenericTarget.cs + - Generate asp.net output in bin\ folder (asp.net requires it there) + +2008-04-30T17:29 John Anderson + * src/Core/Nodes/DatabaseReferenceNode.cs, + src/Core/Nodes/Datanode.cs, + src/Core/Nodes/FileNode.cs, + src/Core/Nodes/FileNodes.cs, + src/Core/Nodes/MatchNode.cs, + src/Core/Targets/VS2008Target.cs, + src/data/prebuild-1.7.xsd + - Refactored the project generation code to handle web projects and more + logically handle embedded resources and designer files. + +2008-04-30T17:29 Joseph Lombrozo + * src/Core/Nodes/SolutionNode.cs + - Had solutions inherit Configurations in the same way that Projects do. + +2008-04-29T06:35 Joseph Lombrozo + * src/Core/Targets/VS2008Target.cs, + src/Core/Nodes/DatabaseProjectNode.cs, + src/Core/Nodes/DatabaseReferenceNode.cs, + src/data/prebuild-1.7.xsd + - Added database references to database projects. + - Prevented nested solutions from being written to disk. + +2008-04-29T05:43 Joseph Lombrozo + * src/Core/Targets/VS2008Target.cs + - Enabled embedded solutions to contain Files. + +2008-04-29T04:13 Joseph Lombrozo + * src/Core/VSVersion.cs + - Fixed spelling mistake in enum comment. + * src/Core/Attributes/DataNodeAttribute.cs + - Allowed the DataNodeAttribute to be attached to a single class + more than once, allowing one class to be used to parse more than + one node at a time. + * src/Core/Kernel.cs + - Changed CacheNodeTypes() to allow for multiple DataNodeAttribute + instances in one class. Refactored ProcessFile(...) to return Solutions, + rather than adding them to the Kernel. + * src/Core/Nodes/SolutionNode.cs + - Added Guid (for embedded folders) + - Added DatabaseProjects, Solutions and Processes to the SolutionNode + when parsing. + * src/Core/Nodes/ProjectNode.cs + - Added FrameworkVersion property to allow for 2.0/3.0/3.5 differentiation. + * src/Core/Targets/VS2008Target.cs, src/data/prebuild-1.7.xsd + - Added ability to have embedded solutions, and externally referenced + prebuild scripts. + +2008-04-24T04:33 John M. Anderson + * src/Core/Targets/VS2003Target.cs, src/Core/Targets/VSVersion.cs + - Moved the VSVersion enum into its own file. + * src/Core/Targets/VS2008Target.cs + - added support for VS2008 + * src/Core/Nodes/ProjectNode.cs + - Added initial support for ASP.NET projects + * src/Core/Nodes/DatabaseProjectNode.cs + - Added support for Visual Studio database projects + 2008-02-19T07:08 C.J. Adams-Collier * TODO - added some tasks from Sam Hocevar diff --git a/Prebuild/prebuild.xml b/Prebuild/prebuild.xml index 8538e69..1f81086 100644 --- a/Prebuild/prebuild.xml +++ b/Prebuild/prebuild.xml @@ -1,6 +1,6 @@ - + DEBUG;TRACE diff --git a/Prebuild/scripts/VS2008.bat b/Prebuild/scripts/VS2008.bat new file mode 100644 index 0000000..b465668 --- /dev/null +++ b/Prebuild/scripts/VS2008.bat @@ -0,0 +1,4 @@ +@rem Generates a solution (.sln) and a set of project files (.csproj, .vbproj, etc.) +@rem for Microsoft Visual Studio .NET 2008 +cd .. +Prebuild.exe /target vs2008 /file prebuild.xml /pause diff --git a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs index cdd0e0d..f1938a2 100644 --- a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs @@ -23,15 +23,6 @@ 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; @@ -40,7 +31,7 @@ namespace Prebuild.Core.Attributes /// /// /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=true)] public sealed class DataNodeAttribute : Attribute { #region Fields diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs index 5cefe68..2d6a6a7 100644 --- a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs @@ -23,15 +23,6 @@ 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 b17cc5b..5ad62ee 100644 --- a/Prebuild/src/Core/Attributes/TargetAttribute.cs +++ b/Prebuild/src/Core/Attributes/TargetAttribute.cs @@ -23,15 +23,6 @@ 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 784c35d..3487905 100644 --- a/Prebuild/src/Core/FatalException.cs +++ b/Prebuild/src/Core/FatalException.cs @@ -23,15 +23,6 @@ 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 7583fd2..986dd2d 100644 --- a/Prebuild/src/Core/Interfaces/IDataNode.cs +++ b/Prebuild/src/Core/Interfaces/IDataNode.cs @@ -23,15 +23,6 @@ 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 77006d7..47115c6 100644 --- a/Prebuild/src/Core/Interfaces/ITarget.cs +++ b/Prebuild/src/Core/Interfaces/ITarget.cs @@ -23,15 +23,6 @@ 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 1f0ad70..95ef04e 100644 --- a/Prebuild/src/Core/Kernel.cs +++ b/Prebuild/src/Core/Kernel.cs @@ -36,16 +36,8 @@ 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; @@ -80,17 +72,17 @@ namespace Prebuild.Core #region Fields - private static Kernel m_Instance = new Kernel(); + private static readonly Kernel m_Instance = new Kernel(); /// /// This must match the version of the schema that is embeeded /// - 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; + 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; bool disposed; private Version m_Version; - private string m_Revision = ""; + private const string m_Revision = ""; private CommandLineCollection m_CommandLine; private Log m_Log; private CurrentDirectory m_CurrentWorkingDirectory; @@ -98,19 +90,16 @@ namespace Prebuild.Core private Hashtable m_Targets; private Hashtable m_Nodes; - - ArrayList m_Solutions; + + readonly List m_Solutions = new List(); string m_Target; string m_Clean; string[] m_RemoveDirectories; - string m_CurrentFile; - XmlDocument m_CurrentDoc; + XmlDocument m_CurrentDoc; bool m_PauseAfterFinish; string[] m_ProjectGroups; - StringCollection m_Refs; - - #endregion + #endregion #region Constructors @@ -210,7 +199,7 @@ namespace Prebuild.Core /// Gets the solutions. /// /// The solutions. - public ArrayList Solutions + public List Solutions { get { @@ -235,7 +224,7 @@ namespace Prebuild.Core #region Private Methods - private void RemoveDirectories(string rootDir, string[] dirNames) + private static void RemoveDirectories(string rootDir, string[] dirNames) { foreach(string dir in Directory.GetDirectories(rootDir)) { @@ -297,13 +286,15 @@ 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"); } @@ -316,16 +307,13 @@ namespace Prebuild.Core { foreach(Type t in assm.GetTypes()) { - 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; + foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) + { + NodeEntry ne = new NodeEntry(); + ne.Type = t; + ne.Attribute = dna; + m_Nodes[dna.Name] = ne; + } } } @@ -343,7 +331,32 @@ namespace Prebuild.Core m_Log.Write(); } - private void ProcessFile(string file) + + + 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) { m_CurrentWorkingDirectory.Push(); @@ -361,8 +374,7 @@ namespace Prebuild.Core return; } - m_CurrentFile = path; - Helper.SetCurrentDir(Path.GetDirectoryName(path)); + Helper.SetCurrentDir(Path.GetDirectoryName(path)); XmlTextReader reader = new XmlTextReader(path); @@ -379,6 +391,33 @@ 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 @@ -443,7 +482,7 @@ namespace Prebuild.Core } else if(dataNode is SolutionNode) { - m_Solutions.Add(dataNode); + solutions.Add((SolutionNode)dataNode); } } } @@ -527,7 +566,7 @@ namespace Prebuild.Core /// public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) { - IDataNode dataNode = null; + IDataNode dataNode; try { @@ -629,9 +668,6 @@ namespace Prebuild.Core m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); LoadSchema(); - - m_Solutions = new ArrayList(); - m_Refs = new StringCollection(); } /// @@ -664,17 +700,18 @@ namespace Prebuild.Core m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); return; } - 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_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 03ea934..20e72c0 100644 --- a/Prebuild/src/Core/Nodes/AuthorNode.cs +++ b/Prebuild/src/Core/Nodes/AuthorNode.cs @@ -23,15 +23,6 @@ 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 828bff6..67d78d5 100644 --- a/Prebuild/src/Core/Nodes/ConfigurationNode.cs +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs @@ -23,15 +23,6 @@ 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 60ed122..763e6c3 100644 --- a/Prebuild/src/Core/Nodes/DataNode.cs +++ b/Prebuild/src/Core/Nodes/DataNode.cs @@ -23,31 +23,24 @@ 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 class DataNode : IDataNode + public abstract class DataNode : IDataNode { #region Fields private IDataNode parent; + string[] m_WebTypes = new string[] { "aspx", "ascx", "master", "ashx", "asmx" }; #endregion @@ -68,7 +61,10 @@ namespace Prebuild.Core.Nodes parent = value; } } - + public string[] WebTypes + { + get { return m_WebTypes; } + } /// /// Parses the specified node. /// @@ -76,7 +72,46 @@ 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 new file mode 100644 index 0000000..8696a79 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs @@ -0,0 +1,94 @@ +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 new file mode 100644 index 0000000..97c3964 --- /dev/null +++ b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs @@ -0,0 +1,63 @@ +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 cff7afc..353a5ae 100644 --- a/Prebuild/src/Core/Nodes/DescriptionNode.cs +++ b/Prebuild/src/Core/Nodes/DescriptionNode.cs @@ -23,15 +23,6 @@ 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 afc869d..7f04cba 100644 --- a/Prebuild/src/Core/Nodes/ExcludeNode.cs +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs @@ -23,15 +23,6 @@ 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 083dba5..1520fcb 100644 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ b/Prebuild/src/Core/Nodes/FileNode.cs @@ -23,15 +23,6 @@ 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; @@ -39,6 +30,7 @@ using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; using Prebuild.Core.Utilities; +using Prebuild.Core.Targets; namespace Prebuild.Core.Nodes { @@ -93,7 +85,11 @@ namespace Prebuild.Core.Nodes /// /// /// - UserControl + UserControl, + /// + /// + /// + CodeBehind, } public enum CopyToOutput @@ -113,9 +109,9 @@ namespace Prebuild.Core.Nodes private string m_Path; private string m_ResourceName = ""; - private BuildAction m_BuildAction = BuildAction.Compile; + private BuildAction? m_BuildAction; private bool m_Valid; - private SubType m_SubType = SubType.Code; + private SubType? m_SubType; private CopyToOutput m_CopyToOutput = CopyToOutput.Never; private bool m_Link = false; private string m_LinkPath = string.Empty; @@ -155,7 +151,11 @@ namespace Prebuild.Core.Nodes { get { - return m_BuildAction; + if (m_BuildAction != null) + return m_BuildAction.Value; + else + return GetBuildActionByFileName(this.Path); + } } @@ -189,7 +189,10 @@ namespace Prebuild.Core.Nodes { get { - return m_SubType; + if (m_SubType != null) + return m_SubType.Value; + else + return GetSubTypeByFileName(this.Path); } } @@ -227,10 +230,13 @@ namespace Prebuild.Core.Nodes /// public override void Parse(XmlNode node) { - m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), - Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString())); - m_SubType = (SubType)Enum.Parse(typeof(SubType), - Helper.AttributeValue(node, "subType", m_SubType.ToString())); + 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_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 7c1dd19..dc306c2 100644 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -23,15 +23,6 @@ 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,6 +30,7 @@ using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; +using System.IO; namespace Prebuild.Core.Nodes { @@ -224,8 +216,8 @@ namespace Prebuild.Core.Nodes if (!m_Files.Contains(file)) { m_Files.Add(file); - m_BuildActions[ file ] = matchNode.BuildAction; - m_SubTypes[ file ] = matchNode.SubType; + m_BuildActions[ file ] = matchNode.BuildAction == null ? GetBuildActionByFileName(file) : matchNode.BuildAction; + m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; 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 aeaf3c1..656d7d0 100644 --- a/Prebuild/src/Core/Nodes/MatchNode.cs +++ b/Prebuild/src/Core/Nodes/MatchNode.cs @@ -23,16 +23,8 @@ 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; @@ -53,29 +45,16 @@ namespace Prebuild.Core.Nodes { #region Fields - private StringCollection m_Files; + private readonly StringCollection m_Files = new StringCollection(); private Regex m_Regex; - private BuildAction m_BuildAction = BuildAction.Compile; - private SubType m_SubType = SubType.Code; + private BuildAction? m_BuildAction; + private SubType? m_SubType; string m_ResourceName = ""; private CopyToOutput m_CopyToOutput; private bool m_Link; private string m_LinkPath; private bool m_PreservePath; - private ArrayList m_Exclusions; - - #endregion - - #region Constructors - - /// - /// - /// - public MatchNode() - { - m_Files = new StringCollection(); - m_Exclusions = new ArrayList(); - } + private readonly List m_Exclusions = new List(); #endregion @@ -95,7 +74,7 @@ namespace Prebuild.Core.Nodes /// /// /// - public BuildAction BuildAction + public BuildAction? BuildAction { get { @@ -106,7 +85,7 @@ namespace Prebuild.Core.Nodes /// /// /// - public SubType SubType + public SubType? SubType { get { @@ -167,7 +146,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, ArrayList exclusions) + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, List exclusions) { Match match; Boolean excludeFile; @@ -279,10 +258,14 @@ 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")); - 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())); + 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_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)); @@ -329,7 +312,7 @@ namespace Prebuild.Core.Nodes if(dataNode is ExcludeNode) { ExcludeNode excludeNode = (ExcludeNode)dataNode; - m_Exclusions.Add( dataNode ); + m_Exclusions.Add( excludeNode ); } } diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs index 651c339..b63034b 100644 --- a/Prebuild/src/Core/Nodes/OptionsNode.cs +++ b/Prebuild/src/Core/Nodes/OptionsNode.cs @@ -23,17 +23,6 @@ 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 2d2162c..6bfbe16 100644 --- a/Prebuild/src/Core/Nodes/ProcessNode.cs +++ b/Prebuild/src/Core/Nodes/ProcessNode.cs @@ -23,15 +23,6 @@ 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 e98ab5f..0a24abf 100644 --- a/Prebuild/src/Core/Nodes/ProjectNode.cs +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -23,17 +23,9 @@ 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; @@ -59,7 +51,11 @@ namespace Prebuild.Core.Nodes /// /// The project is a library /// - Library + Library, + /// + /// The project is a website + /// + Web, } /// @@ -76,7 +72,25 @@ 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 /// @@ -95,35 +109,22 @@ 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; - private ArrayList m_ReferencePaths; - private ArrayList m_References; - private ArrayList m_Authors; + 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 FilesNode m_Files; #endregion - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - public ProjectNode() - { - m_Configurations = new Hashtable(); - m_ReferencePaths = new ArrayList(); - m_References = new ArrayList(); - m_Authors = new ArrayList(); - } - - #endregion - #region Properties /// @@ -134,10 +135,19 @@ namespace Prebuild.Core.Nodes { get { - return m_Name; + return m_Name; + } + } + /// + /// The version of the .NET Framework to compile under + /// + public FrameworkVersion FrameworkVersion + { + get + { + return this.m_Framework; } } - /// /// Gets the path. /// @@ -210,17 +220,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; + } + } /// /// @@ -269,22 +279,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. @@ -314,7 +324,7 @@ namespace Prebuild.Core.Nodes /// Gets the configurations. /// /// The configurations. - public ICollection Configurations + public IList Configurations { get { @@ -340,11 +350,11 @@ namespace Prebuild.Core.Nodes /// Gets the reference paths. /// /// The reference paths. - public ArrayList ReferencePaths + public List ReferencePaths { get { - ArrayList tmp = new ArrayList(m_ReferencePaths); + List tmp = new List(m_ReferencePaths); tmp.Sort(); return tmp; } @@ -354,11 +364,11 @@ namespace Prebuild.Core.Nodes /// Gets the references. /// /// The references. - public ArrayList References + public List References { get { - ArrayList tmp = new ArrayList(m_References); + List tmp = new List(m_References); tmp.Sort(); return tmp; } @@ -368,7 +378,7 @@ namespace Prebuild.Core.Nodes /// Gets the Authors list. /// /// The list of the project's authors. - public ArrayList Authors + public List Authors { get { @@ -424,7 +434,15 @@ namespace Prebuild.Core.Nodes } } - #endregion + public string DebugStartParameters + { + get + { + return m_DebugStartParameters; + } + } + + #endregion #region Private Methods @@ -470,13 +488,18 @@ 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(); - m_Guid = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + 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_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; @@ -516,15 +539,15 @@ namespace Prebuild.Core.Nodes } else if(dataNode is ReferencePathNode) { - m_ReferencePaths.Add(dataNode); + m_ReferencePaths.Add((ReferencePathNode)dataNode); } else if(dataNode is ReferenceNode) { - m_References.Add(dataNode); + m_References.Add((ReferenceNode)dataNode); } else if(dataNode is AuthorNode) { - m_Authors.Add(dataNode); + m_Authors.Add((AuthorNode)dataNode); } else if(dataNode is FilesNode) { @@ -548,6 +571,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 df0c2e4..9c5d1a3 100644 --- a/Prebuild/src/Core/Nodes/ReferenceNode.cs +++ b/Prebuild/src/Core/Nodes/ReferenceNode.cs @@ -23,15 +23,6 @@ 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 d4042ef..f0543c2 100644 --- a/Prebuild/src/Core/Nodes/ReferencePathNode.cs +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.cs @@ -23,15 +23,6 @@ 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 9473fe6..2a1b8e2 100644 --- a/Prebuild/src/Core/Nodes/SolutionNode.cs +++ b/Prebuild/src/Core/Nodes/SolutionNode.cs @@ -23,17 +23,9 @@ 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; @@ -48,40 +40,62 @@ 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 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(); - } + 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(); #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. /// @@ -195,7 +209,36 @@ 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. /// @@ -226,7 +269,7 @@ namespace Prebuild.Core.Nodes /// Gets the projects table. /// /// The projects table. - public ArrayList ProjectsTableOrder + public List ProjectsTableOrder { get { @@ -287,8 +330,21 @@ namespace Prebuild.Core.Nodes else if(dataNode is ProjectNode) { m_Projects[((ProjectNode)dataNode).Name] = dataNode; - m_ProjectsOrder.Add(dataNode); + m_ProjectsOrder.Add((ProjectNode)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 fc86885..3c79d38 100644 --- a/Prebuild/src/Core/Parse/IfContext.cs +++ b/Prebuild/src/Core/Parse/IfContext.cs @@ -23,15 +23,6 @@ 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 eea5c30..013f8e1 100644 --- a/Prebuild/src/Core/Parse/Preprocessor.cs +++ b/Prebuild/src/Core/Parse/Preprocessor.cs @@ -23,18 +23,10 @@ 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 @@ -79,6 +71,16 @@ 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; @@ -138,10 +140,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 @@ -236,7 +238,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]; @@ -283,7 +285,7 @@ namespace Prebuild.Core.Parse { oper = OperatorSymbol.NotEqual; } - + break; case '<': @@ -295,7 +297,7 @@ namespace Prebuild.Core.Parse { oper = OperatorSymbol.LessThan; } - + break; case '>': @@ -314,7 +316,7 @@ namespace Prebuild.Core.Parse } } - + if(inStr) { throw new WarningException("Expected end of string in expression"); @@ -392,9 +394,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 reader) + public string Process(XmlReader initialReader) { - if(reader == null) + if(initialReader == null) { throw new ArgumentException("Invalid XML reader to pre-process"); } @@ -403,119 +405,175 @@ namespace Prebuild.Core.Parse StringWriter xmlText = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(xmlText); writer.Formatting = Formatting.Indented; - while(reader.Read()) + + // 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) { - if(reader.NodeType == XmlNodeType.ProcessingInstruction) + // 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()) { - bool ignore = false; - switch(reader.LocalName) + // 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) { - case "if": - m_IfStack.Push(context); - context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); - ignore = true; - break; + bool ignore = 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'"); - } + 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."); + } - context.State = IfState.ElseIf; - if(!context.EverKept) - { - context.Keep = ParseExpression(reader.Value); - } - else - { - context.Keep = false; - } + 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); - ignore = true; - break; + if(!includeFile.Exists) + { + throw new WarningException("Cannot include file: " + includeFile.FullName); + } - 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'"); - } + // 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)); - context.State = IfState.Else; - context.Keep = !context.EverKept; - ignore = true; - break; + readerStack.Push(reader); + reader = newReader; + ignore = true; + break; - case "endif": - if(m_IfStack.Count == 0) - { - throw new WarningException("Unexpected 'endif' 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 = (IfContext)m_IfStack.Pop(); - 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'"); + } - if(ignore) - { - continue; - } - }//end pre-proc instruction + context.State = IfState.ElseIf; + if(!context.EverKept) + { + context.Keep = ParseExpression(reader.Value); + } + else + { + context.Keep = false; + } - if(!context.Active || !context.Keep) - { - continue; - } + ignore = true; + break; - switch(reader.NodeType) - { - case XmlNodeType.Element: - bool empty = reader.IsEmptyElement; - writer.WriteStartElement(reader.Name); + 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'"); + } - while (reader.MoveToNextAttribute()) - { - writer.WriteAttributeString(reader.Name, reader.Value); + context.State = IfState.Else; + context.Keep = !context.EverKept; + ignore = true; + break; + + case "endif": + if(m_IfStack.Count == 0) + { + throw new WarningException("Unexpected 'endif' outside of 'if'"); + } + + context = (IfContext)m_IfStack.Pop(); + ignore = true; + break; } - if(empty) + if(ignore) { - writer.WriteEndElement(); + continue; } - - break; + }//end pre-proc instruction - case XmlNodeType.EndElement: - writer.WriteEndElement(); - break; + if(!context.Active || !context.Keep) + { + continue; + } - case XmlNodeType.Text: - writer.WriteString(reader.Value); - break; + switch(reader.NodeType) + { + case XmlNodeType.Element: + bool empty = reader.IsEmptyElement; + writer.WriteStartElement(reader.Name); + + while (reader.MoveToNextAttribute()) + { + writer.WriteAttributeString(reader.Name, reader.Value); + } - case XmlNodeType.CDATA: - writer.WriteCData(reader.Value); - break; + if(empty) + { + writer.WriteEndElement(); + } + + break; - default: - break; + case XmlNodeType.EndElement: + writer.WriteEndElement(); + break; + + case XmlNodeType.Text: + writer.WriteString(reader.Value); + break; + + case XmlNodeType.CDATA: + writer.WriteCData(reader.Value); + break; + + default: + break; + } } - } - if(m_IfStack.Count != 0) - { - throw new WarningException("Mismatched 'if', 'endif' pair"); + 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 f102038..5dcbb38 100644 --- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs @@ -65,18 +65,9 @@ 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; @@ -182,8 +173,7 @@ namespace Prebuild.Core.Targets Hashtable assemblyPathToPackage = new Hashtable(); Hashtable assemblyFullNameToPath = new Hashtable(); Hashtable packagesHash = new Hashtable(); - ArrayList packages = new ArrayList(); - ClrVersion currentVersion; + readonly List packages = new List(); #endregion @@ -203,22 +193,6 @@ 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 = @@ -273,11 +247,11 @@ namespace Prebuild.Core.Targets } } - private ArrayList GetAssembliesWithLibInfo(string line, string file) + private List GetAssembliesWithLibInfo(string line, string file) { - ArrayList references = new ArrayList(); - ArrayList libdirs = new ArrayList(); - ArrayList retval = new ArrayList(); + List references = new List(); + List libdirs = new List(); + List retval = new List(); foreach (string piece in line.Split(' ')) { if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) @@ -304,9 +278,9 @@ namespace Prebuild.Core.Targets return retval; } - private ArrayList GetAssembliesWithoutLibInfo(string line, string file) + private List GetAssembliesWithoutLibInfo(string line, string file) { - ArrayList references = new ArrayList(); + List references = new List(); foreach (string reference in line.Split(' ')) { if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) @@ -356,7 +330,7 @@ namespace Prebuild.Core.Targets if (packagesHash.Contains(pname)) return; - ArrayList fullassemblies = null; + List fullassemblies = null; string version = ""; string desc = ""; @@ -404,7 +378,7 @@ namespace Prebuild.Core.Targets package.Initialize(pname, version, desc, - (string[])fullassemblies.ToArray(typeof(string)), + fullassemblies.ToArray(), ClrVersion.Default, false); packages.Add(package); @@ -414,7 +388,7 @@ namespace Prebuild.Core.Targets void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) { SystemPackage package = new SystemPackage(); - ArrayList list = new ArrayList(); + List list = new List(); string dir = Path.Combine(prefix, version); if (!Directory.Exists(dir)) @@ -431,7 +405,7 @@ namespace Prebuild.Core.Targets package.Initialize("mono", version, "The Mono runtime", - (string[])list.ToArray(typeof(string)), + list.ToArray(), ver, false); packages.Add(package); @@ -444,12 +418,10 @@ 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. @@ -483,9 +455,9 @@ namespace Prebuild.Core.Targets } } search_dirs += Path.PathSeparator + libpath; - if (search_dirs != null && search_dirs.Length > 0) + if (!string.IsNullOrEmpty(search_dirs)) { - ArrayList scanDirs = new ArrayList(); + List scanDirs = new List(); foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) { if (!scanDirs.Contains(potentialDir)) @@ -763,20 +735,22 @@ namespace Prebuild.Core.Targets bool hasAssemblyConfig = false; chkMkDir(projectDir); - ArrayList - compiledFiles = new ArrayList(), - contentFiles = new ArrayList(), - embeddedFiles = new ArrayList(), + List + compiledFiles = new List(), + contentFiles = new List(), + embeddedFiles = new List(), + + binaryLibs = new List(), + pkgLibs = new List(), + systemLibs = new List(), + runtimeLibs = new List(), - binaryLibs = new ArrayList(), - pkgLibs = new ArrayList(), - systemLibs = new ArrayList(), - runtimeLibs = new ArrayList(), + extraDistFiles = new List(), + localCopyTargets = new List(); - extraDistFiles = new ArrayList(), - localCopyTargets = new ArrayList(); + // If there exists a .config file for this assembly, copy + // it to the project folder - // 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; @@ -839,11 +813,15 @@ namespace Prebuild.Core.Targets foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) Console.WriteLine("Error! '{0}'", error.ErrorText); - string projectFullName = cr.CompiledAssembly.FullName; - Regex verRegex = new Regex("Version=([\\d\\.]+)"); - Match verMatch = verRegex.Match(projectFullName); - if (verMatch.Success) + try { + 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 @@ -853,7 +831,7 @@ namespace Prebuild.Core.Targets } catch { - //Console.WriteLine("Error! '{0}'", e.ToString()); + Console.WriteLine("Error! '{0}'", e.ToString()); } } @@ -1013,46 +991,46 @@ namespace Prebuild.Core.Targets } } - string lineSep = " \\\n\t"; + const string lineSep = " \\\n\t"; string compiledFilesString = string.Empty; if (compiledFiles.Count > 0) compiledFilesString = - lineSep + string.Join(lineSep, (string[])compiledFiles.ToArray(typeof(string))); + lineSep + string.Join(lineSep, compiledFiles.ToArray()); string embeddedFilesString = ""; if (embeddedFiles.Count > 0) embeddedFilesString = - lineSep + string.Join(lineSep, (string[])embeddedFiles.ToArray(typeof(string))); + lineSep + string.Join(lineSep, embeddedFiles.ToArray()); string contentFilesString = ""; if (contentFiles.Count > 0) contentFilesString = - lineSep + string.Join(lineSep, (string[])contentFiles.ToArray(typeof(string))); + lineSep + string.Join(lineSep, contentFiles.ToArray()); string extraDistFilesString = ""; if (extraDistFiles.Count > 0) extraDistFilesString = - lineSep + string.Join(lineSep, (string[])extraDistFiles.ToArray(typeof(string))); + lineSep + string.Join(lineSep, extraDistFiles.ToArray()); string pkgLibsString = ""; if (pkgLibs.Count > 0) pkgLibsString = - lineSep + string.Join(lineSep, (string[])pkgLibs.ToArray(typeof(string))); + lineSep + string.Join(lineSep, pkgLibs.ToArray()); string binaryLibsString = ""; if (binaryLibs.Count > 0) binaryLibsString = - lineSep + string.Join(lineSep, (string[])binaryLibs.ToArray(typeof(string))); + lineSep + string.Join(lineSep, binaryLibs.ToArray()); string systemLibsString = ""; if (systemLibs.Count > 0) systemLibsString = - lineSep + string.Join(lineSep, (string[])systemLibs.ToArray(typeof(string))); + lineSep + string.Join(lineSep, systemLibs.ToArray()); string localCopyTargetsString = ""; if (localCopyTargets.Count > 0) localCopyTargetsString = - string.Join("\n", (string[])localCopyTargets.ToArray(typeof(string))); + string.Join("\n", localCopyTargets.ToArray()); string monoPath = ""; foreach (string runtimeLib in runtimeLibs) diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs index db19e05..dc4e666 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 16:42:51 +0900 (Wed, 20 Sep 2006) $ + * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ * $Revision: 164 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index 5a5dc55..c8401fd 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -23,15 +23,6 @@ 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 eb5325d..9a6ee17 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,15 +35,6 @@ 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; @@ -58,85 +49,73 @@ 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)) { - 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; - - // 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), '/'); - } + 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; + } - // Is it a specified extension (dll or exe?) - if (ExtensionSpecified(refr.Name)) - { - return Helper.NormalizePath(referencePath + GetRefFileName(refr.Name), '/'); - } + ProjectNode project = (ProjectNode) refr.Parent; - // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway - return refr.Name + ".dll"; - } + // Do we have an explicit file reference? + string fileRef = FindFileReference(refr.Name, project); + if (fileRef != null) + { + return fileRef; } - else + + // Is there an explicit path in the project ref? + if (refr.Path != null) { - return refr.Path; + return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/'); } + + // 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)) { @@ -144,7 +123,7 @@ namespace Prebuild.Core.Targets } else { - return refName + ".dll"; + return refName + ".dll"; } } @@ -156,268 +135,235 @@ namespace Prebuild.Core.Targets private static string GetProjectExtension(ProjectNode project) { string extension = ".dll"; - if (project.Type == ProjectType.Exe) + if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe) { extension = ".exe"; } return extension; } - //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"); + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName); 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.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) { - ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); - break; + ss.WriteLine(" "); } - 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(" "); + 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)) { @@ -432,149 +378,160 @@ 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(); + 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(); ss.WriteLine(" "); ss.WriteLine(" "); diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs index 0d78796..66dd1bc 100644 --- a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs @@ -23,15 +23,6 @@ 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; @@ -43,18 +34,38 @@ namespace Prebuild.Core.Targets /// [Target("sharpdev2")] public class SharpDevelop2Target : VS2005Target - { - protected override string VersionName + { + #region Properties + public 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 6fe038b..cf7ce02 100644 --- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs @@ -23,15 +23,6 @@ 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 new file mode 100644 index 0000000..935c674 --- /dev/null +++ b/Prebuild/src/Core/Targets/ToolInfo.cs @@ -0,0 +1,197 @@ +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 7067cf3..2292624 100644 --- a/Prebuild/src/Core/Targets/VS2002Target.cs +++ b/Prebuild/src/Core/Targets/VS2002Target.cs @@ -23,15 +23,6 @@ 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 4bf05cb..1bcb7dc 100644 --- a/Prebuild/src/Core/Targets/VS2003Target.cs +++ b/Prebuild/src/Core/Targets/VS2003Target.cs @@ -23,15 +23,6 @@ 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; @@ -44,28 +35,6 @@ 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 5b7ad07..63461c9 100644 --- a/Prebuild/src/Core/Targets/VS2005Target.cs +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -23,15 +23,6 @@ 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; @@ -48,182 +39,8 @@ 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 : ITarget + public class VS2005Target : VSGenericTarget { #region Inner Classes @@ -231,694 +48,100 @@ namespace Prebuild.Core.Targets #region Fields + string solutionVersion = "9.00"; + string productVersion = "8.0.50727"; string schemaVersion = "2.0"; - VSVersion version = VSVersion.VS80; + string versionName = "Visual C# 2005"; + string name = "vs2005"; - Hashtable tools; - Kernel kernel; + VSVersion version = VSVersion.VS80; - protected virtual string ToolsVersionXml + public override string SolutionTag { - get - { - return String.Empty; - } + get { return "# Visual Studio 2005"; } } - protected virtual string SolutionTag + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) { - get { return "# Visual Studio 2005"; } + return string.Empty; } - /// /// Gets or sets the solution version. /// /// The solution version. - protected virtual string SolutionVersion + public override string SolutionVersion { get { - return "9.00"; + return solutionVersion; } } - /// /// Gets or sets the product version. /// /// The product version. - protected virtual string ProductVersion + public override string ProductVersion { get { - return "8.0.50727"; + return productVersion; } } - /// /// Gets or sets the schema version. /// /// The schema version. - protected string SchemaVersion + public override string SchemaVersion { get { - return this.schemaVersion; - } - set - { - this.schemaVersion = value; + return schemaVersion; } } - /// /// Gets or sets the name of the version. /// /// The name of the version. - protected virtual string VersionName + public override string VersionName { get { - return "Visual C# 2005"; + return versionName; } } - /// /// Gets or sets the version. /// /// The version. - protected VSVersion Version + public override VSVersion Version { get { - return this.version; - } - set - { - this.version = value; + return version; } } - - #endregion - - #region Constructors - /// - /// Initializes a new instance of the class. + /// Gets the name. /// - public VS2005Target() - { - 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) - { - 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) + /// The name. + public override string Name { - 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) + get { - CleanProject(project); + return name; } - - 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); - } - 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; - } + #region Constructors /// - /// Gets the name. + /// Initializes a new instance of the class. /// - /// The name. - public virtual string Name - { - get - { - return "vs2005"; - } + public VS2005Target() + : base() + { } #endregion diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs index 88bb5e6..f30017b 100644 --- a/Prebuild/src/Core/Targets/VS2008Target.cs +++ b/Prebuild/src/Core/Targets/VS2008Target.cs @@ -1,56 +1,132 @@ using System; -using System.Collections.Generic; +using System.Collections; +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 { - [Target("vs2008")] - public class VS2008Target : VS2005Target - { - protected override string SolutionTag - { - get { return "# Visual Studio 2008"; } - } - protected override string SolutionVersion - { - get - { - return "10.00"; - } - } + /// + /// + /// + [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; - protected override string VersionName - { - get - { - return "Visual C# 2008"; - } - } + Hashtable tools; + Kernel kernel; - protected override string ToolsVersionXml - { - get - { - return " ToolsVersion=\"3.5\""; - } - } + /// + /// 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 ProductVersion + protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion) { - get + switch (frameworkVersion) { - return "9.0.21022"; + case FrameworkVersion.v3_5: + return "ToolsVersion=\"3.5\""; + case FrameworkVersion.v3_0: + return "ToolsVersion=\"3.0\""; + default: + return "ToolsVersion=\"2.0\""; } } - public override string Name + public override string SolutionTag { - get - { - return "vs2008"; - } + get { return "# Visual Studio 2008"; } } - } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2008Target() + : base() + { + } + + #endregion + } } diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs new file mode 100644 index 0000000..401331d --- /dev/null +++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs @@ -0,0 +1,881 @@ +#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 new file mode 100644 index 0000000..f477086 --- /dev/null +++ b/Prebuild/src/Core/Targets/VSVersion.cs @@ -0,0 +1,50 @@ +#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 ee3b241..d96f65b 100644 --- a/Prebuild/src/Core/Targets/XcodeTarget.cs +++ b/Prebuild/src/Core/Targets/XcodeTarget.cs @@ -23,15 +23,6 @@ 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 5733547..22752aa 100644 --- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs +++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs @@ -23,15 +23,6 @@ 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 abbed52..5fabdf0 100644 --- a/Prebuild/src/Core/Utilities/CurrentDirectory.cs +++ b/Prebuild/src/Core/Utilities/CurrentDirectory.cs @@ -23,15 +23,6 @@ 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 19093ce..9a0d131 100644 --- a/Prebuild/src/Core/Utilities/Helper.cs +++ b/Prebuild/src/Core/Utilities/Helper.cs @@ -23,15 +23,6 @@ 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; @@ -289,6 +280,8 @@ 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 @@ -298,8 +291,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, '/'); - string src = NormalizePath(endPath, '/'); + string tmp = NormalizePath(startPath, seperator); + string src = NormalizePath(endPath, seperator); string prefix = ""; while(true) @@ -312,14 +305,14 @@ namespace Prebuild.Core.Utilities { return "./"; } - if ((src.Length > tmp.Length) && src[tmp.Length-1] != '/' && src[tmp.Length-1] != '\\') + if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) { } else { ret = prefix + endPath.Substring(size, endPath.Length - size); ret = ret.Trim(); - if(ret[0] == '/' || ret[0] == '\\') + if(ret[0] == seperator) { ret = "." + ret; } @@ -334,8 +327,8 @@ namespace Prebuild.Core.Utilities break; } - int lastPos = tmp.LastIndexOf('/', tmp.Length - 2); - int prevPos = tmp.IndexOf('/'); + int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); + int prevPos = tmp.IndexOf(seperator); if((lastPos == prevPos) || (lastPos == -1)) { @@ -343,7 +336,7 @@ namespace Prebuild.Core.Utilities } tmp = tmp.Substring(0, lastPos + 1); - prefix += "../"; + prefix += ".." + seperator.ToString(); } return endPath; diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs index e8105ac..548e987 100644 --- a/Prebuild/src/Core/Utilities/Log.cs +++ b/Prebuild/src/Core/Utilities/Log.cs @@ -23,15 +23,6 @@ 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; diff --git a/Prebuild/src/Prebuild.cs b/Prebuild/src/Prebuild.cs index 922b4c9..2d12b53 100644 --- a/Prebuild/src/Prebuild.cs +++ b/Prebuild/src/Prebuild.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-27 06:43:35 +0900 (Wed, 27 Sep 2006) $ + * $Date: 2006-09-26 23:43:35 +0200 (ti, 26 sep 2006) $ * $Revision: 168 $ */ #endregion diff --git a/Prebuild/src/Properties/AssemblyInfo.cs b/Prebuild/src/Properties/AssemblyInfo.cs index e49aea5..65c8736 100644 --- a/Prebuild/src/Properties/AssemblyInfo.cs +++ b/Prebuild/src/Properties/AssemblyInfo.cs @@ -38,15 +38,6 @@ 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.Reflection; using System.Runtime.CompilerServices; @@ -79,7 +70,7 @@ using System.Resources; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguageAttribute("en-US")] -[assembly: AssemblyVersion("2.0.3.*")] +[assembly: AssemblyVersion("2.0.4.*")] // // Version information for an assembly consists of the following four values: diff --git a/Prebuild/src/data/prebuild-1.7.xsd b/Prebuild/src/data/prebuild-1.7.xsd index 3c108f3..c3f8d6b 100644 --- a/Prebuild/src/data/prebuild-1.7.xsd +++ b/Prebuild/src/data/prebuild-1.7.xsd @@ -2,39 +2,40 @@ - Copyright (c) 2004-2007 - Matthew Holmes (calefaction at houston . rr . com), - Dan Moorehead (dan05a at gmail . com), - David Hudson (jendave at yahoo dot com), - C.J. Adams-Collier (cjac at colliertech dot com) + Copyright (c) 2004-2007 + Matthew Holmes (calefaction at houston . rr . com), + Dan Moorehead (dan05a at gmail . com), + David Hudson (jendave at yahoo dot com), + C.J. Adams-Collier (cjac at colliertech dot com) - .NET Prebuild is a cross-platform XML-driven pre-build tool which - allows developers to easily generate project or make files for major - IDE's and .NET development tools including: Visual Studio .NET 2002, - 2003, and 2005, SharpDevelop, MonoDevelop, NAnt, Xcode and the GNU Autotools. + .NET Prebuild is a cross-platform XML-driven pre-build tool which + allows developers to easily generate project or make files for major + IDE's and .NET development tools including: Visual Studio .NET 2002, + 2003, and 2005, SharpDevelop, MonoDevelop, NAnt, Xcode and the GNU Autotools. - BSD License: - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: + BSD License: - * 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. + Redistribution and use in source and binary forms, with or without modification, are permitted + provided that the following conditions are met: - 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. - + * 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. + + @@ -45,14 +46,35 @@ + + - + + + + + + + + + + + + + + + + + + - + + + @@ -60,12 +82,33 @@ + + + + + + + + + + + + + + + + + + + + + - + @@ -84,6 +127,7 @@ + @@ -98,6 +142,7 @@ + @@ -109,12 +154,23 @@ + + + + + + + + + + + @@ -195,6 +251,7 @@ + @@ -242,6 +299,7 @@ + diff --git a/Prebuild/tests/Makefile b/Prebuild/tests/Makefile new file mode 100644 index 0000000..4a8ddf4 --- /dev/null +++ b/Prebuild/tests/Makefile @@ -0,0 +1,24 @@ +# +# Executable +# + +# Executables +PREBUILD = mono ../src/bin/Release/prebuild.exe /target makefile + +# Files +PREBUILDS = $(wildcard *.prebuild) +RESULTS = $(PREBUILDS:prebuild=results) +TESTS = $(PREBUILDS:prebuild=test) + +all: $(TESTS) + +clean: + rm -f *~ *.log + rm -f $(RESULTS) + +%.test: %.prebuild + $(PREBUILD) /log $*.log /file $*.prebuild /ppi $*.results >& /dev/null + if ! cmp $*.expected $*.results; then \ + echo $*.prebuild failed; \ + false; \ + fi diff --git a/Prebuild/tests/README.txt b/Prebuild/tests/README.txt new file mode 100644 index 0000000..2c2de3b --- /dev/null +++ b/Prebuild/tests/README.txt @@ -0,0 +1,5 @@ +There are some tests that are run via a Makfile in this +directory. They haven't been included in any form of unit tests, but +they are there to help test the functionality in some what. Simply +build prebuild (so there is a src/bin/Release/prebuild.exe) and type +`make` in this directory. Everything should pass without errors. diff --git a/Prebuild/tests/include-001.expected b/Prebuild/tests/include-001.expected new file mode 100644 index 0000000..26374b5 --- /dev/null +++ b/Prebuild/tests/include-001.expected @@ -0,0 +1,46 @@ + + + + + DEBUG;TRACE + false + bin/Debug + true + + + + + TRACE + bin/Release + true + false + + + + + + DEBUG;TRACE + false + bin/Debug + true + Prebuild.snk + 1595 + + + + + TRACE + bin/Release + true + false + Prebuild.snk + 1595 + + + + + + + + + diff --git a/Prebuild/tests/include-001.include b/Prebuild/tests/include-001.include new file mode 100644 index 0000000..7f75962 --- /dev/null +++ b/Prebuild/tests/include-001.include @@ -0,0 +1,33 @@ + + + + DEBUG;TRACE + false + bin/Debug + true + Prebuild.snk + 1595 + + + + + TRACE + bin/Release + true + false + Prebuild.snk + 1595 + + + + + + + diff --git a/Prebuild/tests/include-001.prebuild b/Prebuild/tests/include-001.prebuild new file mode 100644 index 0000000..8047008 --- /dev/null +++ b/Prebuild/tests/include-001.prebuild @@ -0,0 +1,22 @@ + + + + + + DEBUG;TRACE + false + bin/Debug + true + + + + + TRACE + bin/Release + true + false + + + + + diff --git a/Prebuild/tests/include-002-2.include b/Prebuild/tests/include-002-2.include new file mode 100644 index 0000000..661b7f3 --- /dev/null +++ b/Prebuild/tests/include-002-2.include @@ -0,0 +1,8 @@ + + + DEBUG;TRACE + false + bin/Debug + true + + diff --git a/Prebuild/tests/include-002.expected b/Prebuild/tests/include-002.expected new file mode 100644 index 0000000..9849658 --- /dev/null +++ b/Prebuild/tests/include-002.expected @@ -0,0 +1,26 @@ + + + + + DEBUG;TRACE + false + bin/Debug + true + + + + + + DEBUG;TRACE + false + bin/Debug + true + + + + + + + + + diff --git a/Prebuild/tests/include-002.include b/Prebuild/tests/include-002.include new file mode 100644 index 0000000..64f4058 --- /dev/null +++ b/Prebuild/tests/include-002.include @@ -0,0 +1,14 @@ + + + + + + + diff --git a/Prebuild/tests/include-002.prebuild b/Prebuild/tests/include-002.prebuild new file mode 100644 index 0000000..9e85f20 --- /dev/null +++ b/Prebuild/tests/include-002.prebuild @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.1