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 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -14,7 +15,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
@ -166,22 +166,41 @@ namespace CppBackendBinding
} }
#endregion #endregion
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) static string GetFile(string filename)
{ {
string commonTools = Environment.GetEnvironmentVariable("VS90COMNTOOLS"); filename = Environment.ExpandEnvironmentVariables(filename);
if (string.IsNullOrEmpty(commonTools)) { if (File.Exists(filename))
commonTools = Environment.GetEnvironmentVariable("VS80COMNTOOLS"); return filename;
} else
if (!string.IsNullOrEmpty(commonTools)) { return null;
commonTools = Path.Combine(commonTools, "vsvars32.bat"); }
if (!File.Exists(commonTools))
commonTools = 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(); Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/C"; p.StartInfo.Arguments = "/C";
if (commonTools != null) { if (!string.IsNullOrEmpty(commonTools)) {
p.StartInfo.Arguments += " call \"" + commonTools + "\" &&"; p.StartInfo.Arguments += " call \"" + commonTools + "\" &&";
} }
p.StartInfo.Arguments += " vcbuild"; p.StartInfo.Arguments += " vcbuild";
@ -210,8 +229,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) {
@ -219,8 +238,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) {
@ -238,7 +257,7 @@ namespace CppBackendBinding
} }
static readonly Regex errorRegex = new Regex(@"^Error: " + static readonly Regex errorRegex = new Regex(@"^Error: " +
@"([^(:]+?)" + // group 1: file name @"((?:[^(:]|:\\)+)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number @"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator @"\s*:\s*" + // first separator
@"(?:error ([^:]+):)?" + // group 3: error code @"(?:error ([^:]+):)?" + // group 3: error code
@ -247,7 +266,7 @@ namespace CppBackendBinding
static readonly Regex warningRegex = new Regex(@"^(?:\d+\>)?Warning: " + static readonly Regex warningRegex = new Regex(@"^(?:\d+\>)?Warning: " +
@"([^(:]+?)" + // group 1: file name @"((?:[^(:]|:\\)+)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number @"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator @"\s*:\s*" + // first separator
@"(?:warning ([^:]+):)?" + // group 3: error code @"(?:warning ([^:]+):)?" + // group 3: error code

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

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

Loading…
Cancel
Save