From 41e8b9f91ff73fd4d18aae1e467446563f94c33f Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 30 Aug 2017 22:24:07 +0100
Subject: update Prebuild with WhiteCore version
---
Prebuild/src/Core/Targets/NAntTarget.cs | 771 +++++++++++++++++---------------
1 file changed, 398 insertions(+), 373 deletions(-)
(limited to 'Prebuild/src/Core/Targets/NAntTarget.cs')
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
index 21bc80e..925f5ca 100644
--- a/Prebuild/src/Core/Targets/NAntTarget.cs
+++ b/Prebuild/src/Core/Targets/NAntTarget.cs
@@ -47,36 +47,36 @@ using Prebuild.Core.Utilities;
namespace Prebuild.Core.Targets
{
- ///
- ///
- ///
- [Target("nant")]
- public class NAntTarget : ITarget
- {
- #region Fields
-
- private Kernel m_Kernel;
-
- #endregion
-
- #region Private Methods
-
- private static string PrependPath(string path)
- {
- string tmpPath = Helper.NormalizePath(path, '/');
- Regex regex = new Regex(@"(\w):/(\w+)");
- Match match = regex.Match(tmpPath);
- //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
- //{
- tmpPath = Helper.NormalizePath(tmpPath);
- //}
- // else
- // {
- // tmpPath = Helper.NormalizePath("./" + tmpPath);
- // }
-
- return tmpPath;
- }
+ ///
+ ///
+ ///
+ [Target("nant")]
+ public class NAntTarget : ITarget
+ {
+ #region Fields
+
+ private Kernel m_Kernel;
+
+ #endregion
+
+ #region Private Methods
+
+ private static string PrependPath(string path)
+ {
+ string tmpPath = Helper.NormalizePath(path, '/');
+ Regex regex = new Regex(@"(\w):/(\w+)");
+ Match match = regex.Match(tmpPath);
+ //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
+ //{
+ tmpPath = Helper.NormalizePath(tmpPath);
+ //}
+ // else
+ // {
+ // tmpPath = Helper.NormalizePath("./" + tmpPath);
+ // }
+
+ return tmpPath;
+ }
private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr)
{
@@ -85,7 +85,7 @@ namespace Prebuild.Core.Targets
{
return refr.Path;
}
-
+
if (solution.ProjectsTable.ContainsKey(refr.Name))
{
ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name];
@@ -113,7 +113,7 @@ namespace Prebuild.Core.Targets
return refr.Name + ".dll";
}
- public static string GetRefFileName(string refName)
+ public static string GetRefFileName(string refName)
{
if (ExtensionSpecified(refName))
{
@@ -140,11 +140,11 @@ namespace Prebuild.Core.Targets
return extension;
}
- private static string FindFileReference(string refName, ProjectNode project)
- {
- foreach (ReferencePathNode refPath in project.ReferencePaths)
- {
- string fullPath = Helper.MakeFilePath(refPath.Path, refName);
+ private static string FindFileReference(string refName, ProjectNode project)
+ {
+ foreach (ReferencePathNode refPath in project.ReferencePaths)
+ {
+ string fullPath = Helper.MakeFilePath(refPath.Path, refName);
if (File.Exists(fullPath))
{
@@ -153,10 +153,10 @@ namespace Prebuild.Core.Targets
fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
- if (File.Exists(fullPath))
- {
- return fullPath;
- }
+ if (File.Exists(fullPath))
+ {
+ return fullPath;
+ }
fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe");
@@ -164,162 +164,205 @@ namespace Prebuild.Core.Targets
{
return fullPath;
}
- }
-
- return null;
- }
-
- ///
- /// Gets the XML doc file.
- ///
- /// The project.
- /// The conf.
- ///
- public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
- {
- if (conf == null)
- {
- throw new ArgumentNullException("conf");
- }
- if (project == null)
- {
- throw new ArgumentNullException("project");
- }
- string docFile = (string)conf.Options["XmlDocFile"];
- // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
- // {
- // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
- // }
- return docFile;
- }
-
- private void WriteProject(SolutionNode solution, ProjectNode project)
- {
+ }
+
+ return null;
+ }
+
+ ///
+ /// Gets the XML doc file.
+ ///
+ /// The project.
+ /// The conf.
+ ///
+ public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
+ {
+ if (conf == null)
+ {
+ throw new ArgumentNullException("conf");
+ }
+ if (project == null)
+ {
+ throw new ArgumentNullException("project");
+ }
+ string docFile = (string)conf.Options["XmlDocFile"];
+ // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
+ // {
+ // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
+ // }
+ return docFile;
+ }
+
+ private void WriteProject(SolutionNode solution, ProjectNode project)
+ {
string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
- StreamWriter ss = new StreamWriter(projFile);
-
- m_Kernel.CurrentWorkingDirectory.Push();
- Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
- bool hasDoc = false;
-
- using (ss)
- {
- ss.WriteLine("");
- ss.WriteLine("", project.Name);
- ss.WriteLine(" ", "build");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
-
- ss.Write(" ");
+ ss.WriteLine("", project.Name);
+ ss.WriteLine(" ", "build");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ foreach (ReferenceNode refr in project.References)
+ {
+ if (refr.LocalCopy)
+ {
+ ss.WriteLine(" ", '/'));
+ }
+ }
+
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ if (project.ConfigFile != null && project.ConfigFile.Length!=0)
+ {
+ ss.Write(" ");
+ }
+
+ // Add the content files to just be copied
+ ss.WriteLine(" {0}", "");
+ ss.WriteLine(" {0}", "");
+
+ foreach (string file in project.Files)
+ {
+ // Ignore if we aren't content
+ if (project.Files.GetBuildAction(file) != BuildAction.Content)
+ continue;
+
+ // Create a include tag
+ ss.WriteLine(" {0}", "");
+ }
+
+ ss.WriteLine(" {0}", "");
+ ss.WriteLine(" {0}", "");
+
+ ss.Write(" ");
- ss.WriteLine(" ", project.RootNamespace);
- foreach (string file in project.Files)
- {
- switch (project.Files.GetBuildAction(file))
- {
- case BuildAction.EmbeddedResource:
- ss.WriteLine(" {0}", "");
- break;
- default:
- if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
- {
- ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx");
- }
- break;
- }
- }
- //if (project.Files.GetSubType(file).ToString() != "Code")
- //{
- // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx");
-
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- foreach (string file in project.Files)
- {
- switch (project.Files.GetBuildAction(file))
- {
- case BuildAction.Compile:
- ss.WriteLine(" ");
- break;
- default:
- break;
- }
- }
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
+ ss.WriteLine(" ", project.RootNamespace);
+ foreach (string file in project.Files)
+ {
+ switch (project.Files.GetBuildAction(file))
+ {
+ case BuildAction.EmbeddedResource:
+ ss.WriteLine(" {0}", "");
+ break;
+ default:
+ if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
+ {
+ ss.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx");
+ }
+ break;
+ }
+ }
+ //if (project.Files.GetSubType(file).ToString() != "Code")
+ //{
+ // ps.WriteLine(" ", file.Substring(0, file.LastIndexOf('.')) + ".resx");
+
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ foreach (string file in project.Files)
+ {
+ switch (project.Files.GetBuildAction(file))
+ {
+ case BuildAction.Compile:
+ ss.WriteLine(" ");
+ break;
+ default:
+ break;
+ }
+ }
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
foreach(ReferencePathNode refPath in project.ReferencePaths)
{
ss.WriteLine(" ");
}
- ss.WriteLine(" ");
- foreach (ReferenceNode refr in project.References)
- {
- string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
+ ss.WriteLine(" ");
+ foreach (ReferenceNode refr in project.References)
+ {
+ string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
if (refr.Path != null) {
if (ExtensionSpecified(refr.Name))
{
@@ -334,12 +377,12 @@ namespace Prebuild.Core.Targets
{
ss.WriteLine (" ");
}
- }
- ss.WriteLine(" ");
+ }
+ ss.WriteLine(" ");
- ss.WriteLine(" ");
+ ss.WriteLine(" ");
- foreach (ConfigurationNode conf in project.Configurations)
+ foreach (ConfigurationNode conf in project.Configurations)
{
if (!String.IsNullOrEmpty(conf.Options.OutputPath))
{
@@ -361,170 +404,170 @@ namespace Prebuild.Core.Targets
}
}
- ss.WriteLine(" ");
-
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
-
- ss.WriteLine(" ");
- if (hasDoc)
- {
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.Write(" ");
- }
- else
- {
- ss.WriteLine(".exe\" />");
- }
-
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- // foreach(ReferenceNode refr in project.References)
- // {
- // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
- // if (path != "")
- // {
- // ss.WriteLine(" ", path);
- // }
- // }
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- }
- ss.WriteLine(" ");
- ss.WriteLine("");
- }
- m_Kernel.CurrentWorkingDirectory.Pop();
- }
-
- private void WriteCombine(SolutionNode solution)
- {
- m_Kernel.Log.Write("Creating NAnt build files");
- foreach (ProjectNode project in solution.Projects)
- {
- if (m_Kernel.AllowProject(project.FilterGroups))
- {
- m_Kernel.Log.Write("...Creating project: {0}", project.Name);
- WriteProject(solution, project);
- }
- }
-
- m_Kernel.Log.Write("");
- string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
- StreamWriter ss = new StreamWriter(combFile);
-
- m_Kernel.CurrentWorkingDirectory.Push();
- Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
-
- using (ss)
- {
- ss.WriteLine("");
- ss.WriteLine("", solution.Name);
- ss.WriteLine(" ");
- ss.WriteLine();
-
- //ss.WriteLine(" ");
- //ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
-
- // Use the active configuration, which is the first configuration name in the prebuild file.
- Dictionary emittedConfigurations = new Dictionary();
-
- ss.WriteLine(" ", solution.ActiveConfig);
- ss.WriteLine();
-
- foreach (ConfigurationNode conf in solution.Configurations)
- {
- // If the name isn't in the emitted configurations, we give a high level target to the
- // platform specific on. This lets "Debug" point to "Debug-AnyCPU".
- if (!emittedConfigurations.ContainsKey(conf.Name))
- {
- // Add it to the dictionary so we only emit one.
- emittedConfigurations.Add(conf.Name, conf.Platform);
-
- // Write out the target block.
- ss.WriteLine(" ", conf.Name, conf.Platform);
- ss.WriteLine(" ");
- ss.WriteLine();
- }
-
- // Write out the target for the configuration.
- ss.WriteLine(" ", conf.Name, conf.Platform);
- ss.WriteLine(" ", conf.Name);
- ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower());
- ss.WriteLine("\t\t ", conf.Platform);
- 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(" ");
+ ss.WriteLine(" ");
+
+ ss.WriteLine(" ");
+ if (hasDoc)
+ {
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.Write(" ");
+ }
+ else
+ {
+ ss.WriteLine(".exe\" />");
+ }
+
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ // foreach(ReferenceNode refr in project.References)
+ // {
+ // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
+ // if (path != "")
+ // {
+ // ss.WriteLine(" ", path);
+ // }
+ // }
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ }
+ ss.WriteLine(" ");
+ ss.WriteLine("");
+ }
+ m_Kernel.CurrentWorkingDirectory.Pop();
+ }
+
+ private void WriteCombine(SolutionNode solution)
+ {
+ m_Kernel.Log.Write("Creating NAnt build files");
+ foreach (ProjectNode project in solution.Projects)
+ {
+ if (m_Kernel.AllowProject(project.FilterGroups))
+ {
+ m_Kernel.Log.Write("...Creating project: {0}", project.Name);
+ WriteProject(solution, project);
+ }
+ }
+
+ m_Kernel.Log.Write("");
+ string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
+ StreamWriter ss = new StreamWriter(combFile);
+
+ m_Kernel.CurrentWorkingDirectory.Push();
+ Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
+
+ using (ss)
+ {
+ ss.WriteLine("");
+ ss.WriteLine("", solution.Name);
+ ss.WriteLine(" ");
+ ss.WriteLine();
+
+ //ss.WriteLine(" ");
+ //ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+ ss.WriteLine(" ");
+
+ // Use the active configuration, which is the first configuration name in the prebuild file.
+ Dictionary emittedConfigurations = new Dictionary();
+
+ ss.WriteLine(" ", solution.ActiveConfig);
+ ss.WriteLine();
+
+ foreach (ConfigurationNode conf in solution.Configurations)
+ {
+ // If the name isn't in the emitted configurations, we give a high level target to the
+ // platform specific on. This lets "Debug" point to "Debug-AnyCPU".
+ if (!emittedConfigurations.ContainsKey(conf.Name))
+ {
+ // Add it to the dictionary so we only emit one.
+ emittedConfigurations.Add(conf.Name, conf.Platform);
+
+ // Write out the target block.
+ ss.WriteLine(" ", conf.Name, conf.Platform);
+ ss.WriteLine(" ");
+ ss.WriteLine();
+ }
+
+ // Write out the target for the configuration.
+ ss.WriteLine(" ", conf.Name, conf.Platform);
+ ss.WriteLine(" ", conf.Name);
+ ss.WriteLine(" ", conf.Options["DebugInformation"].ToString().ToLower());
+ ss.WriteLine("\t\t ", conf.Platform);
+ 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(" ");
@@ -594,24 +637,6 @@ namespace Prebuild.Core.Targets
ss.WriteLine(" ");
ss.WriteLine(" ");
//ss.WriteLine(" ");
-
- // justincc: FIXME FIXME FIXME - A temporary OpenSim hack to clean up files when "nant clean" is executed.
- // Should be replaced with extreme prejudice once anybody finds out if the CleanFiles stuff works or there is
- // another working mechanism for specifying this stuff
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
- ss.WriteLine(" ");
-
if (solution.Cleanup != null && solution.Cleanup.CleanFiles.Count > 0)
{
foreach (CleanFilesNode cleanFile in solution.Cleanup.CleanFiles)
@@ -625,7 +650,7 @@ namespace Prebuild.Core.Targets
}
}
- ss.WriteLine(" ");
+ ss.WriteLine(" ");
foreach (ProjectNode project in solution.Projects)
{
string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
--
cgit v1.1