Browse Source

Set SolutionPath environment variable when building C++ projects.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3234 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
851fa495d7
  1. 32
      samples/CppBackendBinding/CppProject.cs
  2. 4
      samples/CppBackendBinding/FileGroup.cs

32
samples/CppBackendBinding/CppProject.cs

@ -79,13 +79,21 @@ namespace CppBackendBinding
} }
foreach (FileItem item in items) { foreach (FileItem item in items) {
FileGroup group = groups.Find(fg => fg.ItemType == item.ProjectItem.ItemType); FileGroup group = groups.Find(fg => fg.ItemType == item.ProjectItem.ItemType);
if (groups != null) { if (group != null) {
group.XmlElement.AppendChild(item.XmlElement); group.XmlElement.AppendChild(item.XmlElement);
} else { } else {
LoggingService.Warn("Couldn't find filter for item type " + item.ProjectItem.ItemType + ", the item was not saved!"); LoggingService.Warn("Couldn't find filter for item type " + item.ProjectItem.ItemType + ", the item was not saved!");
} }
} }
document.Save(fileName); using (XmlWriter writer = XmlWriter.Create(fileName, new XmlWriterSettings {
NewLineOnAttributes = true,
Indent = true,
IndentChars = "\t",
Encoding = Encoding.Default
}))
{
document.Save(writer);
}
} }
} }
@ -113,6 +121,17 @@ namespace CppBackendBinding
} }
} }
public override ItemType GetDefaultItemType(string fileName)
{
string extension = Path.GetExtension(fileName);
if (string.Equals(extension, ".c", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".cpp", StringComparison.OrdinalIgnoreCase))
return ItemType.Compile;
else if (string.Equals(extension, ".h", StringComparison.OrdinalIgnoreCase))
return ItemType.Header;
else
return base.GetDefaultItemType(fileName);
}
#region IProjectAllowChangeConfigurations #region IProjectAllowChangeConfigurations
// TODO: Configuration/Platform handling // TODO: Configuration/Platform handling
bool IProjectAllowChangeConfigurations.RenameProjectConfiguration(string oldName, string newName) bool IProjectAllowChangeConfigurations.RenameProjectConfiguration(string oldName, string newName)
@ -222,6 +241,7 @@ namespace CppBackendBinding
p.StartInfo.CreateNoWindow = true; p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
p.StartInfo.EnvironmentVariables["VCBUILD_DEFAULT_CFG"] = options.Configuration + "|" + options.Platform; p.StartInfo.EnvironmentVariables["VCBUILD_DEFAULT_CFG"] = options.Configuration + "|" + options.Platform;
p.StartInfo.EnvironmentVariables["SolutionPath"] = ParentSolution.Directory;
p.EnableRaisingEvents = true; p.EnableRaisingEvents = true;
p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) {
@ -229,8 +249,8 @@ namespace CppBackendBinding
BuildError error = ParseError(e.Data); BuildError error = ParseError(e.Data);
if (error != null) if (error != null)
feedbackSink.ReportError(error); feedbackSink.ReportError(error);
// else else
feedbackSink.ReportMessage(e.Data); feedbackSink.ReportMessage(e.Data);
} }
}; };
p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) { p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) {
@ -238,8 +258,8 @@ namespace CppBackendBinding
BuildError error = ParseError(e.Data); BuildError error = ParseError(e.Data);
if (error != null) if (error != null)
feedbackSink.ReportError(error); feedbackSink.ReportError(error);
// else else
feedbackSink.ReportError(new BuildError(null, e.Data)); feedbackSink.ReportError(new BuildError(null, e.Data));
} }
}; };
p.Exited += delegate(object sender, EventArgs e) { p.Exited += delegate(object sender, EventArgs e) {

4
samples/CppBackendBinding/FileGroup.cs

@ -23,6 +23,10 @@ namespace CppBackendBinding
public FileGroup(CppProject project, XmlElement filterElement) public FileGroup(CppProject project, XmlElement filterElement)
{ {
if (project == null)
throw new ArgumentNullException("project");
if (filterElement == null)
throw new ArgumentNullException("filterElement");
this.Project = project; this.Project = project;
this.XmlElement = filterElement; this.XmlElement = filterElement;
switch (filterElement.GetAttribute("UniqueIdentifier")) { switch (filterElement.GetAttribute("UniqueIdentifier")) {

Loading…
Cancel
Save