Add Copy task to Prebuild.exe (vsxxxx targets)

<Files>
    <Match pattern="*.cs" recurse="true"/>
    <Match pattern="../bin/MyConfig.xml" buildAction="Copy" recurse="false" destination="$(OutputPath)" />
  </Files>
iar_mods
BlueWall 2011-12-25 00:04:42 -05:00
parent b6cfe15c7c
commit f36fe45fa7
25 changed files with 3873 additions and 3769 deletions

BIN
Prebuild/Prebuild.exe Executable file

Binary file not shown.

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<Prebuild xmlns="http://dnpb.sourceforge.net/schemas/prebuild-1.9.xsd" version="1.9"> <Prebuild xmlns="http://dnpb.sourceforge.net/schemas/prebuild-1.9.xsd" version="1.9">
<Solution name="Prebuild" version="2.0.4"> <Solution name="Prebuild" version="2.0.5">
<Configuration name="Debug"> <Configuration name="Debug">
<Options> <Options>
<CompilerDefines>DEBUG;TRACE</CompilerDefines> <CompilerDefines>DEBUG;TRACE</CompilerDefines>
@ -31,13 +31,15 @@
type="Exe" type="Exe"
rootNamespace="Prebuild" rootNamespace="Prebuild"
startupObject="Prebuild.Prebuild" startupObject="Prebuild.Prebuild"
version="2.0.3" version="2.0.5"
frameworkVersion="v3_5"
> >
<Author>Matthew Holmes (matthew@wildfiregames.com)</Author> <Author>Matthew Holmes (matthew@wildfiregames.com)</Author>
<Author>Dan Moorehead (dan05a@gmail.com)</Author> <Author>Dan Moorehead (dan05a@gmail.com)</Author>
<Author>Dave Hudson (jendave@yahoo.com)</Author> <Author>Dave Hudson (jendave@yahoo.com)</Author>
<Author>Rob Loach (http://robloach.net)</Author> <Author>Rob Loach (http://robloach.net)</Author>
<Author>C.J. Adams-Collier (cjac@colliertech.org)</Author> <Author>C.J. Adams-Collier (cjac@colliertech.org)</Author>
<Author>John Hurliman (john.hurliman@intel.com)</Author>
<Description>The Prebuild project generator</Description> <Description>The Prebuild project generator</Description>
<Configuration name="Debug"> <Configuration name="Debug">
<Options> <Options>

View File

@ -62,7 +62,11 @@ namespace Prebuild.Core.Nodes
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
Page Page,
/// <summary>
///
/// </summary>
Copy
} }
/// <summary> /// <summary>
@ -245,6 +249,9 @@ namespace Prebuild.Core.Nodes
if (subType != String.Empty) if (subType != String.Empty)
m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); m_SubType = (SubType)Enum.Parse(typeof(SubType), subType);
Console.WriteLine("[FileNode]:BuildAction is {0}", buildAction);
m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString());
this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString));
if ( this.m_Link == true ) if ( this.m_Link == true )

View File

@ -25,6 +25,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.Xml; using System.Xml;
using Prebuild.Core.Attributes; using Prebuild.Core.Attributes;
@ -49,6 +50,8 @@ namespace Prebuild.Core.Nodes
private readonly Dictionary<string, bool> m_Links = new Dictionary<string, bool>(); private readonly Dictionary<string, bool> m_Links = new Dictionary<string, bool>();
private readonly Dictionary<string, string> m_LinkPaths = new Dictionary<string, string>(); private readonly Dictionary<string, string> m_LinkPaths = new Dictionary<string, string>();
private readonly Dictionary<string, bool> m_PreservePaths = new Dictionary<string, bool>(); private readonly Dictionary<string, bool> m_PreservePaths = new Dictionary<string, bool>();
private readonly Dictionary<string, string> m_DestinationPath = new Dictionary<string, string>();
private readonly NameValueCollection m_CopyFiles = new NameValueCollection();
#endregion #endregion
@ -62,6 +65,16 @@ namespace Prebuild.Core.Nodes
} }
} }
public string[] Destinations
{
get { return m_CopyFiles.AllKeys; }
}
public int CopyFiles
{
get { return m_CopyFiles.Count; }
}
#endregion #endregion
#region Public Methods #region Public Methods
@ -76,6 +89,20 @@ namespace Prebuild.Core.Nodes
return m_BuildActions[file]; return m_BuildActions[file];
} }
public string GetDestinationPath(string file)
{
if( !m_DestinationPath.ContainsKey(file))
{
return null;
}
return m_DestinationPath[file];
}
public string[] SourceFiles(string dest)
{
return m_CopyFiles.GetValues(dest);
}
public CopyToOutput GetCopyToOutput(string file) public CopyToOutput GetCopyToOutput(string file)
{ {
if (!m_CopyToOutputs.ContainsKey(file)) if (!m_CopyToOutputs.ContainsKey(file))
@ -178,6 +205,13 @@ namespace Prebuild.Core.Nodes
m_BuildActions[file] = GetBuildActionByFileName(file); m_BuildActions[file] = GetBuildActionByFileName(file);
else else
m_BuildActions[file] = matchNode.BuildAction.Value; m_BuildActions[file] = matchNode.BuildAction.Value;
if (matchNode.BuildAction == BuildAction.Copy)
{
m_CopyFiles.Add(matchNode.DestinationPath, file);
m_DestinationPath[file] = matchNode.DestinationPath;
}
m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value;
m_ResourceNames[ file ] = matchNode.ResourceName; m_ResourceNames[ file ] = matchNode.ResourceName;
m_PreservePaths[ file ] = matchNode.PreservePath; m_PreservePaths[ file ] = matchNode.PreservePath;

View File

@ -52,6 +52,7 @@ namespace Prebuild.Core.Nodes
private bool m_Link; private bool m_Link;
private string m_LinkPath; private string m_LinkPath;
private bool m_PreservePath; private bool m_PreservePath;
private string m_Destination = "";
private readonly List<ExcludeNode> m_Exclusions = new List<ExcludeNode>(); private readonly List<ExcludeNode> m_Exclusions = new List<ExcludeNode>();
#endregion #endregion
@ -80,6 +81,13 @@ namespace Prebuild.Core.Nodes
} }
} }
public string DestinationPath
{
get
{
return m_Destination;
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -285,12 +293,14 @@ namespace Prebuild.Core.Nodes
} }
string path = Helper.AttributeValue(node, "path", "."); string path = Helper.AttributeValue(node, "path", ".");
string pattern = Helper.AttributeValue(node, "pattern", "*"); string pattern = Helper.AttributeValue(node, "pattern", "*");
string destination = Helper.AttributeValue(node, "destination", string.Empty);
bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false"));
bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false"));
string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty);
if (buildAction != string.Empty) if (buildAction != string.Empty)
m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction);
//TODO: Figure out where the subtype node is being assigned //TODO: Figure out where the subtype node is being assigned
//string subType = Helper.AttributeValue(node, "subType", string.Empty); //string subType = Helper.AttributeValue(node, "subType", string.Empty);
//if (subType != String.Empty) //if (subType != String.Empty)
@ -304,11 +314,12 @@ namespace Prebuild.Core.Nodes
} }
m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) );
if ( buildAction == "Copy")
m_Destination = destination;
if(path != null && path.Length == 0) if(path != null && path.Length == 0)
{
path = ".";//use current directory path = ".";//use current directory
}
//throw new WarningException("Match must have a 'path' attribute"); //throw new WarningException("Match must have a 'path' attribute");
if(pattern == null) if(pattern == null)

View File

@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
/* /*
* $Source$ * $Source$
* $Author: jendave $ * $Author: jendave $
* $Date: 2006-09-20 08:42:51 +0100 (Wed, 20 Sep 2006) $ * $Date: 2006-09-20 03:42:51 -0400 (Wed, 20 Sep 2006) $
* $Revision: 164 $ * $Revision: 164 $
*/ */
#endregion #endregion

View File

@ -1,4 +1,4 @@
#region BSD License #region BSD License
/* /*
Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com) Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com)
@ -25,6 +25,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO; using System.IO;
using Prebuild.Core.Interfaces; using Prebuild.Core.Interfaces;
using Prebuild.Core.Nodes; using Prebuild.Core.Nodes;
@ -42,6 +43,7 @@ namespace Prebuild.Core.Targets
#region Fields #region Fields
readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>(); readonly Dictionary<string, ToolInfo> tools = new Dictionary<string, ToolInfo>();
// NameValueCollection CopyFiles = new NameValueCollection();
Kernel kernel; Kernel kernel;
#endregion #endregion
@ -168,7 +170,14 @@ namespace Prebuild.Core.Targets
#region Project File #region Project File
using (ps) using (ps)
{ {
ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion)); string targets = "";
if(project.Files.CopyFiles > 0)
targets = "Build;CopyFiles";
else
targets = "Build";
ps.WriteLine("<Project DefaultTargets=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {1}>", targets, GetToolsVersionXml(project.FrameworkVersion));
ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PropertyGroup>");
ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProjectType>Local</ProjectType>");
ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion);
@ -334,8 +343,14 @@ namespace Prebuild.Core.Targets
} }
foreach (string filePath in project.Files) foreach (string filePath in project.Files)
{ {
// Add the filePath with the destination as the key
// will use it later to form the copy parameters with Include lists
// for each destination
if (project.Files.GetBuildAction(filePath) == BuildAction.Copy)
continue;
// if (file == "Properties\\Bind.Designer.cs") // if (file == "Properties\\Bind.Designer.cs")
// { // {
// Console.WriteLine("Wait a minute!"); // Console.WriteLine("Wait a minute!");
@ -446,7 +461,9 @@ namespace Prebuild.Core.Targets
ps.WriteLine("Include=\"{0}\">", file); ps.WriteLine("Include=\"{0}\">", file);
int last_period_index = file.LastIndexOf('.'); int last_period_index = file.LastIndexOf('.');
string short_file_name = file.Substring(0, last_period_index); string short_file_name = (last_period_index >= 0)
? file.Substring(0, last_period_index)
: file;
string extension = Path.GetExtension(path); string extension = Path.GetExtension(path);
// make this upper case, so that when File.Exists tests for the // make this upper case, so that when File.Exists tests for the
// existence of a designer file on a case-sensitive platform, // existence of a designer file on a case-sensitive platform,
@ -501,8 +518,41 @@ namespace Prebuild.Core.Targets
} }
} }
} }
ps.WriteLine(" </ItemGroup>");
/*
* Copy Task
*
*/
if ( project.Files.CopyFiles > 0 ) {
Dictionary<string, string> IncludeTags = new Dictionary<string, string>();
int TagCount = 0;
// Handle Copy tasks
ps.WriteLine(" <ItemGroup>");
foreach (string destPath in project.Files.Destinations)
{
string tag = "FilesToCopy_" + TagCount.ToString("0000");
ps.WriteLine(" <{0} Include=\"{1}\" />", tag, String.Join(";", project.Files.SourceFiles(destPath)));
IncludeTags.Add(destPath, tag);
TagCount++;
}
ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" </ItemGroup>");
ps.WriteLine(" <Target Name=\"CopyFiles\">");
foreach (string destPath in project.Files.Destinations)
{
ps.WriteLine(" <Copy SourceFiles=\"@({0})\" DestinationFolder=\"{1}\" />",
IncludeTags[destPath], destPath);
}
ps.WriteLine(" </Target>");
}
ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PropertyGroup>");
ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" <PreBuildEvent>");

View File

@ -27,7 +27,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
/* /*
* $Source$ * $Source$
* $Author: kunnis $ * $Author: kunnis $
* $Date: 2009-04-15 02:33:14 +0100 (Wed, 15 Apr 2009) $ * $Date: 2009-04-14 21:33:14 -0400 (Tue, 14 Apr 2009) $
* $Revision: 308 $ * $Revision: 308 $
*/ */
#endregion #endregion

Binary file not shown.