Add ability to use other text gen tools

This commit is contained in:
Zontreck 2023-08-28 23:38:53 -07:00
parent 19d2cba440
commit 7e3f7f7998
3 changed files with 24 additions and 3 deletions

Binary file not shown.

View file

@ -16,6 +16,7 @@ namespace Prebuild.Core.Nodes
private string m_Name; private string m_Name;
private string m_OutputName; private string m_OutputName;
private List<string> m_Libs = new(); private List<string> m_Libs = new();
private string m_Tool;
#endregion #endregion
@ -25,6 +26,7 @@ namespace Prebuild.Core.Nodes
{ {
m_Name = Helper.AttributeValue(node, "name", ""); m_Name = Helper.AttributeValue(node, "name", "");
m_OutputName = Helper.AttributeValue(node, "output", ""); m_OutputName = Helper.AttributeValue(node, "output", "");
m_Tool = Helper.AttributeValue(node, "tool", "SnapWrap");
foreach (XmlNode childNode in node.ChildNodes) foreach (XmlNode childNode in node.ChildNodes)
{ {
@ -75,6 +77,14 @@ namespace Prebuild.Core.Nodes
} }
} }
public string Tool
{
get
{
return m_Tool;
}
}
#endregion #endregion
} }
} }

View file

@ -687,17 +687,28 @@ public abstract class VSGenericTarget : ITarget
} }
} }
private void WriteTextGeneratorNodes(ProjectNode project, StreamWriter ps) private void WriteTextGeneratorNodes(ProjectNode project, StreamWriter ps)
{ {
int count = 0;
foreach(TextGenNode node in project.TextGenNodes) foreach(TextGenNode node in project.TextGenNodes)
{ {
string pathText = Path.Combine("Prebuild", "bootstrap", "SnapWrap.dll"); string pathText = Path.Combine("Prebuild", "bootstrap", node.Tool);
pathText = Path.ChangeExtension(pathText, "dll");
string filePath = Path.Combine(project.Path, node.Name); string filePath = Path.Combine(project.Path, node.Name);
string outputFile = Path.Combine(project.Path, node.OutputName); string outputFile = Path.Combine(project.Path, node.OutputName);
ps.WriteLine(" <Target Name=\"Prebuild\" BeforeTargets=\"PreBuildEvent\">"); ps.WriteLine(" <Target Name=\"Prebuild-"+count+"\" BeforeTargets=\"PreBuildEvent\">");
if (node.Tool == "SnapWrap")
ps.WriteLine($" <Exec Command='dotnet \"$(SolutionDir){pathText}\" \"$({node.SourceDirectory}){node.Name}\" \"$(ProjectDir){node.OutputName}\" \"{node.Libraries}\"' />"); ps.WriteLine($" <Exec Command='dotnet \"$(SolutionDir){pathText}\" \"$({node.SourceDirectory}){node.Name}\" \"$(ProjectDir){node.OutputName}\" \"{node.Libraries}\"' />");
else
ps.WriteLine($" <Exec Command='dotnet \"$(SolutionDir){pathText}\" \"$({node.SourceDirectory}){node.Name}\" \"$(ProjectDir){node.OutputName}\" />");
ps.WriteLine($" </Target>"); ps.WriteLine($" </Target>");
count++;
} }
} }