From 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Jul 2007 15:40:11 +0000 Subject: changed to native line ending encoding --- Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 916 ++++++++++++------------- 1 file changed, 458 insertions(+), 458 deletions(-) (limited to 'Prebuild/src/Core/Targets/MonoDevelopTarget.cs') diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index 8620e4b..7c0a1e2 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs @@ -1,458 +1,458 @@ -#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 22:07:07 +0100 (ti, 13 feb 2007) $ - * $Revision: 206 $ - */ -#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("monodev")] - public class MonoDevelopTarget : 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 = ""; - } - else - { - ProjectNode project = (ProjectNode)refr.Parent; - string fileRef = FindFileReference(refr.Name, project); - - if(refr.Path != null || fileRef != null) - { - ret += "Assembly\" refto=\""; - - string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; - - ret += finalPath; - ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; - return ret; - } - - ret += "Gac\""; - ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; - ret += " refto=\""; - try - { - //Assembly assem = Assembly.Load(refr.Name); - //ret += assem.FullName; - ret += refr.Name; - } - catch (System.NullReferenceException e) - { - e.ToString(); - ret += refr.Name; - } - 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 GenerateXmlDocFile(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 "False"; - } - return "True"; - } - - private void WriteProject(SolutionNode solution, ProjectNode project) - { - string csComp = "Mcs"; - string netRuntime = "Mono"; - if(project.Runtime == ClrRuntime.Microsoft) - { - csComp = "Csc"; - netRuntime = "MsNet"; - } - - string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); - StreamWriter ss = new StreamWriter(projFile); - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); - - using(ss) - { - ss.WriteLine( - "", - project.Name, - project.RootNamespace - ); - - int count = 0; - - ss.WriteLine(" ", solution.ActiveConfig); - - foreach(ConfigurationNode conf in project.Configurations) - { - ss.WriteLine(" ", conf.Name); - ss.Write(" "); - - ss.Write(" "); - - ss.Write(" "); - - ss.Write(" "); - ss.WriteLine(" "); - - count++; - } - ss.WriteLine(" "); - - ss.Write(" "); - ss.WriteLine(" "); - ss.WriteLine(" "); - - ss.WriteLine(" "); - foreach(string file in project.Files) - { - string buildAction = "Compile"; - switch(project.Files.GetBuildAction(file)) - { - case BuildAction.None: - buildAction = "Nothing"; - break; - - case BuildAction.Content: - buildAction = "Exclude"; - break; - - case BuildAction.EmbeddedResource: - buildAction = "EmbedAsResource"; - break; - - default: - buildAction = "Compile"; - break; - } - - // Sort of a hack, we try and resolve the path and make it relative, if we can. - string filePath = PrependPath(file); - ss.WriteLine(" ", filePath, buildAction); - } - ss.WriteLine(" "); - - ss.WriteLine(" "); - foreach(ReferenceNode refr in project.References) - { - ss.WriteLine(" {0}", BuildReference(solution, refr)); - } - ss.WriteLine(" "); - - - ss.WriteLine(""); - } - - m_Kernel.CurrentWorkingDirectory.Pop(); - } - - private void WriteCombine(SolutionNode solution) - { - m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); - foreach(ProjectNode project in solution.Projects) - { - if(m_Kernel.AllowProject(project.FilterGroups)) - { - m_Kernel.Log.Write("...Creating project: {0}", project.Name); - WriteProject(solution, project); - } - } - - m_Kernel.Log.Write(""); - string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); - StreamWriter ss = new StreamWriter(combFile); - - m_Kernel.CurrentWorkingDirectory.Push(); - Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); - - int count = 0; - - using(ss) - { - ss.WriteLine("", solution.Name); - - count = 0; - foreach(ConfigurationNode conf in solution.Configurations) - { - if(count == 0) - { - ss.WriteLine(" ", conf.Name); - } - - ss.WriteLine(" ", conf.Name); - foreach(ProjectNode project in solution.Projects) - { - ss.WriteLine(" ", project.Name, conf.Name); - } - ss.WriteLine(" "); - - count++; - } - ss.WriteLine(" "); - - count = 0; - - foreach(ProjectNode project in solution.Projects) - { - if(count == 0) - ss.WriteLine(" ", project.Name); - - ss.WriteLine(" ", project.Name); - count++; - } - ss.WriteLine(" "); - - ss.WriteLine(" "); - foreach(ProjectNode project in solution.Projects) - { - string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); - ss.WriteLine(" ", - Helper.MakeFilePath(path, project.Name, "mdp")); - } - 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, "mdp"); - Helper.DeleteIfExists(projectFile); - } - - private void CleanSolution(SolutionNode solution) - { - m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); - - string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); - 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 "sharpdev"; - } - } - - #endregion - } -} +#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 22:07:07 +0100 (ti, 13 feb 2007) $ + * $Revision: 206 $ + */ +#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("monodev")] + public class MonoDevelopTarget : 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 = ""; + } + else + { + ProjectNode project = (ProjectNode)refr.Parent; + string fileRef = FindFileReference(refr.Name, project); + + if(refr.Path != null || fileRef != null) + { + ret += "Assembly\" refto=\""; + + string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; + + ret += finalPath; + ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; + return ret; + } + + ret += "Gac\""; + ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; + ret += " refto=\""; + try + { + //Assembly assem = Assembly.Load(refr.Name); + //ret += assem.FullName; + ret += refr.Name; + } + catch (System.NullReferenceException e) + { + e.ToString(); + ret += refr.Name; + } + 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 GenerateXmlDocFile(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 "False"; + } + return "True"; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + string csComp = "Mcs"; + string netRuntime = "Mono"; + if(project.Runtime == ClrRuntime.Microsoft) + { + csComp = "Csc"; + netRuntime = "MsNet"; + } + + string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); + StreamWriter ss = new StreamWriter(projFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); + + using(ss) + { + ss.WriteLine( + "", + project.Name, + project.RootNamespace + ); + + int count = 0; + + ss.WriteLine(" ", solution.ActiveConfig); + + foreach(ConfigurationNode conf in project.Configurations) + { + ss.WriteLine(" ", conf.Name); + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + + ss.Write(" "); + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + ss.Write(" "); + ss.WriteLine(" "); + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(string file in project.Files) + { + string buildAction = "Compile"; + switch(project.Files.GetBuildAction(file)) + { + case BuildAction.None: + buildAction = "Nothing"; + break; + + case BuildAction.Content: + buildAction = "Exclude"; + break; + + case BuildAction.EmbeddedResource: + buildAction = "EmbedAsResource"; + break; + + default: + buildAction = "Compile"; + break; + } + + // Sort of a hack, we try and resolve the path and make it relative, if we can. + string filePath = PrependPath(file); + ss.WriteLine(" ", filePath, buildAction); + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ss.WriteLine(" {0}", BuildReference(solution, refr)); + } + ss.WriteLine(" "); + + + ss.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void WriteCombine(SolutionNode solution) + { + m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); + foreach(ProjectNode project in solution.Projects) + { + if(m_Kernel.AllowProject(project.FilterGroups)) + { + m_Kernel.Log.Write("...Creating project: {0}", project.Name); + WriteProject(solution, project); + } + } + + m_Kernel.Log.Write(""); + string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + StreamWriter ss = new StreamWriter(combFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); + + int count = 0; + + using(ss) + { + ss.WriteLine("", solution.Name); + + count = 0; + foreach(ConfigurationNode conf in solution.Configurations) + { + if(count == 0) + { + ss.WriteLine(" ", conf.Name); + } + + ss.WriteLine(" ", conf.Name); + foreach(ProjectNode project in solution.Projects) + { + ss.WriteLine(" ", project.Name, conf.Name); + } + ss.WriteLine(" "); + + count++; + } + ss.WriteLine(" "); + + count = 0; + + foreach(ProjectNode project in solution.Projects) + { + if(count == 0) + ss.WriteLine(" ", project.Name); + + ss.WriteLine(" ", project.Name); + count++; + } + ss.WriteLine(" "); + + ss.WriteLine(" "); + foreach(ProjectNode project in solution.Projects) + { + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine(" ", + Helper.MakeFilePath(path, project.Name, "mdp")); + } + 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, "mdp"); + Helper.DeleteIfExists(projectFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); + 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 "sharpdev"; + } + } + + #endregion + } +} -- cgit v1.1