From 79209c429705beb57ad9b787718856ab2c9fd37c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 17 Mar 2008 20:55:21 +0000 Subject: Merged changes in Prebuild trunk up to r258 into OpenSim's Prebuild. Hopefully this should make merging upstream easier. Building with NAnt should still work, but Visual Studio is untested. --- Prebuild/src/Core/Attributes/DataNodeAttribute.cs | 2 +- .../src/Core/Attributes/OptionNodeAttribute.cs | 2 +- Prebuild/src/Core/Attributes/TargetAttribute.cs | 2 +- Prebuild/src/Core/FatalException.cs | 2 +- Prebuild/src/Core/Interfaces/IDataNode.cs | 2 +- Prebuild/src/Core/Interfaces/ITarget.cs | 2 +- Prebuild/src/Core/Kernel.cs | 120 +- Prebuild/src/Core/Nodes/AuthorNode.cs | 98 + Prebuild/src/Core/Nodes/ConfigurationNode.cs | 4 +- Prebuild/src/Core/Nodes/DataNode.cs | 2 +- Prebuild/src/Core/Nodes/DescriptionNode.cs | 98 + Prebuild/src/Core/Nodes/ExcludeNode.cs | 27 +- Prebuild/src/Core/Nodes/FileNode.cs | 33 +- Prebuild/src/Core/Nodes/FilesNode.cs | 56 +- Prebuild/src/Core/Nodes/MatchNode.cs | 78 +- Prebuild/src/Core/Nodes/OptionsNode.cs | 2 +- Prebuild/src/Core/Nodes/ProcessNode.cs | 2 +- Prebuild/src/Core/Nodes/ProjectNode.cs | 79 +- Prebuild/src/Core/Nodes/ReferenceNode.cs | 4 +- Prebuild/src/Core/Nodes/ReferencePathNode.cs | 4 +- Prebuild/src/Core/Nodes/SolutionNode.cs | 34 +- Prebuild/src/Core/Parse/IfContext.cs | 2 +- Prebuild/src/Core/Parse/Preprocessor.cs | 4 +- Prebuild/src/Core/Targets/AutotoolsTarget.cs | 2408 +++++++++++++------- Prebuild/src/Core/Targets/DebugTarget.cs | 2 +- Prebuild/src/Core/Targets/MakefileTarget.cs | 471 ++++ Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 27 +- Prebuild/src/Core/Targets/NAntTarget.cs | 103 +- Prebuild/src/Core/Targets/SharpDevelop2Target.cs | 2 +- Prebuild/src/Core/Targets/SharpDevelopTarget.cs | 2 +- Prebuild/src/Core/Targets/VS2002Target.cs | 2 +- Prebuild/src/Core/Targets/VS2003Target.cs | 2 +- Prebuild/src/Core/Targets/VS2005Target.cs | 89 +- Prebuild/src/Core/Targets/XcodeTarget.cs | 605 +++++ .../src/Core/Utilities/CommandLineCollection.cs | 2 +- Prebuild/src/Core/Utilities/CurrentDirectory.cs | 2 +- Prebuild/src/Core/Utilities/Helper.cs | 2 +- Prebuild/src/Core/Utilities/Log.cs | 2 +- Prebuild/src/Core/WarningException.cs | 9 - Prebuild/src/Prebuild.cs | 2 +- Prebuild/src/Properties/AssemblyInfo.cs | 64 +- Prebuild/src/data/autotools.xml | 790 +++++++ Prebuild/src/data/prebuild-1.7.xsd | 480 ++-- 43 files changed, 4484 insertions(+), 1241 deletions(-) create mode 100644 Prebuild/src/Core/Nodes/AuthorNode.cs create mode 100644 Prebuild/src/Core/Nodes/DescriptionNode.cs create mode 100644 Prebuild/src/Core/Targets/MakefileTarget.cs create mode 100644 Prebuild/src/Core/Targets/XcodeTarget.cs create mode 100644 Prebuild/src/data/autotools.xml (limited to 'Prebuild/src') diff --git a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs index 0786fe5..cdd0e0d 100644 --- a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/DataNodeAttribute.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs index a63e840..5cefe68 100644 --- a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs +++ b/Prebuild/src/Core/Attributes/OptionNodeAttribute.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Attributes/TargetAttribute.cs b/Prebuild/src/Core/Attributes/TargetAttribute.cs index 8724d69..b17cc5b 100644 --- a/Prebuild/src/Core/Attributes/TargetAttribute.cs +++ b/Prebuild/src/Core/Attributes/TargetAttribute.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/FatalException.cs b/Prebuild/src/Core/FatalException.cs index a997c98..784c35d 100644 --- a/Prebuild/src/Core/FatalException.cs +++ b/Prebuild/src/Core/FatalException.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Interfaces/IDataNode.cs b/Prebuild/src/Core/Interfaces/IDataNode.cs index 2562b1d..7583fd2 100644 --- a/Prebuild/src/Core/Interfaces/IDataNode.cs +++ b/Prebuild/src/Core/Interfaces/IDataNode.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Interfaces/ITarget.cs b/Prebuild/src/Core/Interfaces/ITarget.cs index e74ff9a..77006d7 100644 --- a/Prebuild/src/Core/Interfaces/ITarget.cs +++ b/Prebuild/src/Core/Interfaces/ITarget.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs index 170d0f5..1f0ad70 100644 --- a/Prebuild/src/Core/Kernel.cs +++ b/Prebuild/src/Core/Kernel.cs @@ -1,34 +1,47 @@ #region BSD License /* -Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) - -Redistribution and use in source and binary forms, with or without modification, are permitted -provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions - and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions - and the following disclaimer in the documentation and/or other materials provided with the - distribution. -* The name of the author may not be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2004-2008 +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +Rob Loach (http://www.robloach.net), +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 +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + */ #endregion #region CVS Information /* * $Source$ - * $Author: robloach $ - * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ - * $Revision: 165 $ + * $Author: cjcollier $ + * $Date: 2008-02-08 01:31:29 +0900 (Fri, 08 Feb 2008) $ + * $Revision: 256 $ */ #endregion @@ -91,6 +104,7 @@ namespace Prebuild.Core string m_Clean; string[] m_RemoveDirectories; string m_CurrentFile; + XmlDocument m_CurrentDoc; bool m_PauseAfterFinish; string[] m_ProjectGroups; StringCollection m_Refs; @@ -203,6 +217,19 @@ namespace Prebuild.Core return m_Solutions; } } + + /// + /// Gets the XmlDocument object representing the prebuild.xml + /// being processed + /// + /// The XmlDocument object + public XmlDocument CurrentDoc + { + get + { + return m_CurrentDoc; + } + } #endregion @@ -304,10 +331,16 @@ namespace Prebuild.Core private void LogBanner() { - m_Log.Write("Prebuild v" + this.Version); - m_Log.Write("Copyright (c) Matthew Holmes, Dan Moorehead and David Hudson"); - m_Log.Write("See 'prebuild /usage' for help"); - m_Log.Write(); + m_Log.Write("Prebuild v" + this.Version); + m_Log.Write("Copyright (c) 2004-2008"); + m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); + m_Log.Write("Dan Moorehead (dan05a@gmail.com),"); + m_Log.Write("David Hudson (jendave@yahoo.com),"); + m_Log.Write("Rob Loach (http://www.robloach.net),"); + m_Log.Write("C.J. Adams-Collier (cjac@colliertech.org),"); + + m_Log.Write("See 'prebuild /usage' for help"); + m_Log.Write(); } private void ProcessFile(string file) @@ -330,7 +363,6 @@ namespace Prebuild.Core m_CurrentFile = path; Helper.SetCurrentDir(Path.GetDirectoryName(path)); - XmlTextReader reader = new XmlTextReader(path); @@ -348,7 +380,7 @@ namespace Prebuild.Core string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML - XmlDocument doc = new XmlDocument(); + m_CurrentDoc = new XmlDocument(); try { XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); @@ -358,7 +390,7 @@ namespace Prebuild.Core { validator.Schemas.Add(schema); } - doc.Load(validator); + m_CurrentDoc.Load(validator); } catch(XmlException e) { @@ -394,7 +426,7 @@ namespace Prebuild.Core return; } //start reading the xml config file - XmlElement rootNode = doc.DocumentElement; + XmlElement rootNode = m_CurrentDoc.DocumentElement; //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); @@ -681,17 +713,21 @@ namespace Prebuild.Core } else { - ITarget targ = (ITarget)m_Targets[target]; + if (!m_Targets.Contains(target)) { + m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); + return; + } + ITarget targ = (ITarget)m_Targets[target]; - if(clean) - { - targ.Clean(this); - } - else - { - targ.Write(this); - } - } + if(clean) + { + targ.Clean(this); + } + else + { + targ.Write(this); + } + } m_Log.Flush(); } @@ -755,4 +791,4 @@ namespace Prebuild.Core #endregion } -} \ No newline at end of file +} diff --git a/Prebuild/src/Core/Nodes/AuthorNode.cs b/Prebuild/src/Core/Nodes/AuthorNode.cs new file mode 100644 index 0000000..03ea934 --- /dev/null +++ b/Prebuild/src/Core/Nodes/AuthorNode.cs @@ -0,0 +1,98 @@ +#region BSD License +/* +Copyright (c) 2007 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 met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source $ + * $Author: $ + * $Date: $ + * $Revision: $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// + /// + [DataNode("Author")] + public class AuthorNode : DataNode + { + #region Fields + + private string m_Signature; + + #endregion + + #region Properties + + /// + /// Gets the signature. + /// + /// The signature. + public string Signature + { + get + { + return m_Signature; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Signature = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Signature == null) + { + m_Signature = ""; + } + + m_Signature = m_Signature.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs index d2a5d20..828bff6 100644 --- a/Prebuild/src/Core/Nodes/ConfigurationNode.cs +++ b/Prebuild/src/Core/Nodes/ConfigurationNode.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion @@ -183,5 +183,5 @@ namespace Prebuild.Core.Nodes } #endregion - } + } } diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs index aa05faa..60ed122 100644 --- a/Prebuild/src/Core/Nodes/DataNode.cs +++ b/Prebuild/src/Core/Nodes/DataNode.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Nodes/DescriptionNode.cs b/Prebuild/src/Core/Nodes/DescriptionNode.cs new file mode 100644 index 0000000..cff7afc --- /dev/null +++ b/Prebuild/src/Core/Nodes/DescriptionNode.cs @@ -0,0 +1,98 @@ +#region BSD License +/* +Copyright (c) 2007 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 met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source $ + * $Author: $ + * $Date: $ + * $Revision: $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Xml; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Nodes +{ + /// + /// The object representing the /Prebuild/Solution/Project/Description element + /// + [DataNode("Description")] + public class DescriptionNode : DataNode + { + #region Fields + + private string m_Value; + + #endregion + + #region Properties + + /// + /// Gets the description Value. + /// + /// The description Value. + public string Value + { + get + { + return m_Value; + } + } + + #endregion + + #region Public Methods + + /// + /// Parses the specified node. + /// + /// The node. + public override void Parse(XmlNode node) + { + if( node == null ) + { + throw new ArgumentNullException("node"); + } + + m_Value = Helper.InterpolateForEnvironmentVariables(node.InnerText); + if(m_Value == null) + { + m_Value = ""; + } + + m_Value = m_Value.Trim(); + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs index 905626d..afc869d 100644 --- a/Prebuild/src/Core/Nodes/ExcludeNode.cs +++ b/Prebuild/src/Core/Nodes/ExcludeNode.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2006-01-31 16:35:39 +0100 (ti, 31 jan 2006) $ - * $Revision: 74 $ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ */ #endregion @@ -49,7 +49,7 @@ namespace Prebuild.Core.Nodes { #region Fields - private string m_Name = "unknown"; + private string m_Pattern = ""; #endregion @@ -63,11 +63,23 @@ namespace Prebuild.Core.Nodes { get { - return m_Name; + return m_Pattern; } } - #endregion + /// + /// Gets the pattern. + /// + /// The pattern. + public string Pattern + { + get + { + return m_Pattern; + } + } + + #endregion #region Public Methods @@ -77,7 +89,8 @@ namespace Prebuild.Core.Nodes /// The node. public override void Parse(XmlNode node) { - m_Name = Helper.AttributeValue(node, "name", m_Name); + m_Pattern = Helper.AttributeValue( node, "name", m_Pattern ); + m_Pattern = Helper.AttributeValue(node, "pattern", m_Pattern ); } #endregion diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs index ab0a2a3..083dba5 100644 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ b/Prebuild/src/Core/Nodes/FileNode.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ - * $Revision: 197 $ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ */ #endregion @@ -118,6 +118,8 @@ namespace Prebuild.Core.Nodes private SubType m_SubType = SubType.Code; private CopyToOutput m_CopyToOutput = CopyToOutput.Never; private bool m_Link = false; + private string m_LinkPath = string.Empty; + private bool m_PreservePath = false; #endregion @@ -173,6 +175,13 @@ namespace Prebuild.Core.Nodes } } + public string LinkPath + { + get + { + return this.m_LinkPath; + } + } /// /// /// @@ -195,6 +204,19 @@ namespace Prebuild.Core.Nodes } } + /// + /// + /// + /// + /// + public bool PreservePath + { + get + { + return m_PreservePath; + } + } + #endregion #region Public Methods @@ -211,7 +233,12 @@ namespace Prebuild.Core.Nodes Helper.AttributeValue(node, "subType", m_SubType.ToString())); m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( this.m_Link == true ) + { + this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); + this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); if( node == null ) { diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs index 05b2255..7c1dd19 100644 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ b/Prebuild/src/Core/Nodes/FilesNode.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ - * $Revision: 164 $ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ */ #endregion @@ -56,7 +56,8 @@ namespace Prebuild.Core.Nodes private Hashtable m_ResourceNames; private Hashtable m_CopyToOutputs; private Hashtable m_Links; - + private Hashtable m_LinkPaths; + private Hashtable m_PreservePaths; #endregion @@ -73,7 +74,9 @@ namespace Prebuild.Core.Nodes m_ResourceNames = new Hashtable(); m_CopyToOutputs = new Hashtable(); m_Links = new Hashtable(); - } + m_LinkPaths = new Hashtable(); + m_PreservePaths = new Hashtable(); + } #endregion @@ -127,6 +130,15 @@ namespace Prebuild.Core.Nodes return (bool) this.m_Links[file]; } + public string GetLinkPath( string file ) + { + if ( !this.m_LinkPaths.ContainsKey( file ) ) + { + return string.Empty; + } + return (string)this.m_LinkPaths[ file ]; + } + /// /// /// @@ -157,6 +169,21 @@ namespace Prebuild.Core.Nodes return (string)m_ResourceNames[file]; } + /// + /// + /// + /// + /// + public bool GetPreservePath( string file ) + { + if ( !m_PreservePaths.ContainsKey( file ) ) + { + return false; + } + + return (bool)m_PreservePaths[ file ]; + } + /// /// /// @@ -181,8 +208,10 @@ namespace Prebuild.Core.Nodes m_BuildActions[fileNode.Path] = fileNode.BuildAction; m_SubTypes[fileNode.Path] = fileNode.SubType; m_ResourceNames[fileNode.Path] = fileNode.ResourceName; - this.m_Links[fileNode.Path] = fileNode.IsLink; - this.m_CopyToOutputs[fileNode.Path] = fileNode.CopyToOutput; + this.m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; + this.m_Links[ fileNode.Path ] = fileNode.IsLink; + this.m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; + this.m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; } } @@ -191,14 +220,17 @@ namespace Prebuild.Core.Nodes { foreach(string file in ((MatchNode)dataNode).Files) { + MatchNode matchNode = (MatchNode)dataNode; if (!m_Files.Contains(file)) { m_Files.Add(file); - m_BuildActions[file] = ((MatchNode)dataNode).BuildAction; - m_SubTypes[file] = ((MatchNode)dataNode).SubType; - m_ResourceNames[file] = ((MatchNode)dataNode).ResourceName; - this.m_Links[file] = ((MatchNode) dataNode).IsLink; - this.m_CopyToOutputs[file] = ((MatchNode) dataNode).CopyToOutput; + m_BuildActions[ file ] = matchNode.BuildAction; + m_SubTypes[ file ] = matchNode.SubType; + m_ResourceNames[ file ] = matchNode.ResourceName; + this.m_PreservePaths[ file ] = matchNode.PreservePath; + this.m_Links[ file ] = matchNode.IsLink; + this.m_LinkPaths[ file ] = matchNode.LinkPath; + this.m_CopyToOutputs[ file ] = matchNode.CopyToOutput; } } diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs index 8d7b467..aeaf3c1 100644 --- a/Prebuild/src/Core/Nodes/MatchNode.cs +++ b/Prebuild/src/Core/Nodes/MatchNode.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ - * $Revision: 164 $ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ */ #endregion @@ -41,6 +41,7 @@ using System.Xml; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; using Prebuild.Core.Utilities; +using System.Collections; namespace Prebuild.Core.Nodes { @@ -59,7 +60,9 @@ namespace Prebuild.Core.Nodes string m_ResourceName = ""; private CopyToOutput m_CopyToOutput; private bool m_Link; - + private string m_LinkPath; + private bool m_PreservePath; + private ArrayList m_Exclusions; #endregion @@ -71,6 +74,7 @@ namespace Prebuild.Core.Nodes public MatchNode() { m_Files = new StringCollection(); + m_Exclusions = new ArrayList(); } #endregion @@ -126,6 +130,13 @@ namespace Prebuild.Core.Nodes } } + public string LinkPath + { + get + { + return this.m_LinkPath; + } + } /// /// /// @@ -137,6 +148,13 @@ namespace Prebuild.Core.Nodes } } + public bool PreservePath + { + get + { + return m_PreservePath; + } + } #endregion @@ -149,8 +167,10 @@ 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) + private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, ArrayList exclusions) { + Match match; + Boolean excludeFile; try { string[] files; @@ -163,6 +183,7 @@ namespace Prebuild.Core.Nodes string fileTemp; foreach (string file in files) { + excludeFile = false; if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") { fileTemp = file.Substring(2); @@ -171,8 +192,20 @@ namespace Prebuild.Core.Nodes { fileTemp = file; } - - m_Files.Add(fileTemp); + + // Check all excludions and set flag if there are any hits. + foreach ( ExcludeNode exclude in exclusions ) + { + Regex exRegEx = new Regex( exclude.Pattern ); + match = exRegEx.Match( file ); + excludeFile |= match.Success; + } + + if ( !excludeFile ) + { + m_Files.Add( fileTemp ); + } + } } else @@ -182,14 +215,26 @@ namespace Prebuild.Core.Nodes } else { - Match match; files = Directory.GetFiles(path); foreach(string file in files) { + excludeFile = false; + match = m_Regex.Match(file); if(match.Success) { - m_Files.Add(file); + // Check all excludions and set flag if there are any hits. + foreach ( ExcludeNode exclude in exclusions ) + { + Regex exRegEx = new Regex( exclude.Pattern ); + match = exRegEx.Match( file ); + excludeFile |= !match.Success; + } + + if ( !excludeFile ) + { + m_Files.Add( file ); + } } } } @@ -201,7 +246,7 @@ namespace Prebuild.Core.Nodes { foreach(string str in dirs) { - RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex); + RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex, exclusions); } } } @@ -241,6 +286,11 @@ namespace Prebuild.Core.Nodes m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); + if ( this.m_Link == true ) + { + this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); + } + this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); if(path != null && path.Length == 0) @@ -272,7 +322,6 @@ namespace Prebuild.Core.Nodes throw new WarningException("Could not compile regex pattern: {0}", ex.Message); } - RecurseDirectories(path, pattern, recurse, useRegex); foreach(XmlNode child in node.ChildNodes) { @@ -280,13 +329,12 @@ namespace Prebuild.Core.Nodes if(dataNode is ExcludeNode) { ExcludeNode excludeNode = (ExcludeNode)dataNode; - if (m_Files.Contains(Helper.NormalizePath(excludeNode.Name))) - { - m_Files.Remove(Helper.NormalizePath(excludeNode.Name)); - } + m_Exclusions.Add( dataNode ); } } + RecurseDirectories( path, pattern, recurse, useRegex, m_Exclusions ); + if(m_Files.Count < 1) { throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs index b7a784d..651c339 100644 --- a/Prebuild/src/Core/Nodes/OptionsNode.cs +++ b/Prebuild/src/Core/Nodes/OptionsNode.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: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $ + * $Date: 2007-01-09 01:55:40 +0900 (Tue, 09 Jan 2007) $ * $Revision: 197 $ */ #endregion diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs index 5f3dbe6..2d2162c 100644 --- a/Prebuild/src/Core/Nodes/ProcessNode.cs +++ b/Prebuild/src/Core/Nodes/ProcessNode.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs index bddaace..e98ab5f 100644 --- a/Prebuild/src/Core/Nodes/ProjectNode.cs +++ b/Prebuild/src/Core/Nodes/ProjectNode.cs @@ -27,8 +27,8 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O /* * $Source$ * $Author: jendave $ - * $Date: 2006-11-11 05:43:20 +0100 (lö, 11 nov 2006) $ - * $Revision: 192 $ + * $Date: 2007-05-26 06:58:26 +0900 (Sat, 26 May 2007) $ + * $Revision: 244 $ */ #endregion @@ -44,20 +44,20 @@ using Prebuild.Core.Utilities; namespace Prebuild.Core.Nodes { /// - /// + /// A set of values that the Project's type can be /// public enum ProjectType { /// - /// + /// The project is a console executable /// Exe, /// - /// + /// The project is a windows executable /// WinExe, /// - /// + /// The project is a library /// Library } @@ -78,7 +78,7 @@ namespace Prebuild.Core.Nodes } /// - /// + /// The Node object representing /Prebuild/Solution/Project elements /// [DataNode("Project")] public class ProjectNode : DataNode, IComparable @@ -90,6 +90,7 @@ namespace Prebuild.Core.Nodes private string m_FullPath = ""; private string m_AssemblyName; private string m_AppIcon = ""; + private string m_ConfigFile = ""; private string m_DesignerFolder = ""; private string m_Language = "C#"; private ProjectType m_Type = ProjectType.Exe; @@ -97,11 +98,13 @@ namespace Prebuild.Core.Nodes private string m_StartupObject = ""; private string m_RootNamespace; private string m_FilterGroups = ""; + private string m_Version = ""; private Guid m_Guid; private Hashtable m_Configurations; private ArrayList m_ReferencePaths; private ArrayList m_References; + private ArrayList m_Authors; private FilesNode m_Files; #endregion @@ -116,6 +119,7 @@ namespace Prebuild.Core.Nodes m_Configurations = new Hashtable(); m_ReferencePaths = new ArrayList(); m_References = new ArrayList(); + m_Authors = new ArrayList(); } #endregion @@ -159,6 +163,18 @@ namespace Prebuild.Core.Nodes } /// + /// Gets the project's version + /// + /// The project's version. + public string Version + { + get + { + return m_Version; + } + } + + /// /// Gets the full path. /// /// The full path. @@ -194,6 +210,18 @@ namespace Prebuild.Core.Nodes } } + /// + /// Gets the app icon. + /// + /// The app icon. + public string ConfigFile + { + get + { + return m_ConfigFile; + } + } + /// /// /// @@ -290,9 +318,9 @@ namespace Prebuild.Core.Nodes { get { - ArrayList tmp = new ArrayList( ConfigurationsTable.Values); - tmp.Sort(); - return tmp; + ArrayList tmp = new ArrayList(ConfigurationsTable.Values); + tmp.Sort(); + return tmp; } } @@ -319,7 +347,7 @@ namespace Prebuild.Core.Nodes ArrayList tmp = new ArrayList(m_ReferencePaths); tmp.Sort(); return tmp; - } + } } /// @@ -335,6 +363,18 @@ namespace Prebuild.Core.Nodes return tmp; } } + + /// + /// Gets the Authors list. + /// + /// The list of the project's authors. + public ArrayList Authors + { + get + { + return m_Authors; + } + } /// /// Gets the files. @@ -422,7 +462,9 @@ namespace Prebuild.Core.Nodes m_Name = Helper.AttributeValue(node, "name", m_Name); m_Path = Helper.AttributeValue(node, "path", m_Path); m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); + m_Version = Helper.AttributeValue(node, "version", m_Version); m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); + m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile); m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); m_Language = Helper.AttributeValue(node, "language", m_Language); @@ -430,13 +472,11 @@ namespace Prebuild.Core.Nodes m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); - + m_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); - m_Guid = new Guid( hash, 0, 0, 0, 0, 0, 0,0,0,0,0 ); - - m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); - if(m_AssemblyName == null || m_AssemblyName.Length < 1) { m_AssemblyName = m_Name; @@ -482,6 +522,10 @@ namespace Prebuild.Core.Nodes { m_References.Add(dataNode); } + else if(dataNode is AuthorNode) + { + m_Authors.Add(dataNode); + } else if(dataNode is FilesNode) { m_Files = (FilesNode)dataNode; @@ -494,7 +538,6 @@ namespace Prebuild.Core.Nodes } } - #endregion #region IComparable Members @@ -506,5 +549,5 @@ namespace Prebuild.Core.Nodes } #endregion - } + } } diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs index 4b8262e..df0c2e4 100644 --- a/Prebuild/src/Core/Nodes/ReferenceNode.cs +++ b/Prebuild/src/Core/Nodes/ReferenceNode.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-07-25 18:56:49 +0200 (ti, 25 jul 2006) $ + * $Date: 2006-07-26 01:56:49 +0900 (Wed, 26 Jul 2006) $ * $Revision: 132 $ */ #endregion @@ -149,5 +149,5 @@ namespace Prebuild.Core.Nodes } #endregion - } + } } diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs index 4c981e7..d4042ef 100644 --- a/Prebuild/src/Core/Nodes/ReferencePathNode.cs +++ b/Prebuild/src/Core/Nodes/ReferencePathNode.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion @@ -104,5 +104,5 @@ namespace Prebuild.Core.Nodes } #endregion - } + } } diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs index 3ea53a4..9473fe6 100644 --- a/Prebuild/src/Core/Nodes/SolutionNode.cs +++ b/Prebuild/src/Core/Nodes/SolutionNode.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-02-28 17:15:42 +0100 (ti, 28 feb 2006) $ + * $Date: 2006-03-01 01:15:42 +0900 (Wed, 01 Mar 2006) $ * $Revision: 92 $ */ #endregion @@ -53,11 +53,11 @@ namespace Prebuild.Core.Nodes #region Fields private string m_Name = "unknown"; - private string m_Version = "1.0.0"; 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; @@ -111,18 +111,6 @@ namespace Prebuild.Core.Nodes } /// - /// Gets the version. - /// - /// The version. - public string Version - { - get - { - return m_Version; - } - } - - /// /// Gets the path. /// /// The path. @@ -147,6 +135,18 @@ namespace Prebuild.Core.Nodes } /// + /// Gets the version. + /// + /// The version. + public string Version + { + get + { + return m_Version; + } + } + + /// /// Gets the options. /// /// The options. @@ -181,7 +181,7 @@ namespace Prebuild.Core.Nodes ArrayList tmp = new ArrayList(ConfigurationsTable.Values); tmp.Sort(); return tmp; - } + } } /// @@ -245,9 +245,9 @@ namespace Prebuild.Core.Nodes public override void Parse(XmlNode node) { m_Name = Helper.AttributeValue(node, "name", m_Name); - m_Version = Helper.AttributeValue(node, "version", m_Version); m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); m_Path = Helper.AttributeValue(node, "path", m_Path); + m_Version = Helper.AttributeValue(node, "version", m_Version); m_FullPath = m_Path; try diff --git a/Prebuild/src/Core/Parse/IfContext.cs b/Prebuild/src/Core/Parse/IfContext.cs index 6311f47..fc86885 100644 --- a/Prebuild/src/Core/Parse/IfContext.cs +++ b/Prebuild/src/Core/Parse/IfContext.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Parse/Preprocessor.cs b/Prebuild/src/Core/Parse/Preprocessor.cs index af21090..eea5c30 100644 --- a/Prebuild/src/Core/Parse/Preprocessor.cs +++ b/Prebuild/src/Core/Parse/Preprocessor.cs @@ -27,8 +27,8 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O /* * $Source$ * $Author: jendave $ - * $Date: 2006-09-01 19:55:06 +0200 (fr, 01 sep 2006) $ - * $Revision: 147 $ + * $Date: 2007-04-26 17:10:27 +0900 (Thu, 26 Apr 2007) $ + * $Revision: 236 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs index cf575e3..f102038 100644 --- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs @@ -1,11 +1,11 @@ #region BSD License /* -Copyright (c) 2004 - 2006 +Copyright (c) 2004 - 2008 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), Dave Hudson (jendave@yahoo.com), -C.J. Adams-Collier (cjcollier@colliertech.org), +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 @@ -37,6 +37,35 @@ POSSIBILITY OF SUCH DAMAGE. */ #endregion +#region MIT X11 license + +/* + Portions of this file authored by Lluis Sanchez Gual + + Copyright (C) 2006 Novell, Inc (http://www.novell.com) + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + #region CVS Information /* * $Source$ @@ -53,6 +82,10 @@ using System.IO; using System.Reflection; using System.Text; using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Xsl; +using System.Net; +using System.Diagnostics; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; @@ -62,63 +95,500 @@ using Prebuild.Core.Utilities; namespace Prebuild.Core.Targets { - /// - /// - /// - [Target("autotools")] - public class AutotoolsTarget : 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, ReferenceNode refr) - { - string ret = ""; - if(solution.ProjectsTable.ContainsKey(refr.Name)) - { - ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; - string fileRef = FindFileReference(refr.Name, project); - string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/'); - ret += finalPath; - return ret; - } - else - { - 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 + "/" + refr.Name + ".dll", '/') : fileRef; - ret += Path.Combine(project.Path, finalPath); - return ret; - } - - try - { - //Assembly assem = Assembly.Load(refr.Name); + public enum ClrVersion + { + Default, + Net_1_1, + Net_2_0 + } + + public class SystemPackage + { + string name; + string version; + string description; + string[] assemblies; + bool isInternal; + ClrVersion targetVersion; + + public void Initialize(string name, + string version, + string description, + string[] assemblies, + ClrVersion targetVersion, + bool isInternal) + { + this.isInternal = isInternal; + this.name = name; + this.version = version; + this.assemblies = assemblies; + this.description = description; + this.targetVersion = targetVersion; + } + + public string Name + { + get { return name; } + } + + public string Version + { + get { return version; } + } + + public string Description + { + get { return description; } + } + + public ClrVersion TargetVersion + { + get { return targetVersion; } + } + + // The package is part of the mono SDK + public bool IsCorePackage + { + get { return name == "mono"; } + } + + // The package has been registered by an add-in, and is not installed + // in the system. + public bool IsInternalPackage + { + get { return isInternal; } + } + + public string[] Assemblies + { + get { return assemblies; } + } + + } + + + /// + /// + /// + [Target("autotools")] + public class AutotoolsTarget : ITarget + { + #region Fields + + Kernel m_Kernel; + XmlDocument autotoolsDoc; + XmlUrlResolver xr; + System.Security.Policy.Evidence e; + Hashtable assemblyPathToPackage = new Hashtable(); + Hashtable assemblyFullNameToPath = new Hashtable(); + Hashtable packagesHash = new Hashtable(); + ArrayList packages = new ArrayList(); + ClrVersion currentVersion; + + #endregion + + #region Private Methods + + private void mkdirDashP(string dirName) + { + DirectoryInfo di = new DirectoryInfo(dirName); + if (di.Exists) + return; + + string parentDirName = System.IO.Path.GetDirectoryName(dirName); + DirectoryInfo parentDi = new DirectoryInfo(parentDirName); + if (!parentDi.Exists) + mkdirDashP(parentDirName); + + 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 = + new System.IO.DirectoryInfo(dirName); + + if (!di.Exists) + di.Create(); + } + + private void transformToFile(string filename, XsltArgumentList argList, string nodeName) + { + // Create an XslTransform for this file + XslTransform templateTransformer = + new XslTransform(); + + // Load up the template + XmlNode templateNode = + autotoolsDoc.SelectSingleNode(nodeName + "/*"); + templateTransformer.Load(templateNode.CreateNavigator(), xr, e); + + // Create a writer for the transformed template + XmlTextWriter templateWriter = + new XmlTextWriter(filename, null); + + // Perform transformation, writing the file + templateTransformer.Transform + (m_Kernel.CurrentDoc, argList, templateWriter, xr); + } + + string NormalizeAsmName(string name) + { + int i = name.IndexOf(", PublicKeyToken=null"); + if (i != -1) + return name.Substring(0, i).Trim(); + else + return name; + } + + private void AddAssembly(string assemblyfile, SystemPackage package) + { + if (!File.Exists(assemblyfile)) + return; + + try + { + System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); + assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; + assemblyPathToPackage[assemblyfile] = package; + } + catch + { + } + } + + private ArrayList GetAssembliesWithLibInfo(string line, string file) + { + ArrayList references = new ArrayList(); + ArrayList libdirs = new ArrayList(); + ArrayList retval = new ArrayList(); + foreach (string piece in line.Split(' ')) + { + if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) + { + references.Add(ProcessPiece(piece.Substring(3).Trim(), file)); + } + else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:")) + { + libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file)); + } + } + + foreach (string refrnc in references) + { + foreach (string libdir in libdirs) + { + if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) + { + retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); + } + } + } + + return retval; + } + + private ArrayList GetAssembliesWithoutLibInfo(string line, string file) + { + ArrayList references = new ArrayList(); + foreach (string reference in line.Split(' ')) + { + if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) + { + string final_ref = reference.Substring(3).Trim(); + references.Add(ProcessPiece(final_ref, file)); + } + } + return references; + } + + private string ProcessPiece(string piece, string pcfile) + { + int start = piece.IndexOf("${"); + if (start == -1) + return piece; + + int end = piece.IndexOf("}"); + if (end == -1) + return piece; + + string variable = piece.Substring(start + 2, end - start - 2); + string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); + return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); + } + + private string GetVariableFromPkgConfig(string var, string pcfile) + { + ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); + psi.RedirectStandardOutput = true; + psi.UseShellExecute = false; + psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); + Process p = new Process(); + p.StartInfo = psi; + p.Start(); + string ret = p.StandardOutput.ReadToEnd().Trim(); + p.WaitForExit(); + if (String.IsNullOrEmpty(ret)) + return String.Empty; + return ret; + } + + private void ParsePCFile(string pcfile) + { + // Don't register the package twice + string pname = Path.GetFileNameWithoutExtension(pcfile); + if (packagesHash.Contains(pname)) + return; + + ArrayList fullassemblies = null; + string version = ""; + string desc = ""; + + SystemPackage package = new SystemPackage(); + + using (StreamReader reader = new StreamReader(pcfile)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + string lowerLine = line.ToLower(); + if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) + { + string choppedLine = line.Substring(5).Trim(); + if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1) + { + fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile); + } + else + { + fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile); + } + } + else if (lowerLine.StartsWith("version:")) + { + // "version:".Length == 8 + version = line.Substring(8).Trim(); + } + else if (lowerLine.StartsWith("description:")) + { + // "description:".Length == 12 + desc = line.Substring(12).Trim(); + } + } + } + + if (fullassemblies == null) + return; + + foreach (string assembly in fullassemblies) + { + AddAssembly(assembly, package); + } + + package.Initialize(pname, + version, + desc, + (string[])fullassemblies.ToArray(typeof(string)), + ClrVersion.Default, + false); + packages.Add(package); + packagesHash[pname] = package; + } + + void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) + { + SystemPackage package = new SystemPackage(); + ArrayList list = new ArrayList(); + + string dir = Path.Combine(prefix, version); + if (!Directory.Exists(dir)) + { + return; + } + + foreach (string assembly in Directory.GetFiles(dir, "*.dll")) + { + AddAssembly(assembly, package); + list.Add(assembly); + } + + package.Initialize("mono", + version, + "The Mono runtime", + (string[])list.ToArray(typeof(string)), + ver, + false); + packages.Add(package); + } + + void RunInitialization() + { + string versionDir; + + 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. + string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location); + + if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1) + prefix = Path.Combine(prefix, "mono"); + else + prefix = Path.GetDirectoryName(prefix); + + RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1); + RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0); + + string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); + string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); + + if (String.IsNullOrEmpty(libpath)) + { + string path_dirs = Environment.GetEnvironmentVariable("PATH"); + foreach (string pathdir in path_dirs.Split(Path.PathSeparator)) + { + if (pathdir == null) + continue; + if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config")) + { + libpath = Path.Combine(pathdir, ".."); + libpath = Path.Combine(libpath, "lib"); + libpath = Path.Combine(libpath, "pkgconfig"); + break; + } + } + } + search_dirs += Path.PathSeparator + libpath; + if (search_dirs != null && search_dirs.Length > 0) + { + ArrayList scanDirs = new ArrayList(); + foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) + { + if (!scanDirs.Contains(potentialDir)) + scanDirs.Add(potentialDir); + } + foreach (string pcdir in scanDirs) + { + if (pcdir == null) + continue; + + if (Directory.Exists(pcdir)) + { + foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) + { + ParsePCFile(pcfile); + } + } + } + } + } + + private void WriteCombine(SolutionNode solution) + { + #region "Create Solution directory if it doesn't exist" + string solutionDir = Path.Combine(solution.FullPath, + Path.Combine("autotools", + solution.Name)); + chkMkDir(solutionDir); + #endregion + + #region "Write Solution-level files" + XsltArgumentList argList = new XsltArgumentList(); + argList.AddParam("solutionName", "", solution.Name); + // $solutionDir is $rootDir/$solutionName/ + transformToFile(Path.Combine(solutionDir, "configure.ac"), + argList, "/Autotools/SolutionConfigureAc"); + transformToFile(Path.Combine(solutionDir, "Makefile.am"), + argList, "/Autotools/SolutionMakefileAm"); + transformToFile(Path.Combine(solutionDir, "autogen.sh"), + argList, "/Autotools/SolutionAutogenSh"); + #endregion + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + m_Kernel.Log.Write(String.Format("Writing project: {0}", + project.Name)); + WriteProject(solution, project); + } + } + 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, + ReferenceNode refr) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = + (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = + Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + + "/$(BUILD_DIR)/$(CONFIG)/", + refr.Name, "dll"), + '/'); + ret += finalPath; + return ret; + } + else + { + 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 + "/" + + refr.Name + ".dll", + '/') : + fileRef + ); + ret += Path.Combine(project.Path, finalPath); + return ret; + } + + try + { + //Assembly assem = Assembly.Load(refr.Name); //if (assem != null) //{ // int index = refr.Name.IndexOf(","); @@ -135,629 +605,971 @@ namespace Prebuild.Core.Targets //} //else //{ - int index = refr.Name.IndexOf(","); - if ( index > 0) - { - ret += refr.Name.Substring(0, index) + ".dll"; - //Console.WriteLine("Location3: " + assem.Location); - } - else - { - ret += (refr.Name + ".dll"); - //Console.WriteLine("Location4: " + assem.Location); - } - //} - } - catch (System.NullReferenceException e) - { - e.ToString(); - int index = refr.Name.IndexOf(","); - if ( index > 0) - { - ret += refr.Name.Substring(0, index) + ".dll"; - //Console.WriteLine("Location5: " + assem.Location); - } - else - { - ret += (refr.Name + ".dll"); - //Console.WriteLine("Location6: " + assem.Location); - } - } - } - return ret; - } - - 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(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); - ret += finalPath; - return ret; - } - else - { - 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 += ""; - } - } - return ret; - } - - private static string FindFileReference(string refName, ProjectNode project) - { - foreach(ReferencePathNode refPath in project.ReferencePaths) - { - string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); - - if(File.Exists(fullPath)) - { - return fullPath; - } - } - - 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; - } - - /// - /// Normalizes the path. - /// - /// The path. - /// - public static string NormalizePath(string path) - { - if(path == null) - { - return ""; - } - - StringBuilder tmpPath; - - if (Core.Parse.Preprocessor.GetOS() == "Win32") - { - tmpPath = new StringBuilder(path.Replace('\\', '/')); - tmpPath.Replace("/", @"\\"); - } - else - { - tmpPath = new StringBuilder(path.Replace('\\', '/')); - tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); - } - return tmpPath.ToString(); - } - - private void WriteProject(SolutionNode solution, ProjectNode project) - { - string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); - StreamWriter ss = new StreamWriter(projFile); - ss.NewLine = "\n"; - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); - - using(ss) - { - ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); - ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); - foreach(string file in project.Files) - { - if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) - { - ss.Write("\tresgen "); - ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); - if (project.Files.GetResourceName(file) != "") - { - ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); - } - else - { - ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); - } - } - } - ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); - ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); - if (project.References.Count > 0) - { - ss.Write("\t\t/reference:"); - bool firstref = true; - foreach(ReferenceNode refr in project.References) - { - if (firstref) - { - firstref = false; - } - else - { - ss.Write(","); - } - ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); - } - ss.WriteLine(" \\"); - } - //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); - - foreach(string file in project.Files) - { - switch(project.Files.GetBuildAction(file)) - { - case BuildAction.EmbeddedResource: - ss.Write("\t\t/resource:"); - ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); - break; - default: - if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) - { - ss.Write("\t\t/resource:"); - if (project.Files.GetResourceName(file) != "") - { - ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); - } - else - { - ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); - } - } - break; - } - } - - foreach(ConfigurationNode conf in project.Configurations) - { - if (conf.Options.KeyFile !="") - { - ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); - break; - } - } - foreach(ConfigurationNode conf in project.Configurations) - { - if (conf.Options.AllowUnsafe) - { - ss.WriteLine("\t\t/unsafe \\"); - break; - } - } - if (project.AppIcon != "") - { - ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); - } - - foreach(ConfigurationNode conf in project.Configurations) - { - ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); - break; - } - - foreach(ConfigurationNode conf in project.Configurations) - { - if (GetXmlDocFile(project, conf) !="") - { - ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); - break; - } - } - foreach(string file in project.Files) - { - switch(project.Files.GetBuildAction(file)) - { - case BuildAction.Compile: - ss.WriteLine("\t\t\\"); - ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); - break; - default: - break; - } - } - ss.WriteLine(); - ss.WriteLine(); - - if (project.Type == ProjectType.Library) - { - ss.WriteLine("install-data-local:"); - ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); - ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); - ss.WriteLine(); - ss.WriteLine("uninstall-local:"); - ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); - ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); - ss.WriteLine(); - } - ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml"); - ss.WriteLine("EXTRA_DIST = \\"); - ss.Write(" $(FILES)"); - foreach(ConfigurationNode conf in project.Configurations) - { - if (conf.Options.KeyFile != "") - { - ss.Write(" \\"); - ss.WriteLine("\t" + conf.Options.KeyFile); - } - break; - } - } - m_Kernel.CurrentWorkingDirectory.Pop(); - } - bool hasLibrary = false; - - private void WriteCombine(SolutionNode solution) - { - - /* TODO: These vars should be pulled from the prebuild.xml file */ - string releaseVersion = "2.0.0"; - string assemblyVersion = "2.1.0.0"; - string description = - "Tao Framework " + solution.Name + " Binding For .NET"; - - hasLibrary = false; - m_Kernel.Log.Write("Creating Autotools make files"); - foreach(ProjectNode project in solution.Projects) - { - if(m_Kernel.AllowProject(project.FilterGroups)) - { - m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); - WriteProject(solution, project); - } - } - - m_Kernel.Log.Write(""); - string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); - StreamWriter ss = new StreamWriter(combFile); - ss.NewLine = "\n"; - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); - - using(ss) - { - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - if (project.Type == ProjectType.Library) - { - hasLibrary = true; - break; - } - } - - if (hasLibrary) - { - ss.Write("pkgconfig_in_files = "); - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - if (project.Type == ProjectType.Library) - { - string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); - ss.Write(" " + project.Name + ".pc.in "); - StreamWriter sspc = new StreamWriter(combFilepc); - sspc.NewLine = "\n"; - using(sspc) - { - sspc.WriteLine("prefix=@prefix@"); - sspc.WriteLine("exec_prefix=${prefix}"); - sspc.WriteLine("libdir=${exec_prefix}/lib"); - sspc.WriteLine(); - sspc.WriteLine("Name: @PACKAGE_NAME@"); - sspc.WriteLine("Description: @DESCRIPTION@"); - sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); - sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); - } - } - } - - ss.WriteLine(); - ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); - ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); - } - ss.WriteLine(); - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); - ss.WriteLine("-include x {0}", - Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/')); - } - ss.WriteLine(); - ss.WriteLine("all: \\"); - ss.Write("\t"); - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); - ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); - - } - ss.WriteLine(); - if (hasLibrary) - { - ss.WriteLine("EXTRA_DIST = \\"); - ss.WriteLine("\t$(pkgconfig_in_files)"); - } - else - { - ss.WriteLine("EXTRA_DIST = "); - } - ss.WriteLine(); - ss.WriteLine("DISTCLEANFILES = \\"); - ss.WriteLine("\tconfigure \\"); - ss.WriteLine("\tMakefile.in \\"); - ss.WriteLine("\taclocal.m4"); - } - combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); - StreamWriter ts = new StreamWriter(combFile); - ts.NewLine = "\n"; - using(ts) - { - if (this.hasLibrary) - { - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - if (project.Type == ProjectType.Library) - { - ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); - break; - } - } - } - else - { - ts.WriteLine("AC_INIT(Makefile.am)"); - } - ts.WriteLine("AC_PREREQ(2.53)"); - ts.WriteLine("AC_CANONICAL_SYSTEM"); - - ts.WriteLine("PACKAGE_NAME={0}", solution.Name); - ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); - ts.WriteLine("DESCRIPTION=\"{0}\"", description); - ts.WriteLine("AC_SUBST(DESCRIPTION)"); - ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); - - ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); - ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); - - ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); - ts.WriteLine("AC_SUBST(PUBKEY)"); - - ts.WriteLine(); - ts.WriteLine("AM_MAINTAINER_MODE"); - ts.WriteLine(); - ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); - ts.WriteLine(); - ts.WriteLine("AC_PROG_INSTALL"); - ts.WriteLine(); - ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); - ts.WriteLine(); - ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); - ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); - ts.WriteLine(" from_cvs=yes"); - ts.WriteLine("else"); - ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); - ts.WriteLine(" from_cvs=yes"); - ts.WriteLine(" else"); - ts.WriteLine(" from_cvs=no"); - ts.WriteLine(" fi"); - ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("AC_MSG_RESULT($from_cvs)"); - ts.WriteLine(); - ts.WriteLine("AC_PATH_PROG(MONO, mono)"); - ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); - ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); - ts.WriteLine(); - ts.WriteLine("AC_MSG_CHECKING([for mono])"); - ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); - ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); - ts.WriteLine("dnl else"); - ts.WriteLine(" AC_MSG_RESULT([found])"); - ts.WriteLine("dnl fi"); - ts.WriteLine(); - ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); - ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); - ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); - ts.WriteLine("dnl else"); - ts.WriteLine(" AC_MSG_RESULT([found])"); - ts.WriteLine("dnl fi"); - ts.WriteLine(); + int index = refr.Name.IndexOf(","); + if (index > 0) + { + ret += refr.Name.Substring(0, index) + ".dll"; + //Console.WriteLine("Location3: " + assem.Location); + } + else + { + ret += (refr.Name + ".dll"); + //Console.WriteLine("Location4: " + assem.Location); + } + //} + } + catch (System.NullReferenceException e) + { + e.ToString(); + int index = refr.Name.IndexOf(","); + if (index > 0) + { + ret += refr.Name.Substring(0, index) + ".dll"; + //Console.WriteLine("Location5: " + assem.Location); + } + else + { + ret += (refr.Name + ".dll"); + //Console.WriteLine("Location6: " + assem.Location); + } + } + } + return ret; + } + + 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(Helper.MakeReferencePath(project.FullPath + + "/${build.dir}/"), + '/'); + ret += finalPath; + return ret; + } + else + { + 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 += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, + ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = + Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) { + return fullPath; + } + } + + 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; + } + + /// + /// Normalizes the path. + /// + /// The path. + /// + public static string NormalizePath(string path) + { + if (path == null) + { + return ""; + } + + StringBuilder tmpPath; + + if (Core.Parse.Preprocessor.GetOS() == "Win32") + { + tmpPath = new StringBuilder(path.Replace('\\', '/')); + tmpPath.Replace("/", @"\\"); + } + else + { + tmpPath = new StringBuilder(path.Replace('\\', '/')); + tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); + } + return tmpPath.ToString(); + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); + string projectDir = Path.Combine(solutionDir, project.Name); + string projectVersion = project.Version; + bool hasAssemblyConfig = false; + chkMkDir(projectDir); + + ArrayList + compiledFiles = new ArrayList(), + contentFiles = new ArrayList(), + embeddedFiles = new ArrayList(), + + binaryLibs = new ArrayList(), + pkgLibs = new ArrayList(), + systemLibs = new ArrayList(), + runtimeLibs = new ArrayList(), + + extraDistFiles = new ArrayList(), + localCopyTargets = new ArrayList(); + + // If there exists a .config file for this assembly, copy it to the project folder + // TODO: Support copying .config.osx files + // TODO: support processing the .config file for native library deps + string projectAssemblyName = project.Name; + if (project.AssemblyName != null) + projectAssemblyName = project.AssemblyName; + + if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) + { + hasAssemblyConfig = true; + System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); + extraDistFiles.Add(project.AssemblyName + ".dll.config"); + } + + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != string.Empty) + { + // Copy snk file into the project's directory + // Use the snk from the project directory directly + string source = Path.Combine(project.FullPath, conf.Options.KeyFile); + string keyFile = conf.Options.KeyFile; + Regex re = new Regex(".*/"); + keyFile = re.Replace(keyFile, ""); + + string dest = Path.Combine(projectDir, keyFile); + // Tell the user if there's a problem copying the file + try + { + mkdirDashP(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.IOException e) + { + Console.WriteLine(e.Message); + } + } + } + + // Copy compiled, embedded and content files into the project's directory + foreach (string filename in project.Files) + { + string source = Path.Combine(project.FullPath, filename); + string dest = Path.Combine(projectDir, filename); + + if (filename.Contains("AssemblyInfo.cs")) + { + // If we've got an AssemblyInfo.cs, pull the version number from it + string[] sources = { source }; + string[] args = { "" }; + Microsoft.CSharp.CSharpCodeProvider cscp = + new Microsoft.CSharp.CSharpCodeProvider(); + + string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); + System.CodeDom.Compiler.CompilerParameters cparam = + new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); + + System.CodeDom.Compiler.CompilerResults cr = + cscp.CompileAssemblyFromFile(cparam, sources); + + 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) + projectVersion = verMatch.Groups[1].Value; + + // Clean up the temp file + try + { + if (File.Exists(tempAssemblyFile)) + File.Delete(tempAssemblyFile); + } + catch + { + //Console.WriteLine("Error! '{0}'", e.ToString()); + } + + } + + // Tell the user if there's a problem copying the file + try + { + mkdirDashP(System.IO.Path.GetDirectoryName(dest)); + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.IOException e) + { + Console.WriteLine(e.Message); + } + + switch (project.Files.GetBuildAction(filename)) + { + case BuildAction.Compile: + compiledFiles.Add(filename); + break; + case BuildAction.Content: + contentFiles.Add(filename); + extraDistFiles.Add(filename); + break; + case BuildAction.EmbeddedResource: + embeddedFiles.Add(filename); + break; + } + } + + // Set up references + for (int refNum = 0; refNum < project.References.Count; refNum++) + { + ReferenceNode refr = (ReferenceNode)project.References[refNum]; + Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); + + /* Determine which pkg-config (.pc) file refers to + this assembly */ + + SystemPackage package = null; + + if (packagesHash.Contains(refr.Name)){ + package = (SystemPackage)packagesHash[refr.Name]; + + }else{ + string assemblyFullName = string.Empty; + if (refAssembly != null) + assemblyFullName = refAssembly.FullName; + + string assemblyFileName = string.Empty; + if (assemblyFullName != string.Empty && + assemblyFullNameToPath.Contains(assemblyFullName) + ) + assemblyFileName = + (string)assemblyFullNameToPath[assemblyFullName]; + + if (assemblyFileName != string.Empty && + assemblyPathToPackage.Contains(assemblyFileName) + ) + package = (SystemPackage)assemblyPathToPackage[assemblyFileName]; + + } + + /* If we know the .pc file and it is not "mono" + (already in the path), add a -pkg: argument */ + + if (package != null && + package.Name != "mono" && + !pkgLibs.Contains(package.Name) + ) + pkgLibs.Add(package.Name); + + string fileRef = + FindFileReference(refr.Name, (ProjectNode)refr.Parent); + + if (refr.LocalCopy || + solution.ProjectsTable.ContainsKey(refr.Name) || + fileRef != null || + refr.Path != null + ) + { + + /* Attempt to copy the referenced lib to the + project's directory */ + + string filename = refr.Name + ".dll"; + string source = filename; + if (refr.Path != null) + source = Path.Combine(refr.Path, source); + source = Path.Combine(project.FullPath, source); + string dest = Path.Combine(projectDir, filename); + + /* Since we depend on this binary dll to build, we + * will add a compile- time dependency on the + * copied dll, and add the dll to the list of + * files distributed with this package + */ + + binaryLibs.Add(refr.Name + ".dll"); + extraDistFiles.Add(refr.Name + ".dll"); + + // TODO: Support copying .config.osx files + // TODO: Support for determining native dependencies + if (File.Exists(source + ".config")) + { + System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); + extraDistFiles.Add(refr.Name + ".dll.config"); + } + + try + { + System.IO.File.Copy(source, dest, true); + } + catch (System.IO.IOException) + { + if (solution.ProjectsTable.ContainsKey(refr.Name)){ + + /* If an assembly is referenced, marked for + * local copy, in the list of projects for + * this solution, but does not exist, put a + * target into the Makefile.am to build the + * assembly and copy it to this project's + * directory + */ + + ProjectNode sourcePrj = + ((ProjectNode)(solution.ProjectsTable[refr.Name])); + + string target = + String.Format("{0}:\n" + + "\t$(MAKE) -C ../{1}\n" + + "\tln ../{2}/$@ $@\n", + filename, + sourcePrj.Name, + sourcePrj.Name ); + + localCopyTargets.Add(target); + } + } + } + else if( !pkgLibs.Contains(refr.Name) ) + { + // Else, let's assume it's in the GAC or the lib path + string assemName = string.Empty; + int index = refr.Name.IndexOf(","); + + if (index > 0) + assemName = refr.Name.Substring(0, index); + else + assemName = refr.Name; + + m_Kernel.Log.Write(String.Format( + "Warning: Couldn't find an appropriate assembly " + + "for reference:\n'{0}'", refr.Name + )); + systemLibs.Add(assemName); + } + } + + string lineSep = " \\\n\t"; + string compiledFilesString = string.Empty; + if (compiledFiles.Count > 0) + compiledFilesString = + lineSep + string.Join(lineSep, (string[])compiledFiles.ToArray(typeof(string))); + + string embeddedFilesString = ""; + if (embeddedFiles.Count > 0) + embeddedFilesString = + lineSep + string.Join(lineSep, (string[])embeddedFiles.ToArray(typeof(string))); + + string contentFilesString = ""; + if (contentFiles.Count > 0) + contentFilesString = + lineSep + string.Join(lineSep, (string[])contentFiles.ToArray(typeof(string))); + + string extraDistFilesString = ""; + if (extraDistFiles.Count > 0) + extraDistFilesString = + lineSep + string.Join(lineSep, (string[])extraDistFiles.ToArray(typeof(string))); + + string pkgLibsString = ""; + if (pkgLibs.Count > 0) + pkgLibsString = + lineSep + string.Join(lineSep, (string[])pkgLibs.ToArray(typeof(string))); + + string binaryLibsString = ""; + if (binaryLibs.Count > 0) + binaryLibsString = + lineSep + string.Join(lineSep, (string[])binaryLibs.ToArray(typeof(string))); + + string systemLibsString = ""; + if (systemLibs.Count > 0) + systemLibsString = + lineSep + string.Join(lineSep, (string[])systemLibs.ToArray(typeof(string))); + + string localCopyTargetsString = ""; + if (localCopyTargets.Count > 0) + localCopyTargetsString = + string.Join("\n", (string[])localCopyTargets.ToArray(typeof(string))); + + string monoPath = ""; + foreach (string runtimeLib in runtimeLibs) + { + monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; + } + + // Add the project name to the list of transformation + // parameters + XsltArgumentList argList = new XsltArgumentList(); + argList.AddParam("projectName", "", project.Name); + argList.AddParam("solutionName", "", solution.Name); + argList.AddParam("assemblyName", "", projectAssemblyName); + argList.AddParam("compiledFiles", "", compiledFilesString); + argList.AddParam("embeddedFiles", "", embeddedFilesString); + argList.AddParam("contentFiles", "", contentFilesString); + argList.AddParam("extraDistFiles", "", extraDistFilesString); + argList.AddParam("pkgLibs", "", pkgLibsString); + argList.AddParam("binaryLibs", "", binaryLibsString); + argList.AddParam("systemLibs", "", systemLibsString); + argList.AddParam("monoPath", "", monoPath); + argList.AddParam("localCopyTargets", "", localCopyTargetsString); + argList.AddParam("projectVersion", "", projectVersion); + argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); + + // Transform the templates + transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); + transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); + transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); + + if (project.Type == Core.Nodes.ProjectType.Library) + transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); + if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) + transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); + } + + private void WriteProjectOld(SolutionNode solution, ProjectNode project) + { + string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); + StreamWriter ss = new StreamWriter(projFile); + ss.NewLine = "\n"; + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using (ss) + { + ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); + ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); + foreach (string file in project.Files) + { + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.Write("\tresgen "); + ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); + if (project.Files.GetResourceName(file) != "") + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); + } + else + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); + } + } + } + ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); + ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); + if (project.References.Count > 0) + { + ss.Write("\t\t/reference:"); + bool firstref = true; + foreach (ReferenceNode refr in project.References) + { + if (firstref) + { + firstref = false; + } + else + { + ss.Write(","); + } + ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); + } + ss.WriteLine(" \\"); + } + //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); + + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.EmbeddedResource: + ss.Write("\t\t/resource:"); + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); + break; + default: + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ss.Write("\t\t/resource:"); + if (project.Files.GetResourceName(file) != "") + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); + } + else + { + ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); + } + } + break; + } + } + + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); + break; + } + } + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.AllowUnsafe) + { + ss.WriteLine("\t\t/unsafe \\"); + break; + } + } + if (project.AppIcon != "") + { + ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); + } + + foreach (ConfigurationNode conf in project.Configurations) + { + ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); + break; + } + + foreach (ConfigurationNode conf in project.Configurations) + { + if (GetXmlDocFile(project, conf) != "") + { + ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); + break; + } + } + foreach (string file in project.Files) + { + switch (project.Files.GetBuildAction(file)) + { + case BuildAction.Compile: + ss.WriteLine("\t\t\\"); + ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); + break; + default: + break; + } + } + ss.WriteLine(); + ss.WriteLine(); + + if (project.Type == ProjectType.Library) + { + ss.WriteLine("install-data-local:"); + ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); + ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); + ss.WriteLine(); + ss.WriteLine("uninstall-local:"); + ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); + ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); + ss.WriteLine(); + } + ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml"); + ss.WriteLine("EXTRA_DIST = \\"); + ss.Write(" $(FILES)"); + foreach (ConfigurationNode conf in project.Configurations) + { + if (conf.Options.KeyFile != "") + { + ss.Write(" \\"); + ss.WriteLine("\t" + conf.Options.KeyFile); + } + break; + } + } + m_Kernel.CurrentWorkingDirectory.Pop(); + } + bool hasLibrary = false; + + private void WriteCombineOld(SolutionNode solution) + { + + /* TODO: These vars should be pulled from the prebuild.xml file */ + string releaseVersion = "2.0.0"; + string assemblyVersion = "2.1.0.0"; + string description = + "Tao Framework " + solution.Name + " Binding For .NET"; + + hasLibrary = false; + m_Kernel.Log.Write("Creating Autotools make files"); + foreach (ProjectNode project in solution.Projects) + { + if (m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); + StreamWriter ss = new StreamWriter(combFile); + ss.NewLine = "\n"; + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + using (ss) + { + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + hasLibrary = true; + break; + } + } + + if (hasLibrary) + { + ss.Write("pkgconfig_in_files = "); + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); + ss.Write(" " + project.Name + ".pc.in "); + StreamWriter sspc = new StreamWriter(combFilepc); + sspc.NewLine = "\n"; + using (sspc) + { + sspc.WriteLine("prefix=@prefix@"); + sspc.WriteLine("exec_prefix=${prefix}"); + sspc.WriteLine("libdir=${exec_prefix}/lib"); + sspc.WriteLine(); + sspc.WriteLine("Name: @PACKAGE_NAME@"); + sspc.WriteLine("Description: @DESCRIPTION@"); + sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); + sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); + } + } + } + + ss.WriteLine(); + ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); + ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); + } + ss.WriteLine(); + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("-include x {0}", + Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"), '/')); + } + ss.WriteLine(); + ss.WriteLine("all: \\"); + ss.Write("\t"); + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); + + } + ss.WriteLine(); + if (hasLibrary) + { + ss.WriteLine("EXTRA_DIST = \\"); + ss.WriteLine("\t$(pkgconfig_in_files)"); + } + else + { + ss.WriteLine("EXTRA_DIST = "); + } + ss.WriteLine(); + ss.WriteLine("DISTCLEANFILES = \\"); + ss.WriteLine("\tconfigure \\"); + ss.WriteLine("\tMakefile.in \\"); + ss.WriteLine("\taclocal.m4"); + } + combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); + StreamWriter ts = new StreamWriter(combFile); + ts.NewLine = "\n"; + using (ts) + { + if (this.hasLibrary) + { + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); + break; + } + } + } + else + { + ts.WriteLine("AC_INIT(Makefile.am)"); + } + ts.WriteLine("AC_PREREQ(2.53)"); + ts.WriteLine("AC_CANONICAL_SYSTEM"); + + ts.WriteLine("PACKAGE_NAME={0}", solution.Name); + ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); + ts.WriteLine("DESCRIPTION=\"{0}\"", description); + ts.WriteLine("AC_SUBST(DESCRIPTION)"); + ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); + + ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); + ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); + + ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); + ts.WriteLine("AC_SUBST(PUBKEY)"); + + ts.WriteLine(); + ts.WriteLine("AM_MAINTAINER_MODE"); + ts.WriteLine(); + ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); + ts.WriteLine(); + ts.WriteLine("AC_PROG_INSTALL"); + ts.WriteLine(); + ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); + ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); + ts.WriteLine(" from_cvs=yes"); + ts.WriteLine("else"); + ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); + ts.WriteLine(" from_cvs=yes"); + ts.WriteLine(" else"); + ts.WriteLine(" from_cvs=no"); + ts.WriteLine(" fi"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_RESULT($from_cvs)"); + ts.WriteLine(); + ts.WriteLine("AC_PATH_PROG(MONO, mono)"); + ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); + ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([for mono])"); + ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); + ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); + ts.WriteLine("dnl else"); + ts.WriteLine(" AC_MSG_RESULT([found])"); + ts.WriteLine("dnl fi"); + ts.WriteLine(); + ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); + ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); + ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); + ts.WriteLine("dnl else"); + ts.WriteLine(" AC_MSG_RESULT([found])"); + ts.WriteLine("dnl fi"); + ts.WriteLine(); //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); //ts.WriteLine("else"); //ts.WriteLine(" AC_MSG_RESULT([found])"); //ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("AC_SUBST(PATH)"); - ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); - ts.WriteLine(); - ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); - ts.WriteLine("CSFLAGS=\"\""); - ts.WriteLine("AC_SUBST(CSFLAGS)"); - ts.WriteLine(); - // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); - // ts.WriteLine("AC_ARG_ENABLE(sdl,"); - // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); - // ts.WriteLine(" [disable_sdl=$disableval],"); - // ts.WriteLine(" [disable_sdl=\"no\"])"); - // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); - // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); - // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); - // ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("dnl Find pkg-config"); - ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); - ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); - ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); - ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); - ts.WriteLine("BUILD_DIR=\"bin\""); - ts.WriteLine("AC_SUBST(BUILD_DIR)"); - ts.WriteLine("CONFIG=\"Release\""); - ts.WriteLine("AC_SUBST(CONFIG)"); - ts.WriteLine(); - ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); - ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); - ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); - ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); - ts.WriteLine(" LIB_PREFIX="); - ts.WriteLine(" LIB_SUFFIX=.dylib"); - ts.WriteLine(" else"); - ts.WriteLine(" LIB_PREFIX=.so"); - ts.WriteLine(" LIB_SUFFIX="); - ts.WriteLine(" fi"); - ts.WriteLine("else"); - ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); - ts.WriteLine(" if test x$CSC = \"xno\"; then"); - ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); - ts.WriteLine(" else"); - ts.WriteLine(" RUNTIME="); - ts.WriteLine(" LIB_PREFIX="); - ts.WriteLine(" LIB_SUFFIX=.dylib"); - ts.WriteLine(" fi"); - ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("AC_SUBST(LIB_PREFIX)"); - ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); - ts.WriteLine(); - ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); - ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); - ts.WriteLine(); - ts.WriteLine("dnl Find monodoc"); - ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); - ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); - ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); - ts.WriteLine(); - ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); - ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); - ts.WriteLine(" if test x$MONODOC = xno; then"); - ts.WriteLine(" enable_monodoc=no"); - ts.WriteLine(" fi"); - ts.WriteLine("else"); - ts.WriteLine(" MONODOC="); - ts.WriteLine("fi"); - ts.WriteLine(); - ts.WriteLine("AC_SUBST(MONODOC)"); - ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); - ts.WriteLine(); - ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); - ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); - ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); - ts.WriteLine("fi"); - ts.WriteLine(); - // foreach(ProjectNode project in solution.ProjectsTableOrder) - // { - // if (project.Type == ProjectType.Library) - // { - // } - // } - ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); - ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); - ts.WriteLine(); - ts.WriteLine("winbuild=no"); - ts.WriteLine("case \"$host\" in"); - ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); - ts.WriteLine(" winbuild=yes"); - ts.WriteLine(" ;;"); - ts.WriteLine("esac"); - ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); - ts.WriteLine(); - // ts.WriteLine("dnl Check for SDL"); - // ts.WriteLine(); - // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); - // ts.WriteLine("have_sdl=no"); - // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); - // ts.WriteLine(" have_sdl=yes"); - // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); - // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); - // ts.WriteLine(" #"); - // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); - // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); - // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); - // ts.WriteLine(" # version of the library also exists in SDL's library installation"); - // ts.WriteLine(" # directory, typically /usr/lib."); - // ts.WriteLine(" #"); - // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); - // ts.WriteLine("fi"); - // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); - // ts.WriteLine("AC_SUBST([SDL_LIBS])"); - ts.WriteLine(); - ts.WriteLine("AC_OUTPUT(["); - ts.WriteLine("Makefile"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(PATH)"); + ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); + ts.WriteLine(); + ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); + ts.WriteLine("CSFLAGS=\"\""); + ts.WriteLine("AC_SUBST(CSFLAGS)"); + ts.WriteLine(); + // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); + // ts.WriteLine("AC_ARG_ENABLE(sdl,"); + // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); + // ts.WriteLine(" [disable_sdl=$disableval],"); + // ts.WriteLine(" [disable_sdl=\"no\"])"); + // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); + // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); + // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); + // ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("dnl Find pkg-config"); + ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); + ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); + ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); + ts.WriteLine("BUILD_DIR=\"bin\""); + ts.WriteLine("AC_SUBST(BUILD_DIR)"); + ts.WriteLine("CONFIG=\"Release\""); + ts.WriteLine("AC_SUBST(CONFIG)"); + ts.WriteLine(); + ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); + ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); + ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); + ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); + ts.WriteLine(" LIB_PREFIX="); + ts.WriteLine(" LIB_SUFFIX=.dylib"); + ts.WriteLine(" else"); + ts.WriteLine(" LIB_PREFIX=.so"); + ts.WriteLine(" LIB_SUFFIX="); + ts.WriteLine(" fi"); + ts.WriteLine("else"); + ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); + ts.WriteLine(" if test x$CSC = \"xno\"; then"); + ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); + ts.WriteLine(" else"); + ts.WriteLine(" RUNTIME="); + ts.WriteLine(" LIB_PREFIX="); + ts.WriteLine(" LIB_SUFFIX=.dylib"); + ts.WriteLine(" fi"); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(LIB_PREFIX)"); + ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); + ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); + ts.WriteLine(); + ts.WriteLine("dnl Find monodoc"); + ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); + ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); + ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); + ts.WriteLine(); + ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); + ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); + ts.WriteLine(" if test x$MONODOC = xno; then"); + ts.WriteLine(" enable_monodoc=no"); + ts.WriteLine(" fi"); + ts.WriteLine("else"); + ts.WriteLine(" MONODOC="); + ts.WriteLine("fi"); + ts.WriteLine(); + ts.WriteLine("AC_SUBST(MONODOC)"); + ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); + ts.WriteLine(); + ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); + ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); + ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); + ts.WriteLine("fi"); + ts.WriteLine(); + // foreach(ProjectNode project in solution.ProjectsTableOrder) + // { + // if (project.Type == ProjectType.Library) + // { + // } + // } + ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); + ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); + ts.WriteLine(); + ts.WriteLine("winbuild=no"); + ts.WriteLine("case \"$host\" in"); + ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); + ts.WriteLine(" winbuild=yes"); + ts.WriteLine(" ;;"); + ts.WriteLine("esac"); + ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); + ts.WriteLine(); + // ts.WriteLine("dnl Check for SDL"); + // ts.WriteLine(); + // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); + // ts.WriteLine("have_sdl=no"); + // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); + // ts.WriteLine(" have_sdl=yes"); + // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); + // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); + // ts.WriteLine(" #"); + // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); + // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); + // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); + // ts.WriteLine(" # version of the library also exists in SDL's library installation"); + // ts.WriteLine(" # directory, typically /usr/lib."); + // ts.WriteLine(" #"); + // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); + // ts.WriteLine("fi"); + // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); + // ts.WriteLine("AC_SUBST([SDL_LIBS])"); + ts.WriteLine(); + ts.WriteLine("AC_OUTPUT(["); + ts.WriteLine("Makefile"); // TODO: this does not work quite right. - //ts.WriteLine("Properties/AssemblyInfo.cs"); - foreach(ProjectNode project in solution.ProjectsTableOrder) - { - if (project.Type == ProjectType.Library) - { - ts.WriteLine(project.Name + ".pc"); - } - // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); - // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); - } - ts.WriteLine("])"); - ts.WriteLine(); - ts.WriteLine("#po/Makefile.in"); - ts.WriteLine(); - ts.WriteLine("echo \"---\""); - ts.WriteLine("echo \"Configuration summary\""); - ts.WriteLine("echo \"\""); - ts.WriteLine("echo \" * Installation prefix: $prefix\""); - ts.WriteLine("echo \" * compiler: $CSC\""); - ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); - ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); - ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); - ts.WriteLine("echo \" * Public Key: $PUBKEY\""); - ts.WriteLine("echo \"\""); - ts.WriteLine("echo \"---\""); - ts.WriteLine(); - } + //ts.WriteLine("Properties/AssemblyInfo.cs"); + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + if (project.Type == ProjectType.Library) + { + ts.WriteLine(project.Name + ".pc"); + } + // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); + } + ts.WriteLine("])"); + ts.WriteLine(); + ts.WriteLine("#po/Makefile.in"); + ts.WriteLine(); + ts.WriteLine("echo \"---\""); + ts.WriteLine("echo \"Configuration summary\""); + ts.WriteLine("echo \"\""); + ts.WriteLine("echo \" * Installation prefix: $prefix\""); + ts.WriteLine("echo \" * compiler: $CSC\""); + ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); + ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); + ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); + ts.WriteLine("echo \" * Public Key: $PUBKEY\""); + ts.WriteLine("echo \"\""); + ts.WriteLine("echo \"---\""); + ts.WriteLine(); + } ts.NewLine = "\n"; foreach (ProjectNode project in solution.ProjectsTableOrder) @@ -767,14 +1579,14 @@ namespace Prebuild.Core.Targets GenerateAssemblyInfoFile(solution, combFile); } } - } + } private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) { System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); StreamWriter ai = new StreamWriter(combFile); - + using (ai) { ai.WriteLine("#region License"); @@ -835,92 +1647,158 @@ namespace Prebuild.Core.Targets //return combFile; } - private void CleanProject(ProjectNode project) - { - m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); - string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); - Helper.DeleteIfExists(projectFile); - } - - private void CleanSolution(SolutionNode solution) - { - m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); - - string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); - Helper.DeleteIfExists(slnFile); - - slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); - Helper.DeleteIfExists(slnFile); - - slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); - Helper.DeleteIfExists(slnFile); - - slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); - Helper.DeleteIfExists(slnFile); - - slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); - Helper.DeleteIfExists(slnFile); - - foreach(ProjectNode project in solution.Projects) - { - CleanProject(project); - } - - m_Kernel.Log.Write(""); - } - - #endregion - - #region ITarget Members - - /// - /// Writes the specified kern. - /// - /// The kern. - public void Write(Kernel kern) - { - if( kern == null ) - { - throw new ArgumentNullException("kern"); - } - m_Kernel = kern; - foreach(SolutionNode solution in kern.Solutions) - { - WriteCombine(solution); - } - m_Kernel = null; - } - - /// - /// Cleans the specified kern. - /// - /// The kern. - public virtual void Clean(Kernel kern) - { - if( kern == null ) - { - throw new ArgumentNullException("kern"); - } - m_Kernel = kern; - foreach(SolutionNode sol in kern.Solutions) - { - CleanSolution(sol); - } - m_Kernel = null; - } - - /// - /// Gets the name. - /// - /// The name. - public string Name - { - get - { - return "autotools"; - } - } - - #endregion - } + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); + Helper.DeleteIfExists(slnFile); + + slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + m_Kernel.Log.Write("Parsing system pkg-config files"); + RunInitialization(); + + string streamName = "autotools.xml"; + string fqStreamName = String.Format("Prebuild.data.{0}", + streamName + ); + + // Retrieve stream for the autotools template XML + Stream autotoolsStream = Assembly.GetExecutingAssembly() + .GetManifestResourceStream(fqStreamName); + + if(autotoolsStream == null) { + + /* + * try without the default namespace prepended, in + * case prebuild.exe assembly was compiled with + * something other than Visual Studio .NET + */ + + autotoolsStream = Assembly.GetExecutingAssembly() + .GetManifestResourceStream(streamName); + if(autotoolsStream == null){ + string errStr = + String.Format("Could not find embedded resource file:\n" + + "'{0}' or '{1}'", + streamName, fqStreamName + ); + + m_Kernel.Log.Write(errStr); + + throw new System.Reflection.TargetException(errStr); + } + } + + // Create an XML URL Resolver with default credentials + xr = new System.Xml.XmlUrlResolver(); + xr.Credentials = CredentialCache.DefaultCredentials; + + // Create a default evidence - no need to limit access + e = new System.Security.Policy.Evidence(); + + // Load the autotools XML + autotoolsDoc = new XmlDocument(); + autotoolsDoc.Load(autotoolsStream); + + /* rootDir is the filesystem location where the Autotools + * build tree will be created - for now we'll make it + * $PWD/autotools + */ + + string pwd = Directory.GetCurrentDirectory(); + //string pwd = System.Environment.GetEnvironmentVariable("PWD"); + string rootDir = ""; + //if (pwd.Length != 0) + //{ + rootDir = Path.Combine(pwd, "autotools"); + //} + //else + //{ + // pwd = Assembly.GetExecutingAssembly() + //} + chkMkDir(rootDir); + + foreach (SolutionNode solution in kern.Solutions) + { + m_Kernel.Log.Write(String.Format("Writing solution: {0}", + solution.Name)); + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "autotools"; + } + } + + #endregion + } } diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs index dc4e666..db19e05 100644 --- a/Prebuild/src/Core/Targets/DebugTarget.cs +++ b/Prebuild/src/Core/Targets/DebugTarget.cs @@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O /* * $Source$ * $Author: jendave $ - * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ + * $Date: 2006-09-20 16:42:51 +0900 (Wed, 20 Sep 2006) $ * $Revision: 164 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/MakefileTarget.cs b/Prebuild/src/Core/Targets/MakefileTarget.cs new file mode 100644 index 0000000..86676d0 --- /dev/null +++ b/Prebuild/src/Core/Targets/MakefileTarget.cs @@ -0,0 +1,471 @@ +#region BSD License +/* +Copyright (c) 2004 Crestez Leonard (cleonard@go.ro) + +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.Specialized; +using System.IO; +using System.Text.RegularExpressions; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + [Target("makefile")] + public class MakefileTarget : ITarget + { + #region Fields + + private Kernel m_Kernel = null; + + #endregion + + #region Private Methods + + // This converts a path relative to the path of a project to + // a path relative to the solution path. + private string NicePath(ProjectNode proj, string path) + { + string res; + SolutionNode solution = (SolutionNode)proj.Parent; + res = Path.Combine(Helper.NormalizePath(proj.FullPath, '/'), Helper.NormalizePath(path, '/')); + res = Helper.NormalizePath(res, '/'); + res = res.Replace("/./", "/"); + while (res.IndexOf("/../") >= 0) + { + int a = res.IndexOf("/../"); + int b = res.LastIndexOf("/", a - 1); + res = res.Remove(b, a - b + 3); + } + res = Helper.MakePathRelativeTo(solution.FullPath, res); + if (res.StartsWith("./")) + res = res.Substring(2, res.Length - 2); + res = Helper.NormalizePath(res, '/'); + return res; + } + + private void WriteProjectFiles(StreamWriter f, SolutionNode solution, ProjectNode project) + { + // Write list of source code files + f.WriteLine("SOURCES_{0} = \\", project.Name); + foreach (string file in project.Files) + if (project.Files.GetBuildAction(file) == BuildAction.Compile) + f.WriteLine("\t{0} \\", NicePath(project, file)); + f.WriteLine(); + + // Write list of resource files + f.WriteLine("RESOURCES_{0} = \\", project.Name); + foreach (string file in project.Files) + if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource) + { + string path = NicePath(project, file); + f.WriteLine("\t-resource:{0},{1} \\", path, Path.GetFileName(path)); + } + f.WriteLine(); + + // There's also Content and None in BuildAction. + // What am I supposed to do with that? + } + + private string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = NicePath(project, Helper.MakeFilePath(refPath.Path, refName, "dll")); + if (File.Exists(fullPath)) + return fullPath; + } + return null; + } + + private void WriteProjectReferences(StreamWriter f, SolutionNode solution, ProjectNode project) + { + f.WriteLine("REFERENCES_{0} = \\", project.Name); + foreach (ReferenceNode refr in project.References) + { + string path; + // Project references change with configurations. + if (solution.ProjectsTable.Contains(refr.Name)) + continue; + path = FindFileReference(refr.Name, project); + if (path != null) + f.WriteLine("\t-r:{0} \\", path); + else + f.WriteLine("\t-r:{0} \\", refr.Name); + } + f.WriteLine(); + } + + private void WriteProjectDependencies(StreamWriter f, SolutionNode solution, ProjectNode project) + { + f.WriteLine("DEPENDENCIES_{0} = \\", project.Name); + f.WriteLine("\t$(SOURCES_{0}) \\", project.Name); + foreach (string file in project.Files) + if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource) + f.WriteLine("\t{0} \\", NicePath(project, file)); + f.WriteLine(); + } + + private string ProjectTypeToExtension(ProjectType t) + { + if (t == ProjectType.Exe || t == ProjectType.WinExe) + { + return "exe"; + } + else if (t == ProjectType.Library) + { + return "dll"; + } + else + { + throw new FatalException("Bad ProjectType: {0}", t); + } + } + + private string ProjectTypeToTarget(ProjectType t) + { + if (t == ProjectType.Exe) + { + return "exe"; + } + else if (t == ProjectType.WinExe) + { + return "winexe"; + } + else if (t == ProjectType.Library) + { + return "library"; + } + else + { + throw new FatalException("Bad ProjectType: {0}", t); + } + } + + private string ProjectOutput(ProjectNode project, ConfigurationNode config) + { + string filepath; + filepath = Helper.MakeFilePath((string)config.Options["OutputPath"], + project.AssemblyName, ProjectTypeToExtension(project.Type)); + return NicePath(project, filepath); + } + + // Returns true if two configs in one project have the same output. + private bool ProjectClashes(ProjectNode project) + { + foreach (ConfigurationNode conf1 in project.Configurations) + foreach (ConfigurationNode conf2 in project.Configurations) + if (ProjectOutput(project, conf1) == ProjectOutput(project, conf2) && conf1 != conf2) + { + m_Kernel.Log.Write("Warning: Configurations {0} and {1} for project {2} output the same file", + conf1.Name, conf2.Name, project.Name); + m_Kernel.Log.Write("Warning: I'm going to use some timestamps(extra empty files)."); + return true; + } + return false; + } + + private void WriteProject(StreamWriter f, SolutionNode solution, ProjectNode project) + { + f.WriteLine("# This is for project {0}", project.Name); + f.WriteLine(); + + WriteProjectFiles(f, solution, project); + WriteProjectReferences(f, solution, project); + WriteProjectDependencies(f, solution, project); + + bool clash = ProjectClashes(project); + + foreach (ConfigurationNode conf in project.Configurations) + { + string outpath = ProjectOutput(project, conf); + string filesToClean = outpath; + + if (clash) + { + f.WriteLine("{0}-{1}: .{0}-{1}-timestamp", project.Name, conf.Name); + f.WriteLine(); + f.Write(".{0}-{1}-timestamp: $(DEPENDENCIES_{0})", project.Name, conf.Name); + } + else + { + f.WriteLine("{0}-{1}: {2}", project.Name, conf.Name, outpath); + f.WriteLine(); + f.Write("{2}: $(DEPENDENCIES_{0})", project.Name, conf.Name, outpath); + } + // Dependencies on other projects. + foreach (ReferenceNode refr in project.References) + if (solution.ProjectsTable.Contains(refr.Name)) + { + ProjectNode refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; + if (ProjectClashes(refProj)) + f.Write(" .{0}-{1}-timestamp", refProj.Name, conf.Name); + else + f.Write(" {0}", ProjectOutput(refProj, conf)); + } + f.WriteLine(); + + // make directory for output. + if (Path.GetDirectoryName(outpath) != "") + { + f.WriteLine("\tmkdir -p {0}", Path.GetDirectoryName(outpath)); + } + // mcs command line. + f.Write("\tgmcs", project.Name); + f.Write(" -warn:{0}", conf.Options["WarningLevel"]); + if ((bool)conf.Options["DebugInformation"]) + f.Write(" -debug"); + if ((bool)conf.Options["AllowUnsafe"]) + f.Write(" -unsafe"); + if ((bool)conf.Options["CheckUnderflowOverflow"]) + f.Write(" -checked"); + if (project.StartupObject != "") + f.Write(" -main:{0}", project.StartupObject); + if ((string)conf.Options["CompilerDefines"] != "") + { + f.Write(" -define:\"{0}\"", conf.Options["CompilerDefines"]); + } + + f.Write(" -target:{0} -out:{1}", ProjectTypeToTarget(project.Type), outpath); + + // Build references to other projects. Now that sux. + // We have to reference the other project in the same conf. + foreach (ReferenceNode refr in project.References) + if (solution.ProjectsTable.Contains(refr.Name)) + { + ProjectNode refProj; + refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; + f.Write(" -r:{0}", ProjectOutput(refProj, conf)); + } + + f.Write(" $(REFERENCES_{0})", project.Name); + f.Write(" $(RESOURCES_{0})", project.Name); + f.Write(" $(SOURCES_{0})", project.Name); + f.WriteLine(); + + // Copy references with localcopy. + foreach (ReferenceNode refr in project.References) + if (refr.LocalCopy) + { + string outPath, srcPath, destPath; + outPath = Helper.NormalizePath((string)conf.Options["OutputPath"]); + if (solution.ProjectsTable.Contains(refr.Name)) + { + ProjectNode refProj; + refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; + srcPath = ProjectOutput(refProj, conf); + destPath = Path.Combine(outPath, Path.GetFileName(srcPath)); + destPath = NicePath(project, destPath); + if (srcPath != destPath) + { + f.WriteLine("\tcp -f {0} {1}", srcPath, destPath); + filesToClean += " " + destPath; + } + continue; + } + srcPath = FindFileReference(refr.Name, project); + if (srcPath != null) + { + destPath = Path.Combine(outPath, Path.GetFileName(srcPath)); + destPath = NicePath(project, destPath); + f.WriteLine("\tcp -f {0} {1}", srcPath, destPath); + filesToClean += " " + destPath; + } + } + + if (clash) + { + filesToClean += String.Format(" .{0}-{1}-timestamp", project.Name, conf.Name); + f.WriteLine("\ttouch .{0}-{1}-timestamp", project.Name, conf.Name); + f.Write("\trm -rf"); + foreach (ConfigurationNode otherConf in project.Configurations) + if (otherConf != conf) + f.WriteLine(" .{0}-{1}-timestamp", project.Name, otherConf.Name); + f.WriteLine(); + } + f.WriteLine(); + f.WriteLine("{0}-{1}-clean:", project.Name, conf.Name); + f.WriteLine("\trm -rf {0}", filesToClean); + f.WriteLine(); + } + } + + private void WriteIntro(StreamWriter f, SolutionNode solution) + { + f.WriteLine("# Makefile for {0} generated by Prebuild ( http://dnpb.sf.net )", solution.Name); + f.WriteLine("# Do not edit."); + f.WriteLine("#"); + + f.Write("# Configurations:"); + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}", conf.Name); + f.WriteLine(); + + f.WriteLine("# Projects:"); + foreach (ProjectNode proj in solution.Projects) + f.WriteLine("#\t{0}", proj.Name); + + f.WriteLine("#"); + f.WriteLine("# Building:"); + f.WriteLine("#\t\"make\" to build everything under the default(first) configuration"); + f.WriteLine("#\t\"make CONF\" to build every project under configuration CONF"); + f.WriteLine("#\t\"make PROJ\" to build project PROJ under the default(first) configuration"); + f.WriteLine("#\t\"make PROJ-CONF\" to build project PROJ under configuration CONF"); + f.WriteLine("#"); + f.WriteLine("# Cleaning (removing results of build):"); + f.WriteLine("#\t\"make clean\" to clean everything, that's what you probably want"); + f.WriteLine("#\t\"make CONF\" to clean everything for a configuration"); + f.WriteLine("#\t\"make PROJ\" to clean everything for a project"); + f.WriteLine("#\t\"make PROJ-CONF\" to clea project PROJ under configuration CONF"); + f.WriteLine(); + } + + private void WritePhony(StreamWriter f, SolutionNode solution) + { + string defconf = ""; + foreach (ConfigurationNode conf in solution.Configurations) + { + defconf = conf.Name; + break; + } + + f.Write(".PHONY: all"); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0} {0}-clean", proj.Name); + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0} {0}-clean", conf.Name); + foreach (ProjectNode proj in solution.Projects) + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}-{1} {0}-{1}-clean", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + + f.WriteLine("all: {0}", defconf); + f.WriteLine(); + + f.Write("clean:"); + foreach (ConfigurationNode conf in solution.Configurations) + f.Write(" {0}-clean", conf.Name); + f.WriteLine(); + f.WriteLine(); + + foreach (ConfigurationNode conf in solution.Configurations) + { + f.Write("{0}: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + + f.Write("{0}-clean: ", conf.Name); + foreach (ProjectNode proj in solution.Projects) + f.Write(" {0}-{1}-clean", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + } + + foreach (ProjectNode proj in solution.Projects) + { + f.WriteLine("{0}: {0}-{1}", proj.Name, defconf); + f.WriteLine(); + + f.Write("{0}-clean:", proj.Name); + foreach (ConfigurationNode conf in proj.Configurations) + f.Write(" {0}-{1}-clean", proj.Name, conf.Name); + f.WriteLine(); + f.WriteLine(); + } + } + + private void WriteSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Creating makefile for {0}", solution.Name); + m_Kernel.CurrentWorkingDirectory.Push(); + + string file = "Makefile";// Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); + StreamWriter f = new StreamWriter(file); + + Helper.SetCurrentDir(Path.GetDirectoryName(file)); + + using (f) + { + WriteIntro(f, solution); + WritePhony(f, solution); + + foreach (ProjectNode project in solution.Projects) + { + m_Kernel.Log.Write("...Creating Project: {0}", project.Name); + WriteProject(f, solution, project); + } + } + + m_Kernel.Log.Write(""); + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning makefile for {0}", solution.Name); + + string file = Helper.MakeFilePath(solution.FullPath, solution.Name, "make"); + Helper.DeleteIfExists(file); + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + public void Write(Kernel kern) + { + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + WriteSolution(solution); + m_Kernel = null; + } + + public virtual void Clean(Kernel kern) + { + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + CleanSolution(sol); + m_Kernel = null; + } + + public string Name + { + get + { + return "makefile"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index 7c0a1e2..af3341f 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $ - * $Revision: 206 $ + * $Author: cjcollier $ + * $Date: 2007-04-11 07:10:35 +0900 (Wed, 11 Apr 2007) $ + * $Revision: 231 $ */ #endregion @@ -106,9 +106,24 @@ namespace Prebuild.Core.Targets ret += " refto=\""; try { - //Assembly assem = Assembly.Load(refr.Name); - //ret += assem.FullName; - ret += refr.Name; + /* + Day changed to 28 Mar 2007 + ... + 08:09 < cj> is there anything that replaces Assembly.LoadFromPartialName() ? + 08:09 < jonp> no + 08:10 < jonp> in their infinite wisdom [sic], microsoft decided that the + ability to load any assembly version by-name was an inherently + bad idea + 08:11 < cj> I'm thinking of a bunch of four-letter words right now... + 08:11 < cj> security through making it difficult for the developer!!! + 08:12 < jonp> just use the Obsolete API + 08:12 < jonp> it should still work + 08:12 < cj> alrighty. + 08:12 < jonp> you just get warnings when using it + */ + Assembly assem = Assembly.LoadWithPartialName(refr.Name); + ret += assem.FullName; + //ret += refr.Name; } catch (System.NullReferenceException e) { diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs index 8a6dbdf..6ee6aef 100644 --- a/Prebuild/src/Core/Targets/NAntTarget.cs +++ b/Prebuild/src/Core/Targets/NAntTarget.cs @@ -1,34 +1,46 @@ #region BSD License /* - Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) - - Redistribution and use in source and binary forms, with or without modification, are permitted - provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions - and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions - and the following disclaimer in the documentation and/or other materials provided with the - distribution. - * The name of the author may not be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, - BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2004 - 2008 +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 +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. */ + #endregion #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ - * $Revision: 205 $ + * $Author: cjcollier $ + * $Date: 2008-02-07 10:22:36 +0900 (Thu, 07 Feb 2008) $ + * $Revision: 255 $ */ #endregion @@ -83,9 +95,7 @@ namespace Prebuild.Core.Targets if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; - string finalPath = Helper.NormalizePath(((ReferencePathNode)currentProject.ReferencePaths[0]).Path + refr.Name + GetProjectExtension(project), '/'); - return finalPath; } else @@ -122,7 +132,6 @@ namespace Prebuild.Core.Targets { ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); - return finalPath; } else @@ -213,7 +222,7 @@ namespace Prebuild.Core.Targets ss.WriteLine(" ", "build"); ss.WriteLine(" "); ss.WriteLine(" "); - ss.WriteLine(" "); + ss.WriteLine(" "); ss.WriteLine(" "); foreach (ReferenceNode refr in project.References) { @@ -222,8 +231,41 @@ namespace Prebuild.Core.Targets 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(" "); - ss.WriteLine(" "); + ss.WriteLine(" "); ss.WriteLine(" "); ss.WriteLine(" "); ss.WriteLine(" "); ss.WriteLine(); - // sdague - ok, this is an ugly hack, but what it lets // us do is native include of files into the nant // created files from all .nant/*include files. This diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs index 6b0552e..0d78796 100644 --- a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs @@ -53,7 +53,7 @@ namespace Prebuild.Core.Targets } #region Public Methods - + /// /// Gets the name. /// diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs index ededadb..6fe038b 100644 --- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.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: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ + * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $ * $Revision: 205 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs index b380f36..7067cf3 100644 --- a/Prebuild/src/Core/Targets/VS2002Target.cs +++ b/Prebuild/src/Core/Targets/VS2002Target.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs index c3ca930..4bf05cb 100644 --- a/Prebuild/src/Core/Targets/VS2003Target.cs +++ b/Prebuild/src/Core/Targets/VS2003Target.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-29 21:11:40 +0200 (fr, 29 sep 2006) $ + * $Date: 2006-09-30 04:11:40 +0900 (Sat, 30 Sep 2006) $ * $Revision: 177 $ */ #endregion diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs index bd56beb..4c17a3a 100644 --- a/Prebuild/src/Core/Targets/VS2005Target.cs +++ b/Prebuild/src/Core/Targets/VS2005Target.cs @@ -26,9 +26,9 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O #region CVS Information /* * $Source$ - * $Author: robloach $ - * $Date: 2007-02-27 19:52:34 +0100 (ti, 27 feb 2007) $ - * $Revision: 207 $ + * $Author: borrillis $ + * $Date: 2007-05-25 01:03:16 +0900 (Fri, 25 May 2007) $ + * $Revision: 243 $ */ #endregion @@ -36,6 +36,7 @@ using System; using System.Collections; using System.Collections.Specialized; using System.IO; +using System.Text; using Prebuild.Core.Attributes; using Prebuild.Core.Interfaces; @@ -235,7 +236,7 @@ namespace Prebuild.Core.Targets Hashtable tools; Kernel kernel; - + protected virtual string ToolsVersionXml { get @@ -249,7 +250,7 @@ namespace Prebuild.Core.Targets get { return "# Visual Studio 2005"; } } - /// + /// /// Gets or sets the solution version. /// /// The solution version. @@ -260,6 +261,7 @@ namespace Prebuild.Core.Targets return "9.00"; } } + /// /// Gets or sets the product version. /// @@ -287,6 +289,7 @@ namespace Prebuild.Core.Targets this.schemaVersion = value; } } + /// /// Gets or sets the name of the version. /// @@ -298,6 +301,7 @@ namespace Prebuild.Core.Targets return "Visual C# 2005"; } } + /// /// Gets or sets the version. /// @@ -377,7 +381,7 @@ namespace Prebuild.Core.Targets #region Project File using (ps) { - ps.WriteLine("", ToolsVersionXml ); + ps.WriteLine("", ToolsVersionXml); //ps.WriteLine(" <{0}", toolInfo.XMLTag); ps.WriteLine(" "); ps.WriteLine(" Local"); @@ -431,7 +435,7 @@ namespace Prebuild.Core.Targets ps.WriteLine(" "); ps.WriteLine(" "); ps.WriteLine(" {0}", conf.Options["CompilerDefines"]); - ps.WriteLine(" {0}", conf.Options["XmlDocFile"]); + ps.WriteLine(" {0}", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); ps.WriteLine(" {0}", conf.Options["DebugInformation"]); ps.WriteLine(" {0}", conf.Options["FileAlignment"]); // ps.WriteLine(" "); string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path; - + foreach (ReferenceNode refr in project.References) { if (!solution.ProjectsTable.ContainsKey(refr.Name)) @@ -471,7 +475,7 @@ namespace Prebuild.Core.Targets string path; - if( refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase )) + if (refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) { path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); } @@ -479,7 +483,7 @@ namespace Prebuild.Core.Targets { path = refr.Name + ".dll"; } - + // TODO: Allow reference to *.exe files ps.WriteLine(" {0}", path ); ps.WriteLine(" {0}", refr.LocalCopy); @@ -602,35 +606,53 @@ namespace Prebuild.Core.Targets { if (!list.Contains(file)) { - ps.Write(" <{0} ", project.Files.GetBuildAction(file)); - ps.WriteLine("Include=\"{0}\">", file); + ps.Write(" <{0} ", project.Files.GetBuildAction(file)); + int startPos = 0; + if ( project.Files.GetPreservePath( file ) ) + { + while ( ( @"./\" ).IndexOf( file.Substring( startPos, 1 ) ) != -1 ) + startPos++; - if (file.Contains("Designer.cs")) - { - ps.WriteLine(" {0}", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); - } + } + else + { + startPos = file.LastIndexOf( Path.GetFileName( file ) ); + } + ps.WriteLine("Include=\"{0}\">", Helper.NormalizePath(file)); - if (project.Files.GetIsLink(file)) - { - ps.WriteLine(" {0}", Path.GetFileName(file)); - } - 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) + + 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.GetCopyToOutput(file)); - } + ps.WriteLine(" {0}", project.Files.GetSubType(file)); + } + } - ps.WriteLine(" ", project.Files.GetBuildAction(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(" "); @@ -658,15 +680,14 @@ namespace Prebuild.Core.Targets ps.WriteLine(" "); //ps.WriteLine(" ", MakeRefPath(project)); - ps.WriteLine(" Debug"); - ps.WriteLine(" AnyCPU"); 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"); @@ -678,7 +699,7 @@ namespace Prebuild.Core.Targets ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); ps.WriteLine(" />"); } - + ps.WriteLine(""); } #endregion diff --git a/Prebuild/src/Core/Targets/XcodeTarget.cs b/Prebuild/src/Core/Targets/XcodeTarget.cs new file mode 100644 index 0000000..ee3b241 --- /dev/null +++ b/Prebuild/src/Core/Targets/XcodeTarget.cs @@ -0,0 +1,605 @@ +#region BSD License +/* +Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +#region CVS Information +/* + * $Source$ + * $Author: jendave $ + * $Date: 2007-02-13 12:58:03 -0800 (Tue, 13 Feb 2007) $ + * $Revision: 205 $ + */ +#endregion + +using System; +using System.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + /// + /// + /// + [Target("xcode")] + public class XcodeTarget : 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, ReferenceNode refr) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); + ret += finalPath; + return ret; + } + else + { + 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 + "/" + refr.Name + ".dll", '/') : fileRef; + ret += finalPath; + return ret; + } + + try + { + //Assembly assem = Assembly.Load(refr.Name); + //if (assem != null) + //{ + //ret += (refr.Name + ".dll"); + //} + //else + //{ + ret += (refr.Name + ".dll"); + //} + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name + ".dll"; + } + } + return ret; + } + + private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) + { + string ret = ""; + if (solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; + string fileRef = FindFileReference(refr.Name, project); + string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); + ret += finalPath; + return ret; + } + else + { + 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 += ""; + } + } + return ret; + } + + private static string FindFileReference(string refName, ProjectNode project) + { + foreach (ReferencePathNode refPath in project.ReferencePaths) + { + string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); + + if (File.Exists(fullPath)) + { + return fullPath; + } + } + + 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 + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "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(" "); + 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(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ReferenceNode refr in project.References) + { + 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 Xcode 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(""); + DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj")); + if (!directoryInfo.Exists) + { + directoryInfo.Create(); + } + string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj"); + 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(" "); + + foreach (ConfigurationNode conf in solution.Configurations) + { + // Set the project.config to a non-debug configuration + if (conf.Options["DebugInformation"].ToString().ToLower() != "true") + { + ss.WriteLine(" ", conf.Name); + } + 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(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + //foreach(ProjectNode project in solution.Projects) + //{ + // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + // ss.Write(" "); + //} + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + + foreach (ProjectNode project in solution.ProjectsTableOrder) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(" "); + ss.WriteLine(); + //ss.WriteLine(" "); + ss.WriteLine(" "); + ss.WriteLine(); + + ss.WriteLine(" "); + ss.WriteLine(" "); + foreach (ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.Write(" "); + } + ss.WriteLine(" "); + ss.WriteLine(); + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning Xcode build files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); + Helper.DeleteIfExists(slnFile); + + foreach (ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public void Write(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode solution in kern.Solutions) + { + WriteCombine(solution); + } + m_Kernel = null; + } + + /// + /// Cleans the specified kern. + /// + /// The kern. + public virtual void Clean(Kernel kern) + { + if (kern == null) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach (SolutionNode sol in kern.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get + { + return "xcode"; + } + } + + #endregion + } +} diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs index 62eb18b..5733547 100644 --- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs +++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs @@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O /* * $Source$ * $Author: robloach $ - * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ + * $Date: 2006-09-26 07:30:53 +0900 (Tue, 26 Sep 2006) $ * $Revision: 165 $ */ #endregion diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs index ff2d159..abbed52 100644 --- a/Prebuild/src/Core/Utilities/CurrentDirectory.cs +++ b/Prebuild/src/Core/Utilities/CurrentDirectory.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs index 27b9ccf..19093ce 100644 --- a/Prebuild/src/Core/Utilities/Helper.cs +++ b/Prebuild/src/Core/Utilities/Helper.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: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ + * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $ * $Revision: 205 $ */ #endregion diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs index 2f26557..e8105ac 100644 --- a/Prebuild/src/Core/Utilities/Log.cs +++ b/Prebuild/src/Core/Utilities/Log.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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ + * $Date: 2006-01-28 09:49:58 +0900 (Sat, 28 Jan 2006) $ * $Revision: 71 $ */ #endregion diff --git a/Prebuild/src/Core/WarningException.cs b/Prebuild/src/Core/WarningException.cs index ce685cd..df90dc8 100644 --- a/Prebuild/src/Core/WarningException.cs +++ b/Prebuild/src/Core/WarningException.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 01:49:58 +0100 (lö, 28 jan 2006) $ - * $Revision: 71 $ - */ -#endregion - using System; using System.Runtime.Serialization; diff --git a/Prebuild/src/Prebuild.cs b/Prebuild/src/Prebuild.cs index 2d12b53..922b4c9 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-26 23:43:35 +0200 (ti, 26 sep 2006) $ + * $Date: 2006-09-27 06:43:35 +0900 (Wed, 27 Sep 2006) $ * $Revision: 168 $ */ #endregion diff --git a/Prebuild/src/Properties/AssemblyInfo.cs b/Prebuild/src/Properties/AssemblyInfo.cs index 9f74500..e49aea5 100644 --- a/Prebuild/src/Properties/AssemblyInfo.cs +++ b/Prebuild/src/Properties/AssemblyInfo.cs @@ -1,34 +1,49 @@ #region BSD License /* -Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) -Redistribution and use in source and binary forms, with or without modification, are permitted -provided that the following conditions are met: +Copyright (c) 2004 - 2008 +Matthew Holmes (matthew@wildfiregames.com), +Dan Moorehead (dan05a@gmail.com), +Dave Hudson (jendave@yahoo.com), +Rob Loach (http://www.robloach.net), +C.J. Adams-Collier (cjac@colliertech.org), -* 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: + +* 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. -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #endregion #region CVS Information /* * $Source$ - * $Author: jendave $ - * $Date: 2007-01-26 19:31:34 +0100 (fr, 26 jan 2007) $ - * $Revision: 203 $ + * $Author: cjcollier $ + * $Date: 2008-02-08 01:31:29 +0900 (Fri, 08 Feb 2008) $ + * $Revision: 256 $ */ #endregion @@ -55,11 +70,16 @@ using System.Resources; [assembly: AssemblyConfiguration(".NET CLR")] [assembly: AssemblyCompany("The Prebuild Project")] [assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Copyright 2004-2006 Matthew Holmes, Dan Moorehead and David Hudson")] +[assembly: AssemblyCopyright("Copyright 2004-2008 " + + "Matthew Holmes, " + + "Dan Moorehead, " + + "C.J. Adams-Collier, " + + "Rob Loach, " + + "David Hudson,")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguageAttribute("en-US")] -[assembly: AssemblyVersion("2.0.0.*")] +[assembly: AssemblyVersion("2.0.3.*")] // // Version information for an assembly consists of the following four values: diff --git a/Prebuild/src/data/autotools.xml b/Prebuild/src/data/autotools.xml new file mode 100644 index 0000000..ee4b064 --- /dev/null +++ b/Prebuild/src/data/autotools.xml @@ -0,0 +1,790 @@ + + + + + #!/bin/sh +# Run this to generate all the initial makefiles, etc. +# Ripped off from Mono, which ripped off from GNOME macros version + +DIE=0 + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +if [ -n "$MONO_PATH" ]; then + # from -> /mono/lib:/another/mono/lib + # to -> /mono /another/mono + for i in `echo ${MONO_PATH} | tr ":" " "`; do + i=`dirname ${i}` + if [ -n "{i}" -a -d "${i}/share/aclocal" ]; then + ACLOCAL_FLAGS="-I ${i}/share/aclocal $ACLOCAL_FLAGS" + fi + if [ -n "{i}" -a -d "${i}/bin" ]; then + PATH="${i}/bin:$PATH" + fi + done + export PATH +fi + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`autoconf' installed to compile Mono." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +if [ -z "$LIBTOOL" ]; then + LIBTOOL=`which glibtool 2>/dev/null` + if [ ! -x "$LIBTOOL" ]; then + LIBTOOL=`which libtool` + fi +fi + +(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && { + ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`libtool' installed to compile Mono." + echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && { + grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \ + (gettext --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`gettext' installed to compile Mono." + echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`automake' installed to compile Mono." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + NO_AUTOMAKE=yes +} + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing \`aclocal'. The version of \`automake'" + echo "installed doesn't appear recent enough." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$NOCONFIGURE"; then + +if test -z "$*"; then + echo "**Warning**: I am going to run \`configure' with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo \`$0\'" command line." + echo +fi + +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + + +if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then + if test -z "$NO_LIBTOOLIZE" ; then + echo "Running libtoolize..." + ${LIBTOOL}ize --force --copy + fi +fi + +echo "Running aclocal $ACLOCAL_FLAGS ..." +aclocal $ACLOCAL_FLAGS || { + echo + echo "**Error**: aclocal failed. This may mean that you have not" + echo "installed all of the packages you need, or you may need to" + echo "set ACLOCAL_FLAGS to include \"-I \$prefix/share/aclocal\"" + echo "for the prefix where you installed the packages whose" + echo "macros were not found" + exit 1 +} + +if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then + echo "Running autoheader..." + autoheader || { echo "**Error**: autoheader failed."; exit 1; } +fi + +echo "Running automake --gnu $am_opt ..." +automake --add-missing --gnu $am_opt || + { echo "**Error**: automake failed."; exit 1; } +echo "Running autoconf ..." +autoconf || { echo "**Error**: autoconf failed."; exit 1; } + +conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c + +if test x$NOCONFIGURE = x; then + echo Running $srcdir/configure $conf_flags "$@" ... + $srcdir/configure $conf_flags "$@" \ + && echo Now type \`make\' to compile $PKG_NAME || exit 1 +else + echo Skipping configure process. +fi + + + + + + + + + + + + + + + + AC_INIT([],[]) + +AC_PREREQ(2.60) +AC_CANONICAL_SYSTEM +AC_CONFIG_AUX_DIR(.) +AM_INIT_AUTOMAKE([1.9 tar-ustar foreign]) +AM_MAINTAINER_MODE +dnl AC_PROG_INTLTOOL([0.25]) +AC_PROG_INSTALL + +ASSEMBLY_NAME= +PROJECT_NAME= +PROJECT_VERSION=$VERSION +PROJECT_DESCRIPTION="" +PROJECT_TYPE="" + +AC_SUBST(ASSEMBLY_NAME) +AC_SUBST(PROJECT_NAME) +AC_SUBST(PROJECT_VERSION) +AC_SUBST(DESCRIPTION) + +AC_MSG_CHECKING([assembly type]) +case $PROJECT_TYPE in + *Exe) + ASSEMBLY_EXTENSION=exe + ;; + *Library) + ASSEMBLY_EXTENSION=dll + ;; + *) + AC_MSG_ERROR([*** Please add support for project type $PROJECT_TYPE to configure.ac checks!]) + ;; +esac +AC_MSG_RESULT([$PROJECT_TYPE]) + +AC_SUBST(ASSEMBLY_EXTENSION) + +AC_MSG_CHECKING([whether we're compiling from an RCS]) +if test -f "$srcdir/.cvs_version" ; then + from_rcs=cvs +else + if test -f "$srcdir/.svn/entries" ; then + from_rcs=svn + else + from_rcs=no + fi +fi + +AC_MSG_RESULT($from_rcs) + +MONO_REQUIRED_VERSION=1.1 + +PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false) + +if test "x$has_mono" = "xtrue"; then + AC_PATH_PROG(RUNTIME, mono, no) + AC_PATH_PROG(CSC, gmcs, no) + AC_PATH_PROG(RESGEN, resgen2, no) + if test `uname -s` = "Darwin"; then + LIB_PREFIX= + LIB_SUFFIX=.dylib + else + LIB_PREFIX=.so + LIB_SUFFIX= + fi +else + AC_PATH_PROG(CSC, csc.exe, no) + if test x$CSC = "xno"; then + AC_MSG_ERROR([You need to install either mono or .Net]) + else + RUNTIME= + LIB_PREFIX= + LIB_SUFFIX= + fi +fi + +AC_PATH_PROG(GACUTIL, gacutil) +if test "x$GACUTIL" = "xno" ; then + AC_MSG_ERROR([No gacutil tool found]) +fi + +GACUTIL_FLAGS='/package /gacdir $(DESTDIR)$(prefix)/lib' +AC_SUBST(GACUTIL_FLAGS) + +AC_SUBST(PATH) +AC_SUBST(LD_LIBRARY_PATH) + +AC_SUBST(LIB_PREFIX) +AC_SUBST(LIB_SUFFIX) +AC_SUBST(RUNTIME) +AC_SUBST(CSC) +AC_SUBST(RESGEN) +AC_SUBST(GACUTIL) + +AC_SUBST(BASE_DEPENDENCIES_CFLAGS) +AC_SUBST(BASE_DEPENDENCIES_LIBS) + +dnl Find monodoc +MONODOC_REQUIRED_VERSION=1.0 +AC_SUBST(MONODOC_REQUIRED_VERSION) + +PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no) + +if test "x$enable_monodoc" = "xyes"; then + AC_PATH_PROG(MONODOC, monodoc, no) + if test x$MONODOC = xno; then + enable_monodoc=no + fi +else + MONODOC= +fi + +AC_SUBST(MONODOC) +AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes") + +winbuild=no +case "$host" in + *-*-mingw*|*-*-cygwin*) + winbuild=yes + ;; +esac +AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes) + +AC_CONFIG_FILES() +AC_CONFIG_FILES(.pc) + +AC_CONFIG_FILES(Makefile) +AC_OUTPUT + +echo "===" +echo "" +echo "Project configuration summary" +echo "" +echo " * Installation prefix: $prefix" +echo " * compiler: $CSC" +echo " * Documentation: $enable_monodoc ($MONODOC)" +echo " * Project Name: $PROJECT_NAME" +echo " * Version: $PROJECT_VERSION" +echo "" +echo "===" + + + + + + + + + + + + + + + + + + + + + + + + + + +ASSEMBLY=$(ASSEMBLY_NAME).$(ASSEMBLY_EXTENSION) + + +dir = $(prefix)/lib/ +_DATA = $(ASSEMBLY) $(ASSEMBLY).config + +bin_SCRIPTS= + +pkgconfigdir = $(prefix)/lib/pkgconfig +pkgconfig_DATA = .pc + +dir = $(prefix)/lib/mono/ +_DATA = $(ASSEMBLY).config + +noinst_DATA = $(ASSEMBLY) + + +PACKAGES = +BINARY_LIBS = +SYSTEM_LIBS = +RESOURCES_SRC = +RESOURCES = $(RESOURCES_SRC:.resx=.resources) +SOURCES = + +EXTRA_DIST=$(SOURCES) $(BINARY_LIBS) $(RESOURCES_SRC) install-sh missing + +CLEANFILES=$(ASSEMBLY) + + + + + + + +/$(ASSEMBLY): $(srcdir)/$(ASSEMBLY).response $(RESOURCES) $(SOURCES) $(BINARY_LIBS) + mkdir -p doc && mkdir -p && $(CSC) /out:$@ \ + /target: \ + $(addprefix /resource:$(srcdir)/, $(RESOURCES)) \ + $(addprefix /pkg:, $(PACKAGES)) \ + $(addprefix /r:, $(SYSTEM_LIBS)) \ + $(addprefix /r:$(srcdir)/, $(BINARY_LIBS)) \ + @$(srcdir)/$(ASSEMBLY).response \ + /doc:doc/ \ + /keyfile:$(srcdir)/ \ + /unsafe \ + && rm -f $(ASSEMBLY) \ + && ln $@ $(ASSEMBLY) + +CLEANFILES+=/$(ASSEMBLY) + + +EXTRA_DIST+= + +: /$(ASSEMBLY) + rm -f $(ASSEMBLY) \ + && ln /$(ASSEMBLY) $(ASSEMBLY) + + + + + +_install-data-local: /$(ASSEMBLY) + echo "$(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS)"; \ + $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; + +_uninstall-local: + if [`gacutil -l | grep "Number" | awk -F= '{print $$2}'` -gt "0" ] ; \ + then \ + echo "$(GACUTIL) /u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS)"; \ + $(GACUTIL) /u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS) || exit 1; \ + fi + + + +noinst__dir = $(prefix)/lib/mono/ +noinst___DATA = /$(ASSEMBLY) + + + + + + +$(ASSEMBLY): + + +$(srcdir)/$(ASSEMBLY).response: $(srcdir)/Makefile + echo "$(addprefix $(srcdir)/, $(SOURCES))" > $@ + + +all: $(ASSEMBLY) + +# rule to compile .resx files to .resources +%.resources: %.resx + $(RESGEN) /useSourcePath /compile $(@:.resources=.resx) + + + + + +install-data-local: _install-data-local + +uninstall-local: _uninstall-local + + + +#dir+=$(noinst__dir) +#_DATA+=$(noinst___DATA) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +prefix=@prefix@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib/mono/@PROJECT_NAME@ + +Name: +Description: +Version: @PROJECT_VERSION@ +Requires: +Libs: -r:${libdir}/@PROJECT_NAME@.dll + + + + + + + + + + + #!/bin/sh +# Run this to generate all the initial makefiles, etc. +# Ripped off from Mono, which ripped off from GNOME macros version + +DIE=0 + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +if [ -n "$MONO_PATH" ]; then + # from -> /mono/lib:/another/mono/lib + # to -> /mono /another/mono + for i in `echo ${MONO_PATH} | tr ":" " "`; do + i=`dirname ${i}` + if [ -n "{i}" -a -d "${i}/share/aclocal" ]; then + ACLOCAL_FLAGS="-I ${i}/share/aclocal $ACLOCAL_FLAGS" + fi + if [ -n "{i}" -a -d "${i}/bin" ]; then + PATH="${i}/bin:$PATH" + fi + done + export PATH +fi + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`autoconf' installed to compile Mono." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +if [ -z "$LIBTOOL" ]; then + LIBTOOL=`which glibtool 2>/dev/null` + if [ ! -x "$LIBTOOL" ]; then + LIBTOOL=`which libtool` + fi +fi + +(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && { + ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`libtool' installed to compile Mono." + echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && { + grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \ + (gettext --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`gettext' installed to compile Mono." + echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`automake' installed to compile Mono." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 + NO_AUTOMAKE=yes +} + + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing \`aclocal'. The version of \`automake'" + echo "installed doesn't appear recent enough." + echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" + echo "(or a newer version if it is available)" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "**Warning**: I am going to run \`configure' with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo \`$0\'" command line." + echo +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + + +if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then + if test -z "$NO_LIBTOOLIZE" ; then + echo "Running libtoolize..." + ${LIBTOOL}ize --force --copy + fi +fi + +echo "Running aclocal $ACLOCAL_FLAGS ..." +aclocal $ACLOCAL_FLAGS || { + echo + echo "**Error**: aclocal failed. This may mean that you have not" + echo "installed all of the packages you need, or you may need to" + echo "set ACLOCAL_FLAGS to include \"-I \$prefix/share/aclocal\"" + echo "for the prefix where you installed the packages whose" + echo "macros were not found" + exit 1 +} + +if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then + echo "Running autoheader..." + autoheader || { echo "**Error**: autoheader failed."; exit 1; } +fi + +echo "Running automake --gnu $am_opt ..." +automake --add-missing --gnu $am_opt || + { echo "**Error**: automake failed."; exit 1; } +echo "Running autoconf ..." +autoconf || { echo "**Error**: autoconf failed."; exit 1; } + + +echo Running /autogen.sh ... +(cd $srcdir/ ; NOCONFIGURE=1 /bin/sh ./autogen.sh "$@") +echo Done running /autogen.sh ... + + +conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c + +if test x$NOCONFIGURE = x; then + echo Running $srcdir/configure $conf_flags "$@" ... + $srcdir/configure $conf_flags "$@" \ + && echo Now type \`make\' to compile $PKG_NAME || exit 1 +else + echo Skipping configure process. +fi + + + + + + + + + + +AC_INIT([]-solution,[]) +AC_CONFIG_AUX_DIR(.) +AM_INIT_AUTOMAKE([1.9 tar-ustar foreign]) +EXTRA_DIST="install-sh missing" +SOLUTION_NAME= +SOLUTION_VERSION=$VERSION +SOLUTION_DESCRIPTION="" +AC_SUBST(DESCRIPTION) + +AM_MAINTAINER_MODE + +dnl AC_PROG_INTLTOOL([0.25]) + +AC_PROG_INSTALL + +AC_MSG_CHECKING([whether we're building from an RCS]) +if test -f "$srcdir/.cvs_version" ; then + from_rcs=cvs +else + if test -f "$srcdir/.svn/entries" ; then + from_rcs=svn + else + from_rcs=no + fi +fi + +AC_MSG_RESULT($from_rcs) + +CONFIG="Release" +AC_SUBST(CONFIG) + +AC_CONFIG_SUBDIRS( +) + + +AC_OUTPUT([ +Makefile +]) + +echo "===" +echo "" +echo "Solution configuration summary" +echo "" +echo " * Solution Name: $SOLUTION_NAME" +echo " * Version: $SOLUTION_VERSION" +echo " * Packages:" +echo " - " +echo "" +echo "===" + + + + + + + + + SUBDIRS = + + + + + + + + + + + + +#! /bin/sh + +PACKAGE= +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# %%$@%$# why oh why isn't it $sharedir/ +# Day changed to 30 Mar 2007 +# ... +# 07:50 < cj> why are we installing .exe assemblies to $prefix/lib/$package/ and +# not $prefix/share/$package ? +# 07:50 < jonp> momentum. +# 07:50 < jonp> and it's hard to say that a .exe isn't platform specific +# 07:50 < jonp> as it can still contain DllImport's which make platform +# assumptions + +packagedir=$prefix/lib/ +export MONO_PATH=$MONO_PATH + +exec @RUNTIME@ $packagedir/$PACKAGE.exe "$@" + + + + + diff --git a/Prebuild/src/data/prebuild-1.7.xsd b/Prebuild/src/data/prebuild-1.7.xsd index 381b9f0..3c108f3 100644 --- a/Prebuild/src/data/prebuild-1.7.xsd +++ b/Prebuild/src/data/prebuild-1.7.xsd @@ -1,14 +1,17 @@ - - - - - Copyright (c) 2004-2005 Matthew Holmes (calefaction at houston . rr . com), Dan Moorehead (dan05a at gmail . com), David Hudson (jendave at yahoo 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 and - 2003, SharpDevelop, MonoDevelop, and NAnt. + IDE's and .NET development tools including: Visual Studio .NET 2002, + 2003, and 2005, SharpDevelop, MonoDevelop, NAnt, Xcode and the GNU Autotools. BSD License: @@ -31,231 +34,240 @@ 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1