Browse Source

Add "AnyCPU (32-bit preferred)" option.

This option is only available if .NET 4.5 is installed.
pull/31/head
Daniel Grunwald 13 years ago
parent
commit
2c4b5da6a8
  1. 6
      data/resources/StringResources.resx
  2. 7
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildAdvanced.xaml
  3. 74
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildAdvanced.xaml.cs

6
data/resources/StringResources.resx

@ -2437,6 +2437,12 @@ system. I don't think that it needs translation.</comment>
<data name="Dialog.ProjectOptions.Build.TargetCPU.Any" xml:space="preserve"> <data name="Dialog.ProjectOptions.Build.TargetCPU.Any" xml:space="preserve">
<value>Any processor</value> <value>Any processor</value>
</data> </data>
<data name="Dialog.ProjectOptions.Build.TargetCPU.Any32" xml:space="preserve">
<value>Any processor (prefer 32-bit)</value>
</data>
<data name="Dialog.ProjectOptions.Build.TargetCPU.Any64" xml:space="preserve">
<value>Any processor (prefer 64-bit)</value>
</data>
<data name="Dialog.ProjectOptions.Build.TargetCPU.Itanium" xml:space="preserve"> <data name="Dialog.ProjectOptions.Build.TargetCPU.Itanium" xml:space="preserve">
<value>Intel 64-bit Itanium processor</value> <value>Intel 64-bit Itanium processor</value>
</data> </data>

7
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildAdvanced.xaml

@ -35,6 +35,7 @@
<Binding Path="RegisterForComInterop.Location" /> <Binding Path="RegisterForComInterop.Location" />
<Binding Path="GenerateSerializationAssemblies.Location" /> <Binding Path="GenerateSerializationAssemblies.Location" />
<Binding Path="PlatformTarget.Location" /> <Binding Path="PlatformTarget.Location" />
<Binding Path="Prefer32Bit.Location" />
<Binding Path="FileAlignment.Location" /> <Binding Path="FileAlignment.Location" />
<Binding Path="BaseAddress.Location" /> <Binding Path="BaseAddress.Location" />
</MultiBinding> </MultiBinding>
@ -61,10 +62,10 @@
<Label Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" <Label Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right"
Content="{core:Localize Dialog.ProjectOptions.Build.TargetCPU}"></Label> Content="{core:Localize Dialog.ProjectOptions.Build.TargetCPU}"></Label>
<!--x:Name="targetCpuComboBox"--> <ComboBox x:Name="targetCpuComboBox"
<ComboBox Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center"
ItemsSource="{Binding Path=DataContext.TargetCPU}" ItemsSource="{Binding Path=DataContext.TargetCPU}"
SelectedValue="{Binding Path=PlatformTarget.Value}" SelectionChanged="TargetCpuComboBox_SelectionChanged"
DisplayMemberPath="DisplayValue" DisplayMemberPath="DisplayValue"
SelectedValuePath="Key"></ComboBox> SelectedValuePath="Key"></ComboBox>

74
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/BuildAdvanced.xaml.cs

@ -16,9 +16,9 @@ using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Converter;
using ICSharpCode.SharpDevelop.Widgets; using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
@ -33,26 +33,44 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
private System.Windows.Input.ICommand baseIntermediateOutputPathCommand; private System.Windows.Input.ICommand baseIntermediateOutputPathCommand;
private System.Windows.Input.ICommand intermediateOutputPathCommand; private System.Windows.Input.ICommand intermediateOutputPathCommand;
private ProjectOptionPanel projectOptions; private ProjectOptionPanel projectOptions;
bool supports32BitPreferred;
public BuildAdvanced() public BuildAdvanced()
{ {
InitializeComponent(); InitializeComponent();
InitializeCombos();
this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute); this.BaseIntermediateOutputPathCommand = new RelayCommand(BaseIntermediateOutputPathExecute);
this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute); this.IntermediateOutputPathCommand = new RelayCommand(IntermediateOutputPathExecute);
this.DataContext = this; this.DataContext = this;
} }
void InitializeCombos() public void Initialize (ProjectOptionPanel projectOptions)
{ {
if (projectOptions == null) {
throw new ArgumentNullException("projectOptions");
}
this.projectOptions = projectOptions;
projectOptions.RegisterLoadSaveCallback(this);
this.SerializationInfo = new List<KeyItemPair>(); this.SerializationInfo = new List<KeyItemPair>();
this.SerializationInfo.Add(new KeyItemPair("Off", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Off}"))); this.SerializationInfo.Add(new KeyItemPair("Off", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Off}")));
this.SerializationInfo.Add(new KeyItemPair("On", StringParser.Parse("${res:Dialog.ProjectOptions.Build.On}"))); this.SerializationInfo.Add(new KeyItemPair("On", StringParser.Parse("${res:Dialog.ProjectOptions.Build.On}")));
this.SerializationInfo.Add(new KeyItemPair("Auto", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Auto}"))); this.SerializationInfo.Add(new KeyItemPair("Auto", StringParser.Parse("${res:Dialog.ProjectOptions.Build.Auto}")));
this.TargetCPU = new List<KeyItemPair>(); this.TargetCPU = new List<KeyItemPair>();
this.TargetCPU.Add(new KeyItemPair("AnyCPU", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any}"))); supports32BitPreferred = false;
if (DotnetDetection.IsDotnet45Installed()) {
supports32BitPreferred = projectOptions.Project.MinimumSolutionVersion >= Solution.SolutionVersionVS2010;
var compilableProject = projectOptions.Project as CompilableProject;
if (compilableProject != null && compilableProject.OutputType == OutputType.Library)
supports32BitPreferred = false;
}
if (supports32BitPreferred) {
this.TargetCPU.Add(new KeyItemPair("AnyCPU32", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any32}")));
this.TargetCPU.Add(new KeyItemPair("AnyCPU64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any64}")));
} else {
this.TargetCPU.Add(new KeyItemPair("AnyCPU", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Any}")));
}
this.TargetCPU.Add(new KeyItemPair("x86", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x86}"))); this.TargetCPU.Add(new KeyItemPair("x86", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x86}")));
this.TargetCPU.Add(new KeyItemPair("x64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x64}"))); this.TargetCPU.Add(new KeyItemPair("x64", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.x64}")));
this.TargetCPU.Add(new KeyItemPair("Itanium", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Itanium}"))); this.TargetCPU.Add(new KeyItemPair("Itanium", StringParser.Parse("${res:Dialog.ProjectOptions.Build.TargetCPU.Itanium}")));
@ -65,18 +83,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
this.FileAlign.Add(new KeyItemPair("8192", "8192")); this.FileAlign.Add(new KeyItemPair("8192", "8192"));
} }
#region IProjectUserControl
public void Initialize (ProjectOptionPanel projectOptions)
{
if (projectOptions == null) {
throw new ArgumentNullException("projectOptions");
}
this.projectOptions = projectOptions;
projectOptions.RegisterLoadSaveCallback(this);
}
public void Load(MSBuildBasedProject project, string configuration, string platform) public void Load(MSBuildBasedProject project, string configuration, string platform)
{ {
int val; int val;
@ -84,6 +90,20 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
val = 0x400000; val = 0x400000;
} }
DllBaseAddress = "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo); DllBaseAddress = "0x" + val.ToString("x", NumberFormatInfo.InvariantInfo);
if (supports32BitPreferred && string.Equals(this.PlatformTarget.Value, "AnyCPU", StringComparison.OrdinalIgnoreCase)) {
bool default32BitPreferred = false;
var upgradableProject = projectOptions.Project as IUpgradableProject;
if (upgradableProject != null && upgradableProject.CurrentTargetFramework.IsBasedOn(TargetFramework.Net45)) {
default32BitPreferred = true;
}
if (Prefer32Bit.Value ?? default32BitPreferred)
targetCpuComboBox.SelectedValue = "AnyCPU32";
else
targetCpuComboBox.SelectedValue = "AnyCPU64";
} else {
targetCpuComboBox.SelectedValue = this.PlatformTarget.Value;
}
} }
public bool Save(MSBuildBasedProject project, string configuration, string platform) public bool Save(MSBuildBasedProject project, string configuration, string platform)
@ -98,14 +118,28 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
int val; int val;
if (int.TryParse(dllBaseAddressWithoutHexPrefix, style, NumberFormatInfo.InvariantInfo, out val)) { if (int.TryParse(dllBaseAddressWithoutHexPrefix, style, NumberFormatInfo.InvariantInfo, out val)) {
BaseAddress.Value = val.ToString(NumberFormatInfo.InvariantInfo); BaseAddress.Value = val.ToString(NumberFormatInfo.InvariantInfo);
return true;
} else { } else {
MessageService.ShowMessage("${res:Dialog.ProjectOptions.PleaseEnterValidNumber}"); MessageService.ShowMessage("${res:Dialog.ProjectOptions.PleaseEnterValidNumber}");
return false; return false;
} }
// targetCPU is saved in targetCPUCombobox_SelectionChanged
return true;
} }
#endregion void TargetCpuComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (string.Equals((string)targetCpuComboBox.SelectedValue, "AnyCPU32", StringComparison.OrdinalIgnoreCase)) {
this.PlatformTarget.Value = "AnyCPU";
this.Prefer32Bit.Value = true;
} else if (string.Equals((string)targetCpuComboBox.SelectedValue, "AnyCPU64", StringComparison.OrdinalIgnoreCase)) {
this.PlatformTarget.Value = "AnyCPU";
this.Prefer32Bit.Value = false;
} else {
this.PlatformTarget.Value = (string)targetCpuComboBox.SelectedValue;
this.Prefer32Bit.Value = null;
}
}
#region Properies #region Properies
@ -137,7 +171,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
} }
public ProjectOptionPanel.ProjectProperty<string> BaseAddress { public ProjectOptionPanel.ProjectProperty<string> BaseAddress {
get {return projectOptions.GetProperty("BaseAddress","1000", get {return projectOptions.GetProperty("BaseAddress","",
TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); } TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); }
} }

Loading…
Cancel
Save