IDE: Update target processor list and assembly style selections based on CPU type. Issues #20310 and #20311

git-svn-id: trunk@42758 -
This commit is contained in:
juha 2013-09-12 20:10:26 +00:00
parent 5c1f0c896b
commit 41601dd2fc
4 changed files with 228 additions and 134 deletions

View File

@ -10,18 +10,18 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
DesignTop = 284
object grpConfigFile: TGroupBox
Left = 0
Height = 102
Height = 106
Top = 0
Width = 594
Align = alTop
AutoSize = True
Caption = 'grpConfigFile'
ClientHeight = 83
ClientHeight = 86
ClientWidth = 590
TabOrder = 0
object chkConfigFile: TCheckBox
Left = 6
Height = 21
Height = 22
Top = 6
Width = 578
Align = alTop
@ -33,8 +33,8 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
end
object chkCustomConfigFile: TCheckBox
Left = 6
Height = 21
Top = 30
Height = 22
Top = 31
Width = 578
Align = alTop
BorderSpacing.Left = 6
@ -51,8 +51,8 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
AnchorSideRight.Control = chkCustomConfigFile
AnchorSideRight.Side = asrBottom
Left = 25
Height = 25
Top = 52
Height = 26
Top = 54
Width = 559
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 19
@ -65,14 +65,14 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
object grpTargetPlatform: TGroupBox
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 109
Top = 110
Height = 125
Top = 114
Width = 594
Align = alTop
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Target Platform'
ClientHeight = 90
ClientHeight = 105
ClientWidth = 590
TabOrder = 1
object lblTargetOS: TLabel
@ -80,9 +80,9 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
AnchorSideTop.Control = TargetOSComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 8
Width = 70
Height = 18
Top = 9
Width = 83
BorderSpacing.Left = 6
Caption = 'lblTargetOS'
ParentColor = False
@ -92,21 +92,21 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
AnchorSideTop.Control = TargetCPUComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 36
Width = 78
Height = 18
Top = 42
Width = 91
Caption = 'lblTargetCPU'
ParentColor = False
end
object lblTargetProcessorProc: TLabel
object lblTargetProc: TLabel
AnchorSideLeft.Control = lblTargetCPU
AnchorSideTop.Control = TargetProcessorProcComboBox
AnchorSideTop.Control = TargetProcComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 64
Width = 144
Caption = 'lblTargetProcessorProc'
Height = 18
Top = 75
Width = 93
Caption = 'lblTargetProc'
ParentColor = False
end
object TargetOSComboBox: TComboBox
@ -115,15 +115,16 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
AnchorSideTop.Control = grpTargetPlatform
AnchorSideRight.Control = grpTargetPlatform
AnchorSideRight.Side = asrBottom
Left = 82
Height = 25
Left = 95
Height = 30
Top = 3
Width = 502
Width = 489
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 6
ItemHeight = 0
OnSelect = TargetOSComboBoxSelect
Style = csDropDownList
TabOrder = 0
end
@ -134,29 +135,30 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpTargetPlatform
AnchorSideRight.Side = asrBottom
Left = 90
Height = 25
Top = 31
Width = 494
Left = 103
Height = 30
Top = 36
Width = 481
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 6
ItemHeight = 0
OnSelect = TargetCPUComboBoxSelect
Style = csDropDownList
TabOrder = 1
end
object TargetProcessorProcComboBox: TComboBox
AnchorSideLeft.Control = lblTargetProcessorProc
object TargetProcComboBox: TComboBox
AnchorSideLeft.Control = lblTargetProc
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TargetCPUComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpTargetPlatform
AnchorSideRight.Side = asrBottom
Left = 156
Height = 25
Top = 59
Width = 428
Left = 105
Height = 30
Top = 69
Width = 479
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 3
@ -169,19 +171,19 @@ object CompilerConfigTargetFrame: TCompilerConfigTargetFrame
end
object grbTargetOptions: TGroupBox
Left = 0
Height = 52
Top = 227
Height = 54
Top = 247
Width = 594
Align = alTop
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Target-specific options'
ClientHeight = 33
ClientHeight = 34
ClientWidth = 590
TabOrder = 2
object chkWin32GraphicApp: TCheckBox
Left = 6
Height = 21
Height = 22
Top = 6
Width = 578
Align = alTop

View File

@ -28,8 +28,9 @@ unit compiler_config_target;
interface
uses
Classes, SysUtils, FileUtil, Controls, Dialogs, StdCtrls, LCLProc, IDEOptionsIntf,
IDEDialogs, CompilerOptions, LazarusIDEStrConsts, PackageDefs;
Classes, SysUtils, strutils, FileUtil, Controls, Dialogs, StdCtrls, LCLProc,
IDEOptionsIntf, IDEDialogs, CompilerOptions, LazarusIDEStrConsts,
TransferMacros, PackageDefs, compiler_parsing_options;
type
@ -45,14 +46,19 @@ type
grpTargetPlatform: TGroupBox;
lblTargetCPU: TLabel;
lblTargetOS: TLabel;
lblTargetProcessorProc: TLabel;
lblTargetProc: TLabel;
TargetCPUComboBox: TComboBox;
TargetOSComboBox: TComboBox;
TargetProcessorProcComboBox: TComboBox;
TargetProcComboBox: TComboBox;
procedure chkCustomConfigFileClick(Sender: TObject);
procedure TargetOSComboBoxSelect(Sender: TObject);
procedure TargetCPUComboBoxSelect(Sender: TObject);
private
FDialog: TAbstractOptionsEditorDialog;
FCompOptions: TBaseCompilerOptions;
FIsPackage: boolean;
procedure UpdateByTargetOS(aTargetOS: string);
procedure UpdateByTargetCPU(aTargetCPU: string);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -117,11 +123,6 @@ end;
{ TCompilerConfigTargetFrame }
procedure TCompilerConfigTargetFrame.chkCustomConfigFileClick(Sender: TObject);
begin
edtConfigPath.Enabled := chkCustomConfigFile.Checked;
end;
constructor TCompilerConfigTargetFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
@ -175,8 +176,82 @@ begin
Result := dlgConfigAndTarget;
end;
procedure TCompilerConfigTargetFrame.UpdateByTargetOS(aTargetOS: string);
var
DbgMsg: String;
begin
DbgMsg := '';
if aTargetOS = '' then
begin
aTargetOS := '$(TargetOS)';
if not GlobalMacroList.SubstituteStr(aTargetOS) then
raise Exception.CreateFmt('Cannot substitute macro "%s".', [aTargetOS]);
DbgMsg := ' (got by using $(TargetOS) macro)';
end;
DebugLn(['TCompilerConfigTargetFrame.UpdateTargetSpecific: TargetOS=',aTargetOS,DbgMsg]);
// Now hide/show the whole GroupBox because there is only one setting.
grbTargetOptions.Visible := AnsiStartsStr('Win', aTargetOS);
end;
procedure TCompilerConfigTargetFrame.UpdateByTargetCPU(aTargetCPU: string);
var
IsIntel: Boolean;
procedure IntelProcessor;
begin
IsIntel := True;
with TargetProcComboBox.Items do
begin
Add(ProcessorToCaption('80386'));
Add(ProcessorToCaption('Pentium'));
Add(ProcessorToCaption('Pentium2'));
Add(ProcessorToCaption('Pentium3'));
Add(ProcessorToCaption('Pentium4'));
Add(ProcessorToCaption('PentiumM'));
end;
end;
var
DbgMsg: String;
ParsingFrame: TCompilerParsingOptionsFrame;
begin
IsIntel := False;
DbgMsg := '';
if aTargetCPU = '' then
begin
aTargetCPU := '$(TargetCPU)';
if not GlobalMacroList.SubstituteStr(aTargetCPU) then
raise Exception.CreateFmt('Cannot substitute macro "%s".', [aTargetCPU]);
DbgMsg := ' (got by using $(TargetCPU) macro)';
end;
DebugLn(['TCompilerConfigTargetFrame.UpdateTargetProcessorList: TargetCPU=',aTargetCPU,DbgMsg]);
// Update selection list for target processor
TargetProcComboBox.Clear;
TargetProcComboBox.Items.Add(ProcessorToCaption(''));
case aTargetCPU of
'arm': begin end;
'i386': IntelProcessor;
'm68k': begin end;
'powerpc': begin end;
'sparc': begin end;
'x86_64': IntelProcessor;
'mipsel': begin end;
'mips': begin end;
'jvm': begin end;
end;
TargetProcComboBox.ItemIndex := 0;
// Update selection list for assembler style
ParsingFrame := TCompilerParsingOptionsFrame(FDialog.FindEditor(TCompilerParsingOptionsFrame));
Assert(Assigned(ParsingFrame));
ParsingFrame.grpAsmStyle.Visible := IsIntel;
end;
procedure TCompilerConfigTargetFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
FDialog := ADialog;
// Config
grpConfigFile.Caption := dlgConfigFiles;
chkConfigFile.Caption := dlgUseFpcCfg + ' (If not checked: -n)';
@ -188,80 +263,59 @@ begin
lblTargetOS.Caption := dlgTargetOS + ' (-T)';
with TargetOSComboBox do
begin
with Items do
begin
Add('(' + lisDefault + ')');
Add('Darwin');
Add('FreeBSD');
Add('Linux');
Add('NetBSD');
Add('OpenBSD');
Add('Solaris');
Add('Win32');
Add('Win64');
Add('WinCE');
Add('aix');
Add('amiga');
Add('android');
Add('atari');
Add('beos');
Add('embedded');
Add('emx');
Add('gba');
Add('go32v2');
Add('haiku');
Add('iphonesim');
Add('java');
Add('macos');
Add('morphos');
Add('nds');
Add('netware');
Add('netwlibc');
Add('os2');
Add('palmos');
Add('qnx');
Add('symbian');
Add('watcom');
Add('wdosx');
end;
Items.Add('(' + lisDefault + ')');
Items.Add('Darwin');
Items.Add('FreeBSD');
Items.Add('Linux');
Items.Add('NetBSD');
Items.Add('OpenBSD');
Items.Add('Solaris');
Items.Add('Win32');
Items.Add('Win64');
Items.Add('WinCE');
Items.Add('aix');
Items.Add('amiga');
Items.Add('android');
Items.Add('atari');
Items.Add('beos');
Items.Add('embedded');
Items.Add('emx');
Items.Add('gba');
Items.Add('go32v2');
Items.Add('haiku');
Items.Add('iphonesim');
Items.Add('java');
Items.Add('macos');
Items.Add('morphos');
Items.Add('nds');
Items.Add('netware');
Items.Add('netwlibc');
Items.Add('os2');
Items.Add('palmos');
Items.Add('qnx');
Items.Add('symbian');
Items.Add('watcom');
Items.Add('wdosx');
ItemIndex := 0;
end;
lblTargetCPU.Caption := dlgTargetCPUFamily + ' (-P)';
with TargetCPUComboBox do
begin
with Items do
begin
Add('(' + lisDefault + ')');
Add('arm');
Add('i386');
Add('m68k');
Add('powerpc');
Add('sparc');
Add('x86_64');
Add('mipsel');
Add('mips');
Add('jvm');
end;
Items.Add('(' + lisDefault + ')');
Items.Add('arm');
Items.Add('i386');
Items.Add('m68k');
Items.Add('powerpc');
Items.Add('sparc');
Items.Add('x86_64');
Items.Add('mipsel');
Items.Add('mips');
Items.Add('jvm');
ItemIndex := 0;
end;
lblTargetProcessorProc.Caption := dlgTargetProc;
with TargetProcessorProcComboBox do
begin
with Items do
begin
Clear;
Add(ProcessorToCaption(''));
Add(ProcessorToCaption('80386'));
Add(ProcessorToCaption('Pentium'));
Add(ProcessorToCaption('Pentium2'));
Add(ProcessorToCaption('Pentium3'));
Add(ProcessorToCaption('Pentium4'));
Add(ProcessorToCaption('PentiumM'));
end;
ItemIndex := 0;
end;
lblTargetProc.Caption := dlgTargetProc;
// Target options
grbTargetOptions.Caption := dlgTargetSpecificOptions;
@ -288,7 +342,7 @@ begin
TargetOSComboBox.Text := 'default';
TargetCPUComboBox.ItemIndex := 0;
TargetCPUComboBox.Text := 'default';
TargetProcessorProcComboBox.Text := 'default';
TargetProcComboBox.Text := 'default';
end else begin
grpTargetPlatform.Visible:=true;
// Target OS
@ -302,7 +356,9 @@ begin
i := 0; // 0 is default
TargetCPUComboBox.ItemIndex := i;
// Target Processor
TargetProcessorProcComboBox.Text := ProcessorToCaption(TargetProcessor);
UpdateByTargetCPU(TargetCPU);
UpdateByTargetOS(TargetOS);
TargetProcComboBox.Text := ProcessorToCaption(TargetProcessor);
end;
chkWin32GraphicApp.Checked := Win32GraphicApp;
chkWin32GraphicApp.Enabled := NeedsLinkerOpts;
@ -332,12 +388,43 @@ begin
if TargetCPUComboBox.Items.IndexOf(NewTargetCPU) <= 0 then
NewTargetCPU := '';
TargetCPU := CaptionToCPU(NewTargetCPU);
TargetProcessor := CaptionToProcessor(TargetProcessorProcComboBox.Text);
TargetProcessor := CaptionToProcessor(TargetProcComboBox.Text);
end;
Win32GraphicApp := chkWin32GraphicApp.Checked;
end;
end;
procedure TCompilerConfigTargetFrame.chkCustomConfigFileClick(Sender: TObject);
begin
edtConfigPath.Enabled := chkCustomConfigFile.Checked;
end;
procedure TCompilerConfigTargetFrame.TargetOSComboBoxSelect(Sender: TObject);
var
cb: TComboBox;
s: TCaption;
begin
cb := Sender as TComboBox;
if cb.ItemIndex = 0 then
s :=''
else
s := cb.Text;
UpdateByTargetOS(s);
end;
procedure TCompilerConfigTargetFrame.TargetCPUComboBoxSelect(Sender: TObject);
var
cb: TComboBox;
s: String;
begin
cb := Sender as TComboBox;
if cb.ItemIndex = 0 then
s :=''
else
s := cb.Text;
UpdateByTargetCPU(s);
end;
class function TCompilerConfigTargetFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TBaseCompilerOptions;

View File

@ -13,8 +13,8 @@ object CompilerParsingOptionsFrame: TCompilerParsingOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 0
Height = 57
Top = 326
Height = 54
Top = 332
Width = 584
Anchors = [akTop, akLeft, akRight]
AutoFill = True
@ -29,7 +29,14 @@ object CompilerParsingOptionsFrame: TCompilerParsingOptionsFrame
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 34
ClientWidth = 580
Columns = 3
Items.Strings = (
'one'
'two'
'three'
)
TabOrder = 1
end
object grpSyntaxOptions: TCheckGroup
@ -38,7 +45,7 @@ object CompilerParsingOptionsFrame: TCompilerParsingOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 258
Top = 62
Top = 68
Width = 584
Anchors = [akTop, akLeft, akRight]
AutoFill = True
@ -56,21 +63,21 @@ object CompilerParsingOptionsFrame: TCompilerParsingOptionsFrame
end
object grpSyntaxMode: TGroupBox
Left = 0
Height = 56
Height = 62
Top = 0
Width = 584
Align = alTop
Anchors = []
AutoSize = True
Caption = 'grpSyntaxMode'
ClientHeight = 37
ClientHeight = 42
ClientWidth = 580
TabOrder = 2
object cmbSyntaxMode: TComboBox
AnchorSideRight.Control = grpSyntaxMode
AnchorSideRight.Side = asrBottom
Left = 6
Height = 25
Height = 30
Top = 6
Width = 568
Align = alLeft

View File

@ -5,8 +5,8 @@ unit compiler_parsing_options;
interface
uses
ExtCtrls, StdCtrls, SysUtils, IDEOptionsIntf, CompilerOptions, LinkScanner,
PackageDefs, LazarusIDEStrConsts;
ExtCtrls, StdCtrls, SysUtils, IDEOptionsIntf, CompilerOptions,
LinkScanner, PackageDefs, LazarusIDEStrConsts;
type
@ -88,22 +88,19 @@ begin
with grpAsmStyle do
begin
Caption := dlgCOAsmStyle + ' (-R)';
with Items do
begin
BeginUpdate;
Add(lisDefault);
Add('Intel');
Add('AT&&T');
EndUpdate;
end;
Items.BeginUpdate;
Items.Clear;
Items.Add(lisDefault);
Items.Add('Intel');
Items.Add('AT&&T');
Items.EndUpdate;
end;
with grpSyntaxOptions do
begin
AutoSize := True;
Caption := dlgSyntaxOptions;
Items.BeginUpdate;
Items.Add(dlgCOCOps + ' (-Sc, {$COPERATORS ON})');
Items.Add(dlgLabelGoto + ' (-Sg, {$GOTO ON})');
Items.Add(dlgCppInline + ' (-Si, {$INLINE ON})');
@ -111,6 +108,7 @@ begin
Items.Add(dlgInitDoneOnly + ' (-Ss)');
Items.Add(dlgStaticKeyword + ' (-St)');
Items.Add(dlgCOAnsiStr + ' (-Sh, {$H+})');
Items.EndUpdate;
end;
end;