From 7e65590a55ba575d0086bdfc25addaf1051d799b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 11 Sep 2010 01:13:08 +0100 Subject: Update Prebuild.exe with Prebuild r323 + an existing OpenSim specific nant hack to correctly clean up chosen OpenSim exes and dlls in bin/ on a "nant clean" Source code is included for reference. This can go away again once Prebuild is updated with a more general mechanism for cleaning up files. The Prebuild source code here can be built with nant, or regnerated for other tools using the prebuild at {root}/bin/Prebuild.exe --- Prebuild/src/Core/Targets/VS2003Target.cs | 593 ++++++++++++++++++++++++++++++ 1 file changed, 593 insertions(+) create mode 100644 Prebuild/src/Core/Targets/VS2003Target.cs (limited to 'Prebuild/src/Core/Targets/VS2003Target.cs') diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs new file mode 100644 index 0000000..10e2dc4 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2003Target.cs @@ -0,0 +1,593 @@ +#region BSD License +/* +Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. +* The name of the author may not be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#endregion + +using System; +using System.Collections.Generic; +using System.IO; + +using Prebuild.Core.Attributes; +using Prebuild.Core.Interfaces; +using Prebuild.Core.Nodes; +using Prebuild.Core.Utilities; + +namespace Prebuild.Core.Targets +{ + [Target("vs2003")] + public class VS2003Target : ITarget + { + + #region Fields + + string solutionVersion = "8.00"; + string productVersion = "7.10.3077"; + string schemaVersion = "2.0"; + string versionName = "2003"; + VSVersion version = VSVersion.VS71; + + readonly Dictionary m_Tools = new Dictionary(); + Kernel m_Kernel; + + /// + /// Gets or sets the solution version. + /// + /// The solution version. + protected string SolutionVersion + { + get + { + return solutionVersion; + } + set + { + solutionVersion = value; + } + } + /// + /// Gets or sets the product version. + /// + /// The product version. + protected string ProductVersion + { + get + { + return productVersion; + } + set + { + productVersion = value; + } + } + /// + /// Gets or sets the schema version. + /// + /// The schema version. + protected string SchemaVersion + { + get + { + return schemaVersion; + } + set + { + schemaVersion = value; + } + } + /// + /// Gets or sets the name of the version. + /// + /// The name of the version. + protected string VersionName + { + get + { + return versionName; + } + set + { + versionName = value; + } + } + /// + /// Gets or sets the version. + /// + /// The version. + protected VSVersion Version + { + get + { + return version; + } + set + { + version = value; + } + } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public VS2003Target() + { + m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); + m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); + } + + #endregion + + #region Private Methods + + private string MakeRefPath(ProjectNode project) + { + string ret = ""; + foreach(ReferencePathNode node in project.ReferencePaths) + { + try + { + string fullPath = Helper.ResolvePath(node.Path); + if(ret.Length < 1) + { + ret = fullPath; + } + else + { + ret += ";" + fullPath; + } + } + catch(ArgumentException) + { + m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); + } + } + + return ret; + } + + private void WriteProject(SolutionNode solution, ProjectNode project) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + StreamWriter ps = new StreamWriter(projectFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); + + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}", toolInfo.XmlTag); + ps.WriteLine("\t\t\t\tProjectType = \"Local\""); + ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", ProductVersion); + ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", SchemaVersion); + ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); + ps.WriteLine("\t\t>"); + + ps.WriteLine("\t\t\t\t"); + ps.WriteLine(" "); + + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine("\t\t\t\t "); + } + + ps.WriteLine(" "); + + ps.WriteLine(" "); + foreach(ReferenceNode refr in project.References) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" "); + + ps.WriteLine(" "); + + foreach(string file in project.Files) + { + string fileName = file.Replace(".\\", ""); + ps.WriteLine(" "); + + if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) + { + ps.WriteLine(" "); + + } + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + ps = new StreamWriter(projectFile + ".user"); + using(ps) + { + ps.WriteLine(""); + ps.WriteLine(" <{0}>", toolInfo.XmlTag); + ps.WriteLine(" "); + + ps.WriteLine(" ", MakeRefPath(project)); + foreach(ConfigurationNode conf in project.Configurations) + { + ps.WriteLine(" "); + } + ps.WriteLine(" "); + + ps.WriteLine(" "); + ps.WriteLine(" ", toolInfo.XmlTag); + ps.WriteLine(""); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + /// + /// 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"); + } + // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false + // { + // return string.Empty; + // } + + //default to "AssemblyName.xml" + //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; + //return (string)conf.Options["XmlDocFile", defaultValue]; + + //default to no XmlDocFile file + return (string)conf.Options["XmlDocFile", ""]; + } + + private void WriteSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", VersionName); + + 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 solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + StreamWriter ss = new StreamWriter(solutionFile); + + m_Kernel.CurrentWorkingDirectory.Push(); + Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); + + using(ss) + { + ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", SolutionVersion); + foreach(ProjectNode project in solution.Projects) + { + if(!m_Tools.ContainsKey(project.Language)) + { + throw new UnknownLanguageException("Unknown .NET language: " + project.Language); + } + + ToolInfo toolInfo = m_Tools[project.Language]; + + string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); + ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", + toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, + toolInfo.FileExtension), project.Guid.ToString().ToUpper()); + + ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); + ss.WriteLine("\tEndProjectSection"); + + ss.WriteLine("EndProject"); + } + + ss.WriteLine("Global"); + + ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); + foreach(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{0} = {0}", conf.Name); + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + for(int i = 0; i < project.References.Count; i++) + { + ReferenceNode refr = project.References[i]; + if(solution.ProjectsTable.ContainsKey(refr.Name)) + { + ProjectNode refProject = solution.ProjectsTable[refr.Name]; + ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", + project.Guid.ToString().ToUpper() + , i, + refProject.Guid.ToString().ToUpper() + ); + } + } + } + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); + foreach(ProjectNode project in solution.Projects) + { + foreach(ConfigurationNode conf in solution.Configurations) + { + ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", + project.Guid.ToString().ToUpper(), + conf.Name); + + ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", + project.Guid.ToString().ToUpper(), + conf.Name); + } + } + ss.WriteLine("\tEndGlobalSection"); + + if(solution.Files != null) + { + ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); + foreach(string file in solution.Files) + { + ss.WriteLine("\t\t{0} = {0}", file); + } + ss.WriteLine("\tEndGlobalSection"); + } + + ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); + ss.WriteLine("\tEndGlobalSection"); + ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); + ss.WriteLine("\tEndGlobalSection"); + + ss.WriteLine("EndGlobal"); + } + + m_Kernel.CurrentWorkingDirectory.Pop(); + } + + private void CleanProject(ProjectNode project) + { + m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); + + ToolInfo toolInfo = m_Tools[project.Language]; + string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); + string userFile = projectFile + ".user"; + + Helper.DeleteIfExists(projectFile); + Helper.DeleteIfExists(userFile); + } + + private void CleanSolution(SolutionNode solution) + { + m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", VersionName, solution.Name); + + string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); + string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); + + Helper.DeleteIfExists(slnFile); + Helper.DeleteIfExists(suoFile); + + foreach(ProjectNode project in solution.Projects) + { + CleanProject(project); + } + + m_Kernel.Log.Write(""); + } + + #endregion + + #region ITarget Members + + /// + /// Writes the specified kern. + /// + /// The kern. + public virtual void Write(Kernel kern) + { + if( kern == null ) + { + throw new ArgumentNullException("kern"); + } + m_Kernel = kern; + foreach(SolutionNode sol in m_Kernel.Solutions) + { + WriteSolution(sol); + } + 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 m_Kernel.Solutions) + { + CleanSolution(sol); + } + m_Kernel = null; + } + + /// + /// Gets the name. + /// + /// The name. + public virtual string Name + { + get + { + return "vs2003"; + } + } + + #endregion + } +} -- cgit v1.1