Browse Source

Support building C++ projects using Windows SDK 6.1.

Solution.GetActiveConfigurationsAndPlatformsForProjects: Use .ActiveCfg entry instead of .Build.0 entry.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3214 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
b7cab5f225
  1. 53
      samples/CppBackendBinding/CppProject.cs
  2. 40
      src/Main/Base/Project/Src/Project/Solution/Solution.cs

53
samples/CppBackendBinding/CppProject.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -14,7 +15,6 @@ using System.Linq; @@ -14,7 +15,6 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
@ -166,22 +166,41 @@ namespace CppBackendBinding @@ -166,22 +166,41 @@ namespace CppBackendBinding
}
#endregion
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
static string GetFile(string filename)
{
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;
filename = Environment.ExpandEnvironmentVariables(filename);
if (File.Exists(filename))
return filename;
else
return null;
}
static string GetPathFromRegistry(string key, string valueName)
{
using (RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey(key)) {
if (installRootKey != null) {
object o = installRootKey.GetValue(valueName);
if (o != null) {
string r = o.ToString();
if (!string.IsNullOrEmpty(r))
return r;
}
}
}
return null;
}
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
{
string commonTools =
GetFile(Path.Combine(GetPathFromRegistry(@"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC", "ProductDir"), "bin\\vcvars32.bat"))
?? GetFile("%VS90COMNTOOLS%\\vsvars32.bat")
?? GetFile("%VS80COMNTOOLS%\\vsvars32.bat");
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/C";
if (commonTools != null) {
if (!string.IsNullOrEmpty(commonTools)) {
p.StartInfo.Arguments += " call \"" + commonTools + "\" &&";
}
p.StartInfo.Arguments += " vcbuild";
@ -210,8 +229,8 @@ namespace CppBackendBinding @@ -210,8 +229,8 @@ namespace CppBackendBinding
BuildError error = ParseError(e.Data);
if (error != null)
feedbackSink.ReportError(error);
else
feedbackSink.ReportMessage(e.Data);
// else
feedbackSink.ReportMessage(e.Data);
}
};
p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) {
@ -219,8 +238,8 @@ namespace CppBackendBinding @@ -219,8 +238,8 @@ namespace CppBackendBinding
BuildError error = ParseError(e.Data);
if (error != null)
feedbackSink.ReportError(error);
else
feedbackSink.ReportError(new BuildError(null, e.Data));
// else
feedbackSink.ReportError(new BuildError(null, e.Data));
}
};
p.Exited += delegate(object sender, EventArgs e) {
@ -238,7 +257,7 @@ namespace CppBackendBinding @@ -238,7 +257,7 @@ namespace CppBackendBinding
}
static readonly Regex errorRegex = new Regex(@"^Error: " +
@"([^(:]+?)" + // group 1: file name
@"((?:[^(:]|:\\)+)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator
@"(?:error ([^:]+):)?" + // group 3: error code
@ -247,7 +266,7 @@ namespace CppBackendBinding @@ -247,7 +266,7 @@ namespace CppBackendBinding
static readonly Regex warningRegex = new Regex(@"^(?:\d+\>)?Warning: " +
@"([^(:]+?)" + // group 1: file name
@"((?:[^(:]|:\\)+)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator
@"(?:warning ([^:]+):)?" + // group 3: error code

40
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -654,15 +654,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -654,15 +654,7 @@ namespace ICSharpCode.SharpDevelop.Project
foreach (IProject project in projects) {
string guid = project.IdGuid.ToUpperInvariant();
foreach (SolutionItem configuration in solSec.Items) {
string searchKey = guid + "." + configuration.Name + ".Build.0";
if (!prjSec.Items.Exists(delegate (SolutionItem item) {
return item.Name == searchKey;
}))
{
prjSec.Items.Add(new SolutionItem(searchKey, configuration.Location));
changed = true;
}
searchKey = guid + "." + configuration.Name + ".ActiveCfg";
string searchKey = guid + "." + configuration.Name + ".ActiveCfg";
if (!prjSec.Items.Exists(delegate (SolutionItem item) {
return item.Name == searchKey;
}))
@ -757,11 +749,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -757,11 +749,11 @@ namespace ICSharpCode.SharpDevelop.Project
if (this.SolutionItem == null)
return;
string oldName = this.SolutionItem.Name;
this.SolutionItem.Name = this.Project.IdGuid + "." + newConfiguration + "|" + newPlatform + ".Build.0";
this.SolutionItem.Name = this.Project.IdGuid + "." + newConfiguration + "|" + newPlatform + ".ActiveCfg";
string newName = this.SolutionItem.Name;
if (StripBuild0(ref oldName) && StripBuild0(ref newName)) {
oldName += ".ActiveCfg";
newName += ".ActiveCfg";
if (StripActiveCfg(ref oldName) && StripActiveCfg(ref newName)) {
oldName += ".Build.0";
newName += ".Build.0";
foreach (SolutionItem item in section.Items) {
if (item.Name == oldName)
item.Name = newName;
@ -777,8 +769,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -777,8 +769,8 @@ namespace ICSharpCode.SharpDevelop.Project
return;
this.SolutionItem.Location = newConfiguration + "|" + newPlatform;
string thisName = this.SolutionItem.Name;
if (StripBuild0(ref thisName)) {
thisName += ".ActiveCfg";
if (StripActiveCfg(ref thisName)) {
thisName += ".Build.0";
foreach (SolutionItem item in section.Items) {
if (item.Name == thisName)
item.Location = this.SolutionItem.Location;
@ -786,10 +778,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -786,10 +778,10 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
internal static bool StripBuild0(ref string s)
internal static bool StripActiveCfg(ref string s)
{
if (s.EndsWith(".Build.0")) {
s = s.Substring(0, s.Length - ".Build.0".Length);
if (s.EndsWith(".ActiveCfg")) {
s = s.Substring(0, s.Length - ".ActiveCfg".Length);
return true;
} else {
return false;
@ -806,7 +798,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -806,7 +798,7 @@ namespace ICSharpCode.SharpDevelop.Project
foreach (SolutionItem item in prjSec.Items) {
dict[item.Name] = item;
}
string searchKeyPostFix = "." + solutionConfiguration + "|" + solutionPlatform + ".Build.0";
string searchKeyPostFix = "." + solutionConfiguration + "|" + solutionPlatform + ".ActiveCfg";
foreach (IProject p in Projects) {
string searchKey = p.IdGuid + searchKeyPostFix;
SolutionItem solutionItem;
@ -828,11 +820,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -828,11 +820,11 @@ namespace ICSharpCode.SharpDevelop.Project
internal SolutionItem CreateMatchingItem(string solutionConfiguration, string solutionPlatform, IProject project, string initialLocation)
{
GetProjectConfigurationsSection().Items.Add(new SolutionItem(project.IdGuid + "." + solutionConfiguration + "|"
+ solutionPlatform + ".Build.0", initialLocation));
SolutionItem item = new SolutionItem(project.IdGuid + "." + solutionConfiguration + "|"
+ solutionPlatform + ".Build.0", initialLocation);
+ solutionPlatform + ".ActiveCfg", initialLocation);
GetProjectConfigurationsSection().Items.Add(item);
GetProjectConfigurationsSection().Items.Add(new SolutionItem(project.IdGuid + "." + solutionConfiguration + "|"
+ solutionPlatform + ".ActiveCfg", initialLocation));
return item;
}
#endregion
@ -997,14 +989,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -997,14 +989,14 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Gets the configuration|platform name from a conf item, e.g.
/// "Release|Any CPU" from
/// "{7115F3A9-781C-4A95-90AE-B5AB53C4C588}.Release|Any CPU.Build.0"
/// "{7115F3A9-781C-4A95-90AE-B5AB53C4C588}.Release|Any CPU.ActiveCfg"
/// </summary>
static string GetKeyFromProjectConfItem(string name)
{
int pos = name.IndexOf('.');
if (pos < 0) return null;
name = name.Substring(pos + 1);
if (!ProjectConfigurationPlatformMatching.StripBuild0(ref name)) {
if (!ProjectConfigurationPlatformMatching.StripActiveCfg(ref name)) {
pos = name.LastIndexOf('.');
if (pos < 0) return null;
name = name.Substring(0, pos);

Loading…
Cancel
Save