Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3126 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
16 changed files with 673 additions and 30 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("C++ Backend Binding for SharpDevelop")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("CppBackendBinding")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
<AddIn name = "CppBackendBinding" |
||||
author = "Daniel Grunwald" |
||||
description = "An example AddIn demonstrating how to write a SharpDevelop backend binding for non-MSBuild projects"> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "CppBackendBinding.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/FileFilter"> |
||||
<FileFilter id = "C++" |
||||
insertbefore="AllFiles" |
||||
name = "C++/C files" |
||||
extensions = "*.cpp;*.h;*.c;*.h;*.hpp"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Combine/FileFilter"> |
||||
<FileFilter id = "CppProject" |
||||
insertbefore="AllFiles" |
||||
name = "Visual C++ project files (*.vcproj)" |
||||
class = "ICSharpCode.SharpDevelop.Project.LoadProject" |
||||
extensions = "*.vcproj"/> |
||||
</Path> |
||||
|
||||
<!-- |
||||
SharpDevelop doesn't support creating non-MSBuild projects from templates |
||||
(though an addin could work around that by replacing the created MSBuild project with the correct |
||||
project format immediately after it was created) |
||||
<Path name = "/SharpDevelop/BackendBindings/Templates"> |
||||
<Directory id = "ILAsm" path = "./Templates" /> |
||||
</Path> |
||||
--> |
||||
|
||||
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C++"> |
||||
<!-- TODO: project option panels --> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/LanguageBindings"> |
||||
<LanguageBinding id = "C++" |
||||
guid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" |
||||
supportedextensions = ".cpp;.c" |
||||
projectfileextension = ".vcproj" |
||||
class = "CppBackendBinding.CppLanguageBinding" /> |
||||
</Path> |
||||
</AddIn> |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{F279DD27-21A9-4D69-AAE3-00DB403257CB}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>CppBackendBinding</RootNamespace> |
||||
<AssemblyName>CppBackendBinding</AssemblyName> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
<OutputPath>..\..\AddIns\Samples\CppBinding\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="ICSharpCode.Core"> |
||||
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.Core.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.SharpDevelop"> |
||||
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.SharpDevelop.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.SharpDevelop.Dom"> |
||||
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="CppBackendBinding.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="CppLanguageBinding.cs" /> |
||||
<Compile Include="CppProject.cs" /> |
||||
<Compile Include="FileGroup.cs" /> |
||||
<Compile Include="FileItem.cs" /> |
||||
</ItemGroup> |
||||
</Project> |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00 |
||||
# Visual Studio 2008 |
||||
# SharpDevelop 3.0.0.3075 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBackendBinding", "CppBackendBinding.csproj", "{F279DD27-21A9-4D69-AAE3-00DB403257CB}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
EndGlobalSection |
||||
EndGlobal |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System.IO; |
||||
|
||||
namespace CppBackendBinding |
||||
{ |
||||
public class CppLanguageBinding : ILanguageBinding |
||||
{ |
||||
public const string LanguageName = "C++"; |
||||
|
||||
public string Language { |
||||
get { |
||||
return LanguageName; |
||||
} |
||||
} |
||||
|
||||
public IProject LoadProject(IMSBuildEngineProvider provider, string fileName, string projectName) |
||||
{ |
||||
return new CppProject(fileName, projectName); |
||||
} |
||||
|
||||
public IProject CreateProject(ProjectCreateInformation info) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,287 @@
@@ -0,0 +1,287 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Text.RegularExpressions; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace CppBackendBinding |
||||
{ |
||||
/// <summary>
|
||||
/// C++ project class. Handlings project loading and saving.
|
||||
/// </summary>
|
||||
public class CppProject : AbstractProject, IProjectItemListProvider, IProjectAllowChangeConfigurations |
||||
{ |
||||
XmlDocument document = new XmlDocument(); |
||||
List<FileGroup> groups = new List<FileGroup>(); |
||||
List<FileItem> items = new List<FileItem>(); |
||||
|
||||
/// <summary>
|
||||
/// Create a new C++ project that loads the specified .vcproj file.
|
||||
/// </summary>
|
||||
public CppProject(string fileName, string projectName) |
||||
{ |
||||
this.Name = projectName; |
||||
this.FileName = fileName; |
||||
this.TypeGuid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; |
||||
|
||||
using (StreamReader r = new StreamReader(fileName, Encoding.Default)) { |
||||
try { |
||||
document.Load(r); |
||||
} catch (Exception ex) { |
||||
throw new ProjectLoadException(ex.Message, ex); |
||||
} |
||||
} |
||||
if (document.DocumentElement.Name != "VisualStudioProject") |
||||
throw new ProjectLoadException("The project is not a visual studio project."); |
||||
XmlElement filesElement = document.DocumentElement["Files"]; |
||||
if (filesElement != null) { |
||||
foreach (XmlElement filterElement in filesElement.ChildNodes.OfType<XmlElement>()) { |
||||
if (filterElement.Name == "Filter") { |
||||
FileGroup group = new FileGroup(this, filterElement); |
||||
groups.Add(group); |
||||
foreach (XmlElement fileElement in filterElement.ChildNodes.OfType<XmlElement>()) { |
||||
if (fileElement.Name == "File" && fileElement.HasAttribute("RelativePath")) { |
||||
items.Add(new FileItem(group, fileElement)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override string Language { |
||||
get { return CppLanguageBinding.LanguageName; } |
||||
} |
||||
|
||||
public override void Save(string fileName) |
||||
{ |
||||
lock (SyncRoot) { |
||||
// file item types may have changed, so remove all items from their parent elements
|
||||
// and re-add them to the correct Filter elements
|
||||
foreach (FileItem item in items) { |
||||
item.SaveChanges(); |
||||
if (item.XmlElement.ParentNode != null) |
||||
item.XmlElement.ParentNode.RemoveChild(item.XmlElement); |
||||
} |
||||
foreach (FileItem item in items) { |
||||
FileGroup group = groups.Find(fg => fg.ItemType == item.ProjectItem.ItemType); |
||||
if (groups != null) { |
||||
group.XmlElement.AppendChild(item.XmlElement); |
||||
} else { |
||||
LoggingService.Warn("Couldn't find filter for item type " + item.ProjectItem.ItemType + ", the item was not saved!"); |
||||
} |
||||
} |
||||
document.Save(fileName); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of available file item types. This member is thread-safe.
|
||||
/// </summary>
|
||||
public override ICollection<ItemType> AvailableFileItemTypes { |
||||
get { |
||||
lock (SyncRoot) { |
||||
return groups.ConvertAll(fg => fg.ItemType).AsReadOnly(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items in the project. This member is thread-safe.
|
||||
/// The returned collection is guaranteed not to change - adding new items or removing existing items
|
||||
/// will create a new collection.
|
||||
/// </summary>
|
||||
public override ReadOnlyCollection<ProjectItem> Items { |
||||
get { |
||||
lock (SyncRoot) { |
||||
return new ReadOnlyCollection<ProjectItem>(items.ConvertAll(fi => fi.ProjectItem)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#region IProjectAllowChangeConfigurations
|
||||
// TODO: Configuration/Platform handling
|
||||
bool IProjectAllowChangeConfigurations.RenameProjectConfiguration(string oldName, string newName) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
bool IProjectAllowChangeConfigurations.RenameProjectPlatform(string oldName, string newName) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
bool IProjectAllowChangeConfigurations.AddProjectConfiguration(string newName, string copyFrom) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
bool IProjectAllowChangeConfigurations.AddProjectPlatform(string newName, string copyFrom) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
bool IProjectAllowChangeConfigurations.RemoveProjectConfiguration(string name) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
bool IProjectAllowChangeConfigurations.RemoveProjectPlatform(string name) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
#endregion
|
||||
|
||||
#region IProjectItemListProvider
|
||||
void IProjectItemListProvider.AddProjectItem(ProjectItem item) |
||||
{ |
||||
if (item == null) |
||||
throw new ArgumentNullException("item"); |
||||
lock (SyncRoot) { |
||||
if (items.Exists(fi => fi.ProjectItem == item)) |
||||
throw new ArgumentException("Project item already exists in project!"); |
||||
items.Add(new FileItem(document, item)); |
||||
} |
||||
} |
||||
|
||||
bool IProjectItemListProvider.RemoveProjectItem(ProjectItem item) |
||||
{ |
||||
lock (SyncRoot) { |
||||
return items.RemoveAll(fi => fi.ProjectItem == item) > 0; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) |
||||
{ |
||||
string commonTools = Environment.GetEnvironmentVariable("VS90COMNTOOLS"); |
||||
if (string.IsNullOrEmpty(commonTools)) { |
||||
commonTools = Environment.GetEnvironmentVariable("VS80COMNTOOLS"); |
||||
} |
||||
if (!string.IsNullOrEmpty(commonTools)) { |
||||
commonTools = Path.Combine(commonTools, "vsvars32.bat"); |
||||
if (!File.Exists(commonTools)) |
||||
commonTools = null; |
||||
} |
||||
|
||||
Process p = new Process(); |
||||
p.StartInfo.FileName = "cmd.exe"; |
||||
p.StartInfo.Arguments = "/C"; |
||||
if (commonTools != null) { |
||||
p.StartInfo.Arguments += " call \"" + commonTools + "\" &&"; |
||||
} |
||||
p.StartInfo.Arguments += " vcbuild"; |
||||
if (options.Target == BuildTarget.Build) { |
||||
// OK
|
||||
} else if (options.Target == BuildTarget.Clean) { |
||||
p.StartInfo.Arguments += " /clean"; |
||||
} else if (options.Target == BuildTarget.Rebuild) { |
||||
p.StartInfo.Arguments += " /rebuild"; |
||||
} |
||||
p.StartInfo.Arguments += " /showenv"; |
||||
p.StartInfo.Arguments += " \"" + this.FileName + "\""; |
||||
p.StartInfo.Arguments += " \"/error:Error: \""; |
||||
p.StartInfo.Arguments += " \"/warning:Warning: \""; |
||||
|
||||
p.StartInfo.WorkingDirectory = this.Directory; |
||||
p.StartInfo.RedirectStandardOutput = true; |
||||
p.StartInfo.RedirectStandardError = true; |
||||
p.StartInfo.CreateNoWindow = true; |
||||
p.StartInfo.UseShellExecute = false; |
||||
p.StartInfo.EnvironmentVariables["VCBUILD_DEFAULT_CFG"] = options.Configuration + "|" + options.Platform; |
||||
|
||||
p.EnableRaisingEvents = true; |
||||
p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { |
||||
if (!string.IsNullOrEmpty(e.Data)) { |
||||
BuildError error = ParseError(e.Data); |
||||
if (error != null) |
||||
feedbackSink.ReportError(error); |
||||
else |
||||
feedbackSink.ReportMessage(e.Data); |
||||
} |
||||
}; |
||||
p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) { |
||||
if (!string.IsNullOrEmpty(e.Data)) { |
||||
BuildError error = ParseError(e.Data); |
||||
if (error != null) |
||||
feedbackSink.ReportError(error); |
||||
else |
||||
feedbackSink.ReportError(new BuildError(null, e.Data)); |
||||
} |
||||
}; |
||||
p.Exited += delegate(object sender, EventArgs e) { |
||||
p.CancelErrorRead(); |
||||
p.CancelOutputRead(); |
||||
feedbackSink.Done(p.ExitCode == 0); |
||||
p.Dispose(); |
||||
}; |
||||
|
||||
feedbackSink.ReportMessage("Building " + this.Name); |
||||
feedbackSink.ReportMessage(p.StartInfo.FileName + " " + p.StartInfo.Arguments); |
||||
p.Start(); |
||||
p.BeginOutputReadLine(); |
||||
p.BeginErrorReadLine(); |
||||
} |
||||
|
||||
static readonly Regex errorRegex = new Regex(@"^Error: " + |
||||
@"([^(:]+?)" + // group 1: file name
|
||||
@"(?:\((\d+)\))?" + // group 2: line number
|
||||
@"\s*:\s*" + // first separator
|
||||
@"(?:error ([^:]+):)?" + // group 3: error code
|
||||
@"\s*(.*)$" // group 4: error message
|
||||
); |
||||
|
||||
|
||||
static readonly Regex warningRegex = new Regex(@"^(?:\d+\>)?Warning: " + |
||||
@"([^(:]+?)" + // group 1: file name
|
||||
@"(?:\((\d+)\))?" + // group 2: line number
|
||||
@"\s*:\s*" + // first separator
|
||||
@"(?:warning ([^:]+):)?" + // group 3: error code
|
||||
@"\s*(.*)$" // group 4: error message
|
||||
); |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Parses an error or warning message and returns a BuildError object for it.
|
||||
/// </summary>
|
||||
BuildError ParseError(string text) |
||||
{ |
||||
bool isWarning = false; |
||||
Match match = errorRegex.Match(text); |
||||
if (!match.Success) { |
||||
match = warningRegex.Match(text); |
||||
isWarning = true; |
||||
} |
||||
if (match.Success) { |
||||
int line = -1; |
||||
try { |
||||
if (match.Groups[2].Length > 0) { |
||||
line = int.Parse(match.Groups[2].Value); |
||||
} |
||||
} catch (FormatException) { |
||||
} catch (OverflowException) { |
||||
} |
||||
return new BuildError(Path.Combine(Directory, match.Groups[1].Value), line, 0, |
||||
match.Groups[3].Value, match.Groups[4].Value) { |
||||
IsWarning = isWarning |
||||
}; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace CppBackendBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a {Filter} element in the .vcproj file.
|
||||
/// </summary>
|
||||
sealed class FileGroup |
||||
{ |
||||
public readonly CppProject Project; |
||||
public readonly ItemType ItemType; |
||||
public readonly string[] Extensions; |
||||
public readonly XmlElement XmlElement; |
||||
|
||||
public FileGroup(CppProject project, XmlElement filterElement) |
||||
{ |
||||
this.Project = project; |
||||
this.XmlElement = filterElement; |
||||
switch (filterElement.GetAttribute("UniqueIdentifier")) { |
||||
case "{4FC737F1-C7A5-4376-A066-2A32D752A2FF}": |
||||
ItemType = ItemType.Compile; |
||||
break; |
||||
case "{93995380-89BD-4b04-88EB-625FBE52EBFB}": |
||||
ItemType = ItemType.Header; |
||||
break; |
||||
case "{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}": |
||||
ItemType = ItemType.Resource; |
||||
break; |
||||
default: |
||||
ItemType = new ItemType(filterElement.GetAttribute("Name")); |
||||
break; |
||||
} |
||||
Extensions = filterElement.GetAttribute("Filter").Split(';'); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace CppBackendBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a {File} element in the .vcproj file.
|
||||
/// </summary>
|
||||
sealed class FileItem |
||||
{ |
||||
public readonly ProjectItem ProjectItem; |
||||
public readonly XmlElement XmlElement; |
||||
|
||||
/// <summary>
|
||||
/// Loads a file item from XML.
|
||||
/// </summary>
|
||||
public FileItem(FileGroup group, XmlElement fileElement) |
||||
{ |
||||
this.XmlElement = fileElement; |
||||
string relativePath = fileElement.GetAttribute("RelativePath"); |
||||
if (relativePath.StartsWith(".\\")) { |
||||
// SharpDevelop doesn't like paths starting with ".\", so strip it away:
|
||||
relativePath = relativePath.Substring(2); |
||||
} |
||||
this.ProjectItem = new FileProjectItem(group.Project, group.ItemType, relativePath); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new file item.
|
||||
/// </summary>
|
||||
public FileItem(XmlDocument document, ProjectItem item) |
||||
{ |
||||
this.ProjectItem = item; |
||||
this.XmlElement = document.CreateElement("File"); |
||||
SaveChanges(); |
||||
} |
||||
|
||||
public void SaveChanges() |
||||
{ |
||||
this.XmlElement.SetAttribute("RelativePath", this.ProjectItem.Include); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Runtime.Serialization; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project |
||||
{ |
||||
/// <summary>
|
||||
/// Exception used when loading of a project fails.
|
||||
/// </summary>
|
||||
[Serializable()] |
||||
public class ProjectLoadException : Exception |
||||
{ |
||||
public ProjectLoadException() : base() |
||||
{ |
||||
} |
||||
|
||||
public ProjectLoadException(string message) : base(message) |
||||
{ |
||||
} |
||||
|
||||
public ProjectLoadException(string message, Exception innerException) : base(message, innerException) |
||||
{ |
||||
} |
||||
|
||||
protected ProjectLoadException(SerializationInfo info, StreamingContext context) : base(info, context) |
||||
{ |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue