Browse Source

Handling msbuild4 projects with target platform other than AnyCPU

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4404 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Tomasz Tretkowski 16 years ago
parent
commit
0762a4924b
  1. BIN
      data/resources/StringResources.pl.resources
  2. 32
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd
  3. 5
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs
  4. 1
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs
  5. 2
      src/Main/Base/Project/Src/Project/CompilableProject.cs
  6. 4
      src/Main/Base/Project/Src/Project/Items/ItemType.cs
  7. 11
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  8. 2
      src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs
  9. 83
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  10. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.pl.resources

Binary file not shown.

32
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
<?xml version="1.0"?>
<!-- syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger -->
<!-- syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger
this should be rewritten to xshd v2.0 syntax to handle c++/cli keywords with whitespaces properly -->
<SyntaxDefinition name = "C++.NET" extensions = ".c;.h;.cc;.cpp;.hpp">
@ -85,6 +86,35 @@ @@ -85,6 +86,35 @@
<Key word = "__unhook" />
<Key word = "__interface" />
<!-- c++/cli new syntax managed keywords //-->
<Key word = "ref class" />
<Key word = "ref struct" />
<Key word = "value class" />
<Key word = "value struct" />
<Key word = "interface class" />
<Key word = "interface struct" />
<Key word = "enum class" />
<Key word = "enum struct" />
<Key word = "delegate" />
<Key word = "event" />
<Key word = "property" />
<Key word = "abstract" />
<Key word = "override" />
<Key word = "sealed" />
<Key word = "generic" />
<Key word = "where" />
<Key word = "finally" />
<Key word = "for each" />
<Key word = "gcnew" />
<Key word = "in" />
<Key word = "initonly" />
<Key word = "literal" />
<Key word = "nullptr" />
</KeyWords>
<KeyWords name = "AccessKeywords" bold="true" italic="false" color="Black">

5
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs

@ -24,11 +24,16 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -24,11 +24,16 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
{
internal List<IProject> createdProjects = new List<IProject>();
public ProjectCreateInformation() {
Platform = "AnyCPU";
}
public ReadOnlyCollection<IProject> CreatedProjects {
get { return createdProjects.AsReadOnly(); }
}
public string OutputProjectFileName { get; set; }
public string Platform { get; set; }
public string ProjectName { get; set; }
public string SolutionName { get; set; }
public string RootNamespace { get; set; }

1
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs

@ -376,6 +376,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -376,6 +376,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
string solutionLocation = projectCreateInformation.Solution.FileName;
if (createNewSolution) {
projectCreateInformation.Solution.AddFolder(project);
projectCreateInformation.Solution.FixSolutionConfiguration(new IProject[] {project});
projectCreateInformation.Solution.Save();
ProjectService.OnSolutionCreated(new SolutionEventArgs(projectCreateInformation.Solution));
projectCreateInformation.Solution.Dispose();

2
src/Main/Base/Project/Src/Project/CompilableProject.cs

@ -185,7 +185,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -185,7 +185,7 @@ namespace ICSharpCode.SharpDevelop.Project
public OutputType OutputType {
get {
try {
return (OutputType)Enum.Parse(typeof(OutputType), GetEvaluatedProperty("OutputType") ?? "Exe");
return (OutputType)Enum.Parse(typeof(OutputType), GetEvaluatedProperty("OutputType") ?? "Exe", true);
} catch (ArgumentException) {
return OutputType.Exe;
}

4
src/Main/Base/Project/Src/Project/Items/ItemType.cs

@ -42,6 +42,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -42,6 +42,10 @@ namespace ICSharpCode.SharpDevelop.Project
public static readonly ItemType BootstrapperFile = new ItemType("BootstrapperFile");
public static readonly ItemType Header = new ItemType("Header");
// vcxproj-only (c++ project) items
public static readonly ItemType ClCompile = new ItemType("ClCompile");
public static readonly ItemType ClInclude = new ItemType("ClInclude");
/// <summary>
/// Gets a collection of item types that are used for files.
/// </summary>

11
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -178,6 +178,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -178,6 +178,7 @@ namespace ICSharpCode.SharpDevelop.Project
this.projectCollection = information.Solution.MSBuildProjectCollection;
this.projectFile = ProjectRootElement.Create(projectCollection);
this.userProjectFile = ProjectRootElement.Create(projectCollection);
this.ActivePlatform = information.Platform;
Name = information.ProjectName;
FileName = information.OutputProjectFileName;
@ -190,10 +191,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -190,10 +191,10 @@ namespace ICSharpCode.SharpDevelop.Project
base.IdGuid = "{" + Guid.NewGuid().ToString().ToUpperInvariant() + "}";
projectFile.AddProperty(ProjectGuidPropertyName, IdGuid);
AddGuardedProperty("Configuration", "Debug");
AddGuardedProperty("Platform", "AnyCPU");
AddGuardedProperty("Platform", information.Platform);
this.ActiveConfiguration = "Debug";
this.ActivePlatform = "AnyCPU";
this.ActivePlatform = information.Platform;
}
/// <summary>
@ -394,7 +395,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -394,7 +395,10 @@ namespace ICSharpCode.SharpDevelop.Project
Dictionary<string, string> globalProps = new Dictionary<string, string>();
InitializeMSBuildProjectProperties(globalProps);
globalProps["Configuration"] = configuration;
globalProps["Platform"] = platform;
//HACK: the ActivePlatform property should be set properly before entering here, but sometimes it does not
if (platform != null)
globalProps["Platform"] = platform;
MSBuild.Project project = MSBuildInternals.LoadProject(projectCollection, projectFile, globalProps);
if (openCurrentConfiguration)
currentlyOpenProject = project;
@ -1101,6 +1105,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1101,6 +1105,7 @@ namespace ICSharpCode.SharpDevelop.Project
{
this.projectCollection = loadInformation.ParentSolution.MSBuildProjectCollection;
this.FileName = loadInformation.FileName;
this.ActivePlatform = loadInformation.Platform;
//try {
projectFile = ProjectRootElement.Open(loadInformation.FileName, projectCollection);

2
src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs

@ -17,8 +17,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -17,8 +17,10 @@ namespace ICSharpCode.SharpDevelop.Project
{
public Solution ParentSolution { get; private set; }
public string FileName { get; private set; }
public string Platform { get; internal set; }
public string ProjectName { get; private set; }
public string TypeGuid { get; set; }
internal string Guid { get; set; }
public Gui.IProgressMonitor ProgressMonitor { get; set; }
public ProjectLoadInformation(Solution parentSolution, string fileName, string projectName)

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

@ -508,6 +508,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -508,6 +508,10 @@ namespace ICSharpCode.SharpDevelop.Project
string solutionDirectory = Path.GetDirectoryName(newSolution.FileName);
ProjectSection nestedProjectsSection = null;
IList<ProjectLoadInformation> projectsToLoad = new List<ProjectLoadInformation>();
IList<IList<ProjectSection>> readProjectSections = new List<IList<ProjectSection>>();
// process the solution file contents
while (true) {
string line = sr.ReadLine();
@ -531,11 +535,16 @@ namespace ICSharpCode.SharpDevelop.Project @@ -531,11 +535,16 @@ namespace ICSharpCode.SharpDevelop.Project
} else {
ProjectLoadInformation loadInfo = new ProjectLoadInformation(newSolution, location, title);
loadInfo.TypeGuid = projectGuid;
loadInfo.ProgressMonitor = progressMonitor;
IProject newProject = LanguageBindingService.LoadProject(loadInfo);
ReadProjectSections(sr, newProject.ProjectSections);
newProject.IdGuid = guid;
newSolution.AddFolder(newProject);
loadInfo.Guid = guid;
// loadInfo.ProgressMonitor = progressMonitor;
// IProject newProject = LanguageBindingService.LoadProject(loadInfo);
// newProject.IdGuid = guid;
projectsToLoad.Add(loadInfo);
IList<ProjectSection> currentProjectSections = new List<ProjectSection>();
ReadProjectSections(sr, currentProjectSections);
readProjectSections.Add(currentProjectSections);
// newSolution.AddFolder(newProject);
}
match = match.NextMatch();
} else {
@ -553,6 +562,21 @@ namespace ICSharpCode.SharpDevelop.Project @@ -553,6 +562,21 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
}
// load projects
for(int i=0; i<projectsToLoad.Count; i++) {
ProjectLoadInformation loadInfo = projectsToLoad[i];
IList<ProjectSection> projectSections = readProjectSections[i];
// set the target platform
SolutionItem projectConfig = newSolution.GetProjectConfiguration(loadInfo.Guid);
loadInfo.Platform = AbstractProject.GetPlatformNameFromKey(projectConfig.Location);
loadInfo.ProgressMonitor = progressMonitor;
IProject newProject = LanguageBindingService.LoadProject(loadInfo);
newProject.IdGuid = loadInfo.Guid;
newProject.ProjectSections.AddRange(projectSections);
newSolution.AddFolder(newProject);
}
return nestedProjectsSection;
}
#endregion
@ -636,39 +660,50 @@ namespace ICSharpCode.SharpDevelop.Project @@ -636,39 +660,50 @@ namespace ICSharpCode.SharpDevelop.Project
return newSec;
}
public SolutionItem GetProjectConfiguration(string guid) {
ProjectSection projectConfigSection = GetProjectConfigurationsSection();
SolutionItem foundItem = projectConfigSection.Items.Find(item => item.Name.StartsWith(guid));
if (foundItem != null)
return foundItem;
LoggingService.Warn("No configuration for project "+guid + "using default.");
return new SolutionItem("Debug|Any CPU", "Debug|Any CPU");
}
public bool FixSolutionConfiguration(IEnumerable<IProject> projects)
{
ProjectSection solSec = GetSolutionConfigurationsSection();
ProjectSection prjSec = GetProjectConfigurationsSection();
bool changed = false;
if (solSec.Items.Count == 0) {
solSec.Items.Add(new SolutionItem("Debug|Any CPU", "Debug|Any CPU"));
solSec.Items.Add(new SolutionItem("Release|Any CPU", "Release|Any CPU"));
LoggingService.Warn("!! Inserted default SolutionConfigurationPlatforms !!");
changed = true;
}
Set<string> configurations = new Set<string>();
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));
string platform = FixPlatformNameForSolution(project.ActivePlatform);
foreach (string configuration in new string[]{"Debug", "Release"}) {
string key = configuration + "|" + platform;
configurations.Add(key);
string searchKey = guid + "." + key + ".Build.0";
if (!prjSec.Items.Exists(item => item.Name == searchKey)) {
prjSec.Items.Add(new SolutionItem(searchKey, key));
changed = true;
}
searchKey = guid + "." + configuration.Name + ".ActiveCfg";
if (!prjSec.Items.Exists(delegate (SolutionItem item) {
return item.Name == searchKey;
}))
{
prjSec.Items.Add(new SolutionItem(searchKey, configuration.Location));
searchKey = guid + "." + key + ".ActiveCfg";
if (!prjSec.Items.Exists(item => item.Name == searchKey)) {
prjSec.Items.Add(new SolutionItem(searchKey, key));
changed = true;
}
}
}
foreach (string key in configurations) {
if (!solSec.Items.Exists(item => item.Location == key && item.Name == key)) {
solSec.Items.Add(new SolutionItem(key, key));
changed = true;
}
}
// remove all configuration entries belonging to removed projects
prjSec.Items.RemoveAll(
item => {

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save