Revert changes committed by mistake

git-svn-id: trunk@32903 -
This commit is contained in:
juha 2011-10-15 10:26:24 +00:00
parent 1b25411dc1
commit bbe92fcaa7
8 changed files with 950 additions and 383 deletions

View File

@ -1,15 +1,15 @@
object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
Left = 354
Height = 480
Top = 78
Left = 333
Height = 529
Top = 113
Width = 700
VertScrollBar.Visible = False
BorderIcons = [biSystemMenu]
Caption = 'ConfigureBuildLazarusDlg'
ClientHeight = 480
ClientHeight = 529
ClientWidth = 700
Constraints.MinHeight = 440
Constraints.MinWidth = 550
Constraints.MinHeight = 500
Constraints.MinWidth = 462
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
@ -18,41 +18,76 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
LCLVersion = '0.9.31'
object DetailsPanel: TPanel
Left = 0
Height = 442
Height = 491
Top = 0
Width = 700
Align = alClient
AutoSize = True
ClientHeight = 442
ClientHeight = 491
ClientWidth = 700
TabOrder = 0
object BuildProfileLabel: TLabel
AnchorSideLeft.Control = DetailsPanel
AnchorSideTop.Control = BuildProfileComboBox
AnchorSideTop.Side = asrCenter
Left = 7
AnchorSideTop.Control = DetailsPanel
Left = 8
Height = 16
Top = 10
Width = 105
Top = 12
Width = 91
BorderSpacing.Top = 5
BorderSpacing.Around = 6
Caption = 'Profile to Build'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object MakeModeListHeader: THeaderControl
AnchorSideLeft.Control = DetailsPanel
AnchorSideTop.Control = BuildProfileComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 39
Width = 410
DragReorder = False
Sections = <>
OnSectionClick = MakeModeListHeaderSectionClick
BorderSpacing.Left = 5
BorderSpacing.Top = 6
OnResize = MakeModeListHeaderResize
end
object MakeModeListBox: TListBox
AnchorSideTop.Control = MakeModeListHeader
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MakeModeListHeader
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = LCLWidgetTypeComboBox
Left = 4
Height = 168
Top = 63
Width = 412
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Bottom = 6
ItemHeight = 25
OnDrawItem = MakeModeListBoxDrawItem
OnMouseDown = MakeModeListBoxMouseDown
OnShowHint = MakeModeListBoxShowHint
ParentShowHint = False
ScrollWidth = 408
ShowHint = True
Style = lbOwnerDrawFixed
TabOrder = 2
TopIndex = -1
end
object BuildProfileComboBox: TComboBox
AnchorSideLeft.Control = BuildProfileLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildProfileLabel
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = BuildProfileButton
Left = 142
Left = 105
Height = 25
Hint = 'Name of the active profile.'
Top = 6
Width = 523
Anchors = [akLeft, akRight]
BorderSpacing.Left = 30
Top = 8
Width = 560
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
ItemHeight = 0
OnSelect = BuildProfileComboBoxSelect
@ -70,7 +105,7 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
Left = 671
Height = 25
Hint = 'Manage profiles'
Top = 6
Top = 8
Width = 22
Anchors = [akTop, akRight]
AutoSize = True
@ -85,9 +120,9 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
object OptionsLabel: TLabel
AnchorSideLeft.Control = LCLWidgetTypeLabel
AnchorSideTop.Control = OptionsMemo
Left = 7
Left = 6
Height = 16
Top = 81
Top = 272
Width = 49
Alignment = taRightJustify
BorderSpacing.Top = 4
@ -97,17 +132,17 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
end
object OptionsMemo: TMemo
AnchorSideLeft.Control = LCLWidgetTypeComboBox
AnchorSideTop.Control = LCLWidgetTypeComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BuildProfileButton
AnchorSideRight.Side = asrBottom
Left = 142
AnchorSideBottom.Control = TargetDirectoryComboBox
Left = 137
Height = 56
Hint = 'Options passed to compiler'
Top = 77
Width = 551
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Top = 268
Width = 556
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 6
Lines.Strings = (
''
)
@ -115,17 +150,17 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
ParentShowHint = False
ScrollBars = ssAutoBoth
ShowHint = True
TabOrder = 4
TabOrder = 5
end
object DefinesLabel: TLabel
AnchorSideLeft.Control = MakeModeListHeader
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TargetOSLabel
AnchorSideTop.Control = MakeModeListHeader
AnchorSideTop.Side = asrCenter
Left = 392
Left = 423
Height = 16
Top = 171
Top = 43
Width = 48
Anchors = [akTop]
BorderSpacing.Left = 7
Caption = 'Defines'
ParentColor = False
@ -136,53 +171,58 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BuildProfileButton
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = MakeModeListBox
AnchorSideBottom.Side = asrBottom
Left = 392
Height = 174
Left = 423
Height = 170
Hint = 'Defines without -d'
Top = 189
Width = 301
Anchors = [akTop, akLeft, akRight]
Top = 61
Width = 270
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
ItemHeight = 0
ParentShowHint = False
PopupMenu = OptionsPopupMenu
ShowHint = True
TabOrder = 2
TabOrder = 3
TopIndex = -1
end
object LCLWidgetTypeLabel: TLabel
AnchorSideLeft.Control = BuildProfileLabel
AnchorSideLeft.Control = DetailsPanel
AnchorSideTop.Control = LCLWidgetTypeComboBox
AnchorSideTop.Side = asrCenter
Left = 7
Left = 6
Height = 16
Top = 50
Top = 241
Width = 99
BorderSpacing.Left = 5
Caption = 'LCL Widget Type'
ParentColor = False
end
object LCLWidgetTypeComboBox: TComboBox
AnchorSideLeft.Control = BuildProfileComboBox
AnchorSideTop.Control = BuildProfileComboBox
AnchorSideLeft.Control = LCLWidgetTypeLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 142
AnchorSideBottom.Control = OptionsMemo
Left = 137
Height = 25
Top = 46
Top = 237
Width = 163
BorderSpacing.Top = 15
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 32
BorderSpacing.Bottom = 6
ItemHeight = 0
Style = csDropDownList
TabOrder = 3
TabOrder = 4
end
object TargetDirectoryLabel: TLabel
AnchorSideLeft.Control = LCLWidgetTypeLabel
AnchorSideTop.Control = TargetDirectoryComboBox
AnchorSideTop.Side = asrCenter
Left = 7
Left = 6
Height = 16
Top = 142
Top = 333
Width = 100
Alignment = taRightJustify
Caption = 'Target Directory'
@ -190,26 +230,26 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
end
object TargetDirectoryComboBox: TComboBox
AnchorSideLeft.Control = OptionsMemo
AnchorSideTop.Control = OptionsMemo
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TargetDirectoryButton
Left = 142
AnchorSideBottom.Control = TargetOSComboBox
Left = 137
Height = 23
Top = 139
Width = 523
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Top = 330
Width = 528
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 5
TabOrder = 6
end
object TargetOSLabel: TLabel
AnchorSideLeft.Control = TargetDirectoryLabel
AnchorSideTop.Control = TargetOSComboBox
AnchorSideTop.Side = asrCenter
Left = 7
Left = 6
Height = 16
Top = 171
Top = 362
Width = 61
Alignment = taRightJustify
Caption = 'Target OS'
@ -219,9 +259,9 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
AnchorSideLeft.Control = TargetOSLabel
AnchorSideTop.Control = TargetCPUComboBox
AnchorSideTop.Side = asrCenter
Left = 7
Left = 6
Height = 16
Top = 200
Top = 391
Width = 69
Alignment = taRightJustify
Caption = 'Target CPU'
@ -229,58 +269,61 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
end
object UpdateRevisionIncCheckBox: TCheckBox
AnchorSideLeft.Control = CleanAllCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CleanAllCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Side = asrBottom
Left = 142
Left = 468
Height = 26
Hint = 'Increment revision? (ToDo: get a better hint)'
Top = 331
Top = 357
Width = 202
BorderSpacing.Left = 12
BorderSpacing.Top = 6
Caption = 'UpdateRevisionIncCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 10
TabOrder = 11
end
object CleanAllCheckBox: TCheckBox
AnchorSideLeft.Control = BuildIdeRadioGroup
AnchorSideTop.Control = BuildIdeRadioGroup
AnchorSideTop.Side = asrBottom
AnchorSideLeft.Control = TargetOSComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TargetOSComboBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom
Left = 142
Left = 319
Height = 26
Hint = 'Like "make clean" on cmd line'
Top = 299
Top = 357
Width = 137
BorderSpacing.Top = 3
BorderSpacing.Left = 19
Caption = 'CleanAllCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 9
TabOrder = 10
end
object TargetCPUComboBox: TComboBox
AnchorSideLeft.Control = TargetOSComboBox
AnchorSideTop.Control = TargetOSComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TargetOSComboBox
AnchorSideRight.Side = asrBottom
Left = 142
AnchorSideBottom.Control = CommonsDividerBevel
Left = 137
Height = 23
Top = 197
Top = 388
Width = 163
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 8
TabOrder = 9
end
object CommonsDividerBevel: TDividerBevel
AnchorSideLeft.Control = DetailsPanel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 377
Width = 668
Top = 417
Width = 686
Caption = 'CommonsDividerBevel'
Autosize = True
Anchors = [akLeft, akRight]
@ -290,20 +333,19 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
ParentFont = False
end
object RestartAfterBuildCheckBox: TCheckBox
AnchorSideLeft.Control = CommonsDividerBevel
AnchorSideTop.Control = CommonsDividerBevel
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 26
Hint = 'Restart Lazarus automatically after building the IDE. Has no effect when building other parts'
Top = 399
Top = 439
Width = 193
BorderSpacing.Top = 7
Caption = 'RestartAfterBuildCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 11
TabOrder = 12
end
object ConfirmBuildCheckBox: TCheckBox
AnchorSideLeft.Control = RestartAfterBuildCheckBox
@ -312,13 +354,13 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
Left = 213
Height = 26
Hint = 'Show confirmation dialog when building directly from Tools menu'
Top = 399
Top = 439
Width = 165
BorderSpacing.Left = 12
Caption = 'ConfirmBuildCheckBox'
ParentShowHint = False
ShowHint = True
TabOrder = 12
TabOrder = 13
end
object DefinesButton: TButton
AnchorSideTop.Control = RestartAfterBuildCheckBox
@ -328,7 +370,7 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
Left = 608
Height = 25
Hint = 'Edit list of defines which can be used by any profile'
Top = 399
Top = 439
Width = 85
Anchors = [akTop, akRight]
AutoSize = True
@ -336,7 +378,7 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
OnClick = DefinesButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 13
TabOrder = 14
end
object TargetDirectoryButton: TButton
AnchorSideLeft.Side = asrBottom
@ -347,7 +389,7 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
AnchorSideBottom.Side = asrBottom
Left = 671
Height = 25
Top = 138
Top = 329
Width = 22
Anchors = [akTop, akRight]
AutoSize = True
@ -355,53 +397,29 @@ object ConfigureBuildLazarusDlg: TConfigureBuildLazarusDlg
BorderSpacing.Right = 6
Caption = '...'
OnClick = TargetDirectoryButtonClick
TabOrder = 6
TabOrder = 7
end
object TargetOSComboBox: TComboBox
AnchorSideLeft.Control = TargetDirectoryComboBox
AnchorSideTop.Control = TargetDirectoryComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = LCLWidgetTypeComboBox
AnchorSideRight.Side = asrBottom
Left = 142
AnchorSideBottom.Control = TargetCPUComboBox
Left = 137
Height = 23
Top = 168
Top = 359
Width = 163
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 7
end
object BuildIdeRadioGroup: TRadioGroup
AnchorSideLeft.Control = TargetCPUComboBox
AnchorSideTop.Control = TargetCPUComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DefinesListBox
Left = 142
Height = 70
Top = 226
Width = 234
Anchors = [akTop, akLeft, akRight]
AutoFill = True
BorderSpacing.Top = 6
BorderSpacing.Right = 13
Caption = 'Building IDE'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
TabOrder = 14
TabOrder = 8
end
end
object CBLDBtnPanel: TPanel
AnchorSideTop.Side = asrBottom
Left = 0
Height = 38
Top = 442
Top = 491
Width = 700
Align = alBottom
AutoSize = True

View File

@ -89,12 +89,13 @@ type
LCLWidgetTypeComboBox: TComboBox;
OptionsLabel: TLabel;
OptionsMemo: TMemo;
BuildIdeRadioGroup: TRadioGroup;
RestartAfterBuildCheckBox: TCheckBox;
ShowOptsMenuItem: TMenuItem;
DetailsPanel: TPanel;
HelpButton: TBitBtn;
BuildProfileLabel: TLabel;
MakeModeListBox: TListBox;
MakeModeListHeader: THeaderControl;
OptionsPopupMenu: TPopupMenu;
Panel2: TPanel;
SaveSettingsButton: TBitBtn;
@ -117,6 +118,14 @@ type
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpButtonClick(Sender: TObject);
procedure MakeModeListHeaderResize(Sender: TObject);
procedure MakeModeListHeaderSectionClick(HeaderControl: TCustomHeaderControl;
Section: THeaderSection);
procedure MakeModeListBoxDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
procedure MakeModeListBoxMouseDown(Sender: TOBject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MakeModeListBoxShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure ShowOptsMenuItemClick(Sender: TObject);
procedure SaveSettingsButtonClick(Sender: TObject);
procedure TargetDirectoryButtonClick(Sender: TObject);
@ -124,10 +133,14 @@ type
// Data is copied by caller before and after opening this dialog.
fProfiles: TBuildLazarusProfiles;
fUpdatingProfileCombo: Boolean;
function GetMakeModeAtX(const X: Integer; out MakeMode: TMakeMode): boolean;
function MakeModeToInt(MakeMode: TMakeMode): integer;
function IntToMakeMode(i: integer): TMakeMode;
procedure PrepareClose;
public
constructor Create(TheOwner: TComponent); overload; reintroduce;
destructor Destroy; override;
procedure CopyMakeModeDefsToUI(AMakeModeDefs: TMakeModeDefs);
procedure CopyProfileToUI(AProfile: TBuildLazarusProfile);
procedure CopyUIToProfile(AProfile: TBuildLazarusProfile);
procedure UpdateProfileNamesUI;
@ -143,9 +156,10 @@ function BuildLazarus(Profiles: TBuildLazarusProfiles;
Flags: TBuildLazarusFlags): TModalResult;
function CreateBuildLazarusOptions(Profiles: TBuildLazarusProfiles;
Macros: TTransferMacroList; const PackageOptions: string;
Flags: TBuildLazarusFlags; var AExOptions: string;
out UpdateRevisionInc: boolean; out OutputDirRedirected: boolean): TModalResult;
ItemIndex: integer; Macros: TTransferMacroList;
const PackageOptions: string; Flags: TBuildLazarusFlags;
var AExOptions: string; out UpdateRevisionInc: boolean;
out OutputDirRedirected: boolean): TModalResult;
function SaveIDEMakeOptions(Profiles: TBuildLazarusProfiles;
Macros: TTransferMacroList;
@ -153,6 +167,8 @@ function SaveIDEMakeOptions(Profiles: TBuildLazarusProfiles;
function GetMakeIDEConfigFilename: string;
function GetTranslatedMakeModes(MakeMode: TMakeMode): string;
implementation
@ -163,6 +179,17 @@ const
ButtonSize = 24;
ModeColumnWidth = 170;
function GetTranslatedMakeModes(MakeMode: TMakeMode): string;
begin
case MakeMode of
mmNone: Result:=lisLazBuildNone;
mmBuild: Result:=lisLazBuildBuild;
mmCleanBuild: Result:=lisLazBuildCleanBuild;
else
Result:='???';
end;
end;
function ShowConfigureBuildLazarusDlg(AProfiles: TBuildLazarusProfiles): TModalResult;
// mrOk=save
// mrYes=save and compile
@ -201,7 +228,9 @@ var
Tool: TExternalToolOptions;
Options: TBuildLazarusProfile;
i: Integer;
MMDef: TMakeModeDef;
ExOptions: String;
CurMakeMode: TMakeMode;
WorkingDirectory: String;
OutputDirRedirected, UpdateRevisionInc: boolean;
begin
@ -236,7 +265,8 @@ begin
Tool.ScanOutputForMakeMessages:=true;
// clean up
if Options.CleanAll and ([blfDontCleanAll,blfOnlyIDE]*Flags=[]) then begin
if Options.CleanAll
and ([blfDontCleanAll,blfOnlyIDE]*Flags=[]) then begin
WorkingDirectory:=EnvironmentOptions.LazarusDirectory;
if not CheckDirectoryWritable(WorkingDirectory) then exit(mrCancel);
@ -256,40 +286,53 @@ begin
// build every item
if not (blfDontBuild in Flags) then begin
WorkingDirectory:=EnvironmentOptions.LazarusDirectory;
if (blfDontCleanAll in Flags) and (Options.IdeBuildMode=bmCleanBuild) then
Options.IdeBuildMode:=bmBuild;
Tool.Title:=lisIDE;
Tool.WorkingDirectory:=WorkingDirectory;
case Options.IdeBuildMode of
bmBuild: Tool.CmdLineParams:='all';
bmCleanBuild: Tool.CmdLineParams:='clean all';
for i:=0 to Profiles.MakeModeDefs.Count-1 do begin
MMDef:=Profiles.MakeModeDefs[i]; // build item
WorkingDirectory:=TrimFilename(EnvironmentOptions.LazarusDirectory
+PathDelim+MMDef.Directory);
// calculate make mode
CurMakeMode:=Profiles.Current.MakeModes[i];
if (blfOnlyIDE in Flags) then begin
if MMDef=Profiles.MakeModeDefs.ItemIDE then begin
if CurMakeMode=mmNone then
CurMakeMode:=mmBuild;
end else
CurMakeMode:=mmNone;
end;
//debugln(['BuildLazarus Def=',MMDef.Name,' Mode=',ord(CurMakeMode)]);
if CurMakeMode=mmNone then continue;
if (blfDontCleanAll in Flags) and (CurMakeMode=mmCleanBuild) then
CurMakeMode:=mmBuild;
Tool.Title:=MMDef.Description;
Tool.WorkingDirectory:=WorkingDirectory;
Tool.CmdLineParams:=MMDef.Commands[CurMakeMode];
// append extra options
ExOptions:='';
Result:=CreateBuildLazarusOptions(Profiles,i,Macros,PackageOptions,Flags,
ExOptions,UpdateRevisionInc,OutputDirRedirected);
if Result<>mrOk then exit;
if (not OutputDirRedirected)
and (not CheckDirectoryWritable(WorkingDirectory)) then
exit(mrCancel);
if ExOptions<>'' then
Tool.EnvironmentOverrides.Values['OPT'] := ExOptions;
if not UpdateRevisionInc then
Tool.EnvironmentOverrides.Values['USESVN2REVISIONINC'] := '0';
// add -w option to print leaving/entering messages
Tool.CmdLineParams:=Tool.CmdLineParams+' -w';
// append target OS
if Options.TargetOS<>'' then
Tool.CmdLineParams:=Tool.CmdLineParams+' OS_TARGET='+Options.FPCTargetOS;
// append target CPU
if Options.TargetCPU<>'' then
Tool.CmdLineParams:=Tool.CmdLineParams+' CPU_TARGET='+Options.FPCTargetCPU;
// run
Result:=ExternalTools.Run(Tool,Macros,false);
if Result<>mrOk then exit;
end;
// append extra options
ExOptions:='';
Result:=CreateBuildLazarusOptions(Profiles,Macros,PackageOptions,Flags,
ExOptions,UpdateRevisionInc,OutputDirRedirected);
if Result<>mrOk then exit;
if (not OutputDirRedirected)
and (not CheckDirectoryWritable(WorkingDirectory)) then
exit(mrCancel);
if ExOptions<>'' then
Tool.EnvironmentOverrides.Values['OPT'] := ExOptions;
if not UpdateRevisionInc then
Tool.EnvironmentOverrides.Values['USESVN2REVISIONINC'] := '0';
// add -w option to print leaving/entering messages
Tool.CmdLineParams:=Tool.CmdLineParams+' -w';
// append target OS
if Options.TargetOS<>'' then
Tool.CmdLineParams:=Tool.CmdLineParams+' OS_TARGET='+Options.FPCTargetOS;
// append target CPU
if Options.TargetCPU<>'' then
Tool.CmdLineParams:=Tool.CmdLineParams+' CPU_TARGET='+Options.FPCTargetCPU;
// run
Result:=ExternalTools.Run(Tool,Macros,false);
if Result<>mrOk then exit;
end;
Result:=mrOk;
finally
@ -300,10 +343,29 @@ begin
end;
function CreateBuildLazarusOptions(Profiles: TBuildLazarusProfiles;
Macros: TTransferMacroList; const PackageOptions: string;
Flags: TBuildLazarusFlags; var AExOptions: string;
out UpdateRevisionInc: boolean; out OutputDirRedirected: boolean): TModalResult;
ItemIndex: integer; Macros: TTransferMacroList;
const PackageOptions: string; Flags: TBuildLazarusFlags;
var AExOptions: string; out UpdateRevisionInc: boolean;
out OutputDirRedirected: boolean): TModalResult;
{
function RemoveProfilerOption(const ExtraOptions: string): string;
var
p, StartPos: integer;
begin
Result:=ExtraOptions;
// delete profiler option
p:=Pos('-pg',Result);
if (p>0)
and ((p+3>length(Result)) or (Result[p+3]=' ')) // option end
and ((p=1) or (Result[p-1]=' ')) then begin
// profiler option found
StartPos:=p;
while (StartPos>1) and (Result[StartPos-1]=' ') do
dec(StartPos);
System.Delete(Result,StartPos,p-StartPos+3);
end;
end;
}
procedure AppendExtraOption(const AddOption: string; EncloseIfSpace: boolean);
begin
if AddOption='' then exit;
@ -322,6 +384,7 @@ function CreateBuildLazarusOptions(Profiles: TBuildLazarusProfiles;
end;
var
MMDef: TMakeModeDef;
Options: TBuildLazarusProfile;
MakeIDECfgFilename: String;
NewTargetFilename: String;
@ -340,192 +403,195 @@ begin
Options:=Profiles.Current;
OutputDirRedirected:=false;
UpdateRevisionInc:=Options.UpdateRevisionInc;
MMDef:=Profiles.MakeModeDefs[ItemIndex];
// create extra options
AExOptions:=Options.ExtraOptions;
// check for special IDE config file
if (blfUseMakeIDECfg in Flags) then begin
MakeIDECfgFilename:=GetMakeIDEConfigFilename;
//DebugLn(['CreateBuildLazarusOptions MAKE MakeIDECfgFilename=',MakeIDECfgFilename,' ',FileExistsUTF8(MakeIDECfgFilename)]);
if (FileExistsUTF8(MakeIDECfgFilename)) then begin
// If a file name contains spaces, a file name whould need to be quoted.
// Using a single quote is not possible, it is used already in the
// makefile to group all options in OPT='bla bla'.
// using " implicates that make uses a shell to execute the command of
// that line. But using shells (i.e. command.com, cmd.exe, etc) is so
// fragile (see bug 11362), that is better to avoid this.
// Therefore we use a short 8.3 file and path name, so we don't need to
// use quotes at all.
// On platforms other than windows, ExtractShortPathName is implemented
// too and simply returns the passed file name, so there is no need
// for $IFDEF.
if pos(' ',MakeIDECfgFilename)>0 then
MakeIDECfgFilename:=ExtractShortPathNameUTF8(MakeIDECfgFilename);
AppendExtraOption('@'+MakeIDECfgFilename);
if MMDef=Profiles.MakeModeDefs.ItemIDE then begin
// check for special IDE config file
if (blfUseMakeIDECfg in Flags) then begin
MakeIDECfgFilename:=GetMakeIDEConfigFilename;
//DebugLn(['CreateBuildLazarusOptions MAKE MakeIDECfgFilename=',MakeIDECfgFilename,' ',FileExistsUTF8(MakeIDECfgFilename)]);
if (FileExistsUTF8(MakeIDECfgFilename)) then begin
// If a file name contains spaces, a file name whould need to be quoted.
// Using a single quote is not possible, it is used already in the
// makefile to group all options in OPT='bla bla'.
// using " implicates that make uses a shell to execute the command of
// that line. But using shells (i.e. command.com, cmd.exe, etc) is so
// fragile (see bug 11362), that is better to avoid this.
// Therefore we use a short 8.3 file and path name, so we don't need to
// use quotes at all.
// On platforms other than windows, ExtractShortPathName is implemented
// too and simply returns the passed file name, so there is no need
// for $IFDEF.
if pos(' ',MakeIDECfgFilename)>0 then
MakeIDECfgFilename:=ExtractShortPathNameUTF8(MakeIDECfgFilename);
AppendExtraOption('@'+MakeIDECfgFilename);
end;
end;
end;
// set target filename and target directory:
// 1. the user has set a target directory
// 2. For crosscompiling the IDE it needs a different directory
// 3. If lazarus is installed as root/administrator, the lazarus executable
// is readonly and needs a different name and directory
// (e.g. ~/.lazarus/bin/lazarus).
// 4. Platforms like windows locks executables, so lazarus can not replace
// itself. They need a different name (e.g. lazarus.new.exe).
// The target directory is writable, the lazarus.o file can be created.
// 5. If the user uses the startlazarus utility, then we need a backup.
// Under non locking platforms 'make' cleans the lazarus executable, so
// the IDE will rename the old file first (e.g. to lazarus.old).
// Renaming is not needed.
// Otherwise: Don't touch the target filename.
// set target filename and target directory:
// 1. the user has set a target directory
// 2. For crosscompiling the IDE it needs a different directory
// 3. If lazarus is installed as root/administrator, the lazarus executable
// is readonly and needs a different name and directory
// (e.g. ~/.lazarus/bin/lazarus).
// 4. Platforms like windows locks executables, so lazarus can not replace
// itself. They need a different name (e.g. lazarus.new.exe).
// The target directory is writable, the lazarus.o file can be created.
// 5. If the user uses the startlazarus utility, then we need a backup.
// Under non locking platforms 'make' cleans the lazarus executable, so
// the IDE will rename the old file first (e.g. to lazarus.old).
// Renaming is not needed.
// Otherwise: Don't touch the target filename.
NewTargetFilename:='';
NewUnitDirectory:='';
NewTargetDirectory:='';
DefaultTargetOS:=GetDefaultTargetOS;
DefaultTargetCPU:=GetDefaultTargetCPU;
NewTargetOS:=Options.FPCTargetOS;
NewTargetCPU:=Options.FPCTargetCPU;
if NewTargetOS='' then NewTargetOS:=DefaultTargetOS;
if NewTargetCPU='' then NewTargetCPU:=DefaultTargetCPU;
CrossCompiling:=(CompareText(NewTargetOS,DefaultTargetOS)<>0) or (CompareText(NewTargetCPU,DefaultTargetCPU)<>0);
ExeLocked:=OSLocksExecutables and (not (blfReplaceExe in Flags))
and (not CrossCompiling);
NewTargetFilename:='';
NewUnitDirectory:='';
NewTargetDirectory:='';
DefaultTargetOS:=GetDefaultTargetOS;
DefaultTargetCPU:=GetDefaultTargetCPU;
NewTargetOS:=Options.FPCTargetOS;
NewTargetCPU:=Options.FPCTargetCPU;
if NewTargetOS='' then NewTargetOS:=DefaultTargetOS;
if NewTargetCPU='' then NewTargetCPU:=DefaultTargetCPU;
CrossCompiling:=(CompareText(NewTargetOS,DefaultTargetOS)<>0) or (CompareText(NewTargetCPU,DefaultTargetCPU)<>0);
ExeLocked:=OSLocksExecutables and (not (blfReplaceExe in Flags))
and (not CrossCompiling);
//DebugLn(['CreateBuildLazarusOptions NewTargetOS=',NewTargetOS,' NewTargetCPU=',NewTargetCPU]);
if (Options.TargetDirectory<>'') then begin
// Case 1. the user has set a target directory
NewTargetDirectory:=Options.TargetDirectory;
if not Macros.SubstituteStr(NewTargetDirectory) then begin
debugln('CreateBuildLazarusOptions macro aborted Options.TargetDirectory=',Options.TargetDirectory);
Result:=mrAbort;
exit;
end;
NewTargetDirectory:=CleanAndExpandDirectory(NewTargetDirectory);
debugln('CreateBuildLazarusOptions Options.TargetDirectory=',NewTargetDirectory);
Result:=ForceDirectoryInteractive(NewTargetDirectory,[]);
if Result<>mrOk then exit;
if ExeLocked then begin
// Allow for the case where this corresponds to the current executable
NewTargetFilename:='lazarus'+GetExecutableExt(NewTargetOS);
if FileExistsUTF8(AppendPathDelim(NewTargetDirectory)+NewTargetFilename) then
NewTargetFilename:='lazarus.new'+GetExecutableExt(NewTargetOS)
end;
end else begin
// no user defined target directory
// => find it automatically
if CrossCompiling then
begin
// Case 2. crosscompiling the IDE
// create directory <primary config dir>/bin/<TargetCPU>-<TargetOS>
NewTargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin'
+PathDelim+NewTargetOS+'-'+NewTargetCPU;
Macros.SubstituteStr(NewUnitDirectory);
debugln('CreateBuildLazarusOptions Options.TargetOS=',Options.FPCTargetOS,' Options.TargetCPU=',
Options.FPCTargetCPU,' DefaultOS=',DefaultTargetOS,' DefaultCPU=',DefaultTargetCPU);
//DebugLn(['CreateBuildLazarusOptions NewTargetOS=',NewTargetOS,' NewTargetCPU=',NewTargetCPU]);
if (Options.TargetDirectory<>'') then begin
// Case 1. the user has set a target directory
NewTargetDirectory:=Options.TargetDirectory;
if not Macros.SubstituteStr(NewTargetDirectory) then begin
debugln('CreateBuildLazarusOptions macro aborted Options.TargetDirectory=',Options.TargetDirectory);
Result:=mrAbort;
exit;
end;
NewTargetDirectory:=CleanAndExpandDirectory(NewTargetDirectory);
debugln('CreateBuildLazarusOptions Options.TargetDirectory=',NewTargetDirectory);
Result:=ForceDirectoryInteractive(NewTargetDirectory,[]);
if Result<>mrOk then exit;
if ExeLocked then begin
// Allow for the case where this corresponds to the current executable
NewTargetFilename:='lazarus'+GetExecutableExt(NewTargetOS);
if FileExistsUTF8(AppendPathDelim(NewTargetDirectory)+NewTargetFilename) then
NewTargetFilename:='lazarus.new'+GetExecutableExt(NewTargetOS)
end;
end else begin
// -> normal compile for this platform
// no user defined target directory
// => find it automatically
// get lazarus directory
if Macros<>nil then begin
NewTargetDirectory:='$(LazarusDir)';
Macros.SubstituteStr(NewTargetDirectory);
end;
if (NewTargetDirectory<>'') and DirPathExists(NewTargetDirectory) then
if CrossCompiling then
begin
if not DirectoryIsWritableCached(NewTargetDirectory) then begin
// Case 3. the lazarus directory is not writable
// create directory <primary config dir>/bin/
UpdateRevisionInc:=false;
NewTargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin';
NewUnitDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'units'
+PathDelim+NewTargetCPU+'-'+NewTargetOS;
debugln('CreateBuildLazarusOptions LazDir readonly NewTargetDirectory=',NewTargetDirectory);
Result:=ForceDirectoryInteractive(NewTargetDirectory,[]);
if Result<>mrOk then exit;
end else begin
// the lazarus directory is writable
if ExeLocked then begin
// Case 4. the current executable is locked
// => use a different output name
NewTargetFilename:='lazarus.new'+GetExecutableExt(NewTargetOS);
debugln('CreateBuildLazarusOptions exe locked NewTargetFilename=',NewTargetFilename);
end else begin
// Case 5. or else: => just compile to current directory
NewTargetDirectory:='';
end;
end;
// Case 2. crosscompiling the IDE
// create directory <primary config dir>/bin/<TargetCPU>-<TargetOS>
NewTargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin'
+PathDelim+NewTargetOS+'-'+NewTargetCPU;
Macros.SubstituteStr(NewUnitDirectory);
debugln('CreateBuildLazarusOptions Options.TargetOS=',Options.FPCTargetOS,' Options.TargetCPU=',
Options.FPCTargetCPU,' DefaultOS=',DefaultTargetOS,' DefaultCPU=',DefaultTargetCPU);
Result:=ForceDirectoryInteractive(NewTargetDirectory,[]);
if Result<>mrOk then exit;
end else begin
// lazarus dir is not valid (probably someone is experimenting)
// -> just compile to current directory
NewTargetDirectory:='';
// -> normal compile for this platform
// get lazarus directory
if Macros<>nil then begin
NewTargetDirectory:='$(LazarusDir)';
Macros.SubstituteStr(NewTargetDirectory);
end;
if (NewTargetDirectory<>'') and DirPathExists(NewTargetDirectory) then
begin
if not DirectoryIsWritableCached(NewTargetDirectory) then begin
// Case 3. the lazarus directory is not writable
// create directory <primary config dir>/bin/
UpdateRevisionInc:=false;
NewTargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin';
NewUnitDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'units'
+PathDelim+NewTargetCPU+'-'+NewTargetOS;
debugln('CreateBuildLazarusOptions LazDir readonly NewTargetDirectory=',NewTargetDirectory);
Result:=ForceDirectoryInteractive(NewTargetDirectory,[]);
if Result<>mrOk then exit;
end else begin
// the lazarus directory is writable
if ExeLocked then begin
// Case 4. the current executable is locked
// => use a different output name
NewTargetFilename:='lazarus.new'+GetExecutableExt(NewTargetOS);
debugln('CreateBuildLazarusOptions exe locked NewTargetFilename=',NewTargetFilename);
end else begin
// Case 5. or else: => just compile to current directory
NewTargetDirectory:='';
end;
end;
end else begin
// lazarus dir is not valid (probably someone is experimenting)
// -> just compile to current directory
NewTargetDirectory:='';
end;
end;
end;
end;
OutputDirRedirected:=NewTargetDirectory<>'';
OutputDirRedirected:=NewTargetDirectory<>'';
// create apple bundle if needed
//debugln(['CreateBuildLazarusOptions NewTargetDirectory=',NewTargetDirectory]);
if (Options.TargetPlatform in [lpCarbon,lpCocoa])
and (NewTargetDirectory<>'')
and (DirectoryIsWritableCached(NewTargetDirectory)) then begin
CurTargetFilename:=NewTargetFilename;
if CurTargetFilename='' then
CurTargetFilename:='lazarus'+GetExecutableExt(NewTargetOS);
if not FilenameIsAbsolute(CurTargetFilename) then
CurTargetFilename:=NewTargetDirectory+PathDelim+CurTargetFilename;
BundleDir:=ChangeFileExt(CurTargetFilename,'.app');
//debugln(['CreateBuildLazarusOptions checking bundle ',BundleDir]);
if not FileExistsCached(BundleDir) then begin
//debugln(['CreateBuildLazarusOptions CurTargetFilename=',CurTargetFilename]);
Result:=CreateApplicationBundle(CurTargetFilename, 'Lazarus');
if not (Result in [mrOk,mrIgnore]) then begin
debugln(['CreateBuildLazarusOptions CreateApplicationBundle failed']);
if IDEMessagesWindow<>nil then
IDEMessagesWindow.AddMsg('Error: failed to create application bundle '+BundleDir,NewTargetDirectory,-1);
exit;
end;
Result:=CreateAppBundleSymbolicLink(CurTargetFilename);
if not (Result in [mrOk,mrIgnore]) then begin
debugln(['CreateBuildLazarusOptions CreateAppBundleSymbolicLink failed']);
if IDEMessagesWindow<>nil then
IDEMessagesWindow.AddMsg('Error: failed to create application bundle symlink to '+CurTargetFilename,NewTargetDirectory,-1);
exit;
// create apple bundle if needed
//debugln(['CreateBuildLazarusOptions NewTargetDirectory=',NewTargetDirectory]);
if (Options.TargetPlatform in [lpCarbon,lpCocoa])
and (NewTargetDirectory<>'')
and (DirectoryIsWritableCached(NewTargetDirectory)) then begin
CurTargetFilename:=NewTargetFilename;
if CurTargetFilename='' then
CurTargetFilename:='lazarus'+GetExecutableExt(NewTargetOS);
if not FilenameIsAbsolute(CurTargetFilename) then
CurTargetFilename:=NewTargetDirectory+PathDelim+CurTargetFilename;
BundleDir:=ChangeFileExt(CurTargetFilename,'.app');
//debugln(['CreateBuildLazarusOptions checking bundle ',BundleDir]);
if not FileExistsCached(BundleDir) then begin
//debugln(['CreateBuildLazarusOptions CurTargetFilename=',CurTargetFilename]);
Result:=CreateApplicationBundle(CurTargetFilename, 'Lazarus');
if not (Result in [mrOk,mrIgnore]) then begin
debugln(['CreateBuildLazarusOptions CreateApplicationBundle failed']);
if IDEMessagesWindow<>nil then
IDEMessagesWindow.AddMsg('Error: failed to create application bundle '+BundleDir,NewTargetDirectory,-1);
exit;
end;
Result:=CreateAppBundleSymbolicLink(CurTargetFilename);
if not (Result in [mrOk,mrIgnore]) then begin
debugln(['CreateBuildLazarusOptions CreateAppBundleSymbolicLink failed']);
if IDEMessagesWindow<>nil then
IDEMessagesWindow.AddMsg('Error: failed to create application bundle symlink to '+CurTargetFilename,NewTargetDirectory,-1);
exit;
end;
end;
end;
if NewUnitDirectory<>'' then
// FPC interpretes '\ ' as an escape for a space in a path,
// so make sure the directory doesn't end with the path delimeter.
AppendExtraOption('-FU'+ChompPathDelim(NewUnitDirectory));
if NewTargetDirectory<>'' then
// FPC interpretes '\ ' as an escape for a space in a path,
// so make sure the directory doesn't end with the path delimeter.
AppendExtraOption('-FE'+ChompPathDelim(NewTargetDirectory));
if NewTargetFilename<>'' then begin
// FPC automatically changes the last extension (append or replace)
// For example under linux, where executables don't need any extension
// fpc removes the last extension of the -o option.
// Trick fpc:
if GetExecutableExt(NewTargetOS)='' then
NewTargetFilename:=NewTargetFilename+'.dummy';
AppendExtraOption('-o'+NewTargetFilename);
end;
// add package options for IDE
//DebugLn(['CreateBuildLazarusOptions blfUseMakeIDECfg=',blfUseMakeIDECfg in FLags,' ExtraOptions="',AExOptions,'" ',PackageOptions]);
if not (blfUseMakeIDECfg in Flags) then
AppendExtraOption(PackageOptions,false);
end;
if NewUnitDirectory<>'' then
// FPC interpretes '\ ' as an escape for a space in a path,
// so make sure the directory doesn't end with the path delimeter.
AppendExtraOption('-FU'+ChompPathDelim(NewUnitDirectory));
if NewTargetDirectory<>'' then
// FPC interpretes '\ ' as an escape for a space in a path,
// so make sure the directory doesn't end with the path delimeter.
AppendExtraOption('-FE'+ChompPathDelim(NewTargetDirectory));
if NewTargetFilename<>'' then begin
// FPC automatically changes the last extension (append or replace)
// For example under linux, where executables don't need any extension
// fpc removes the last extension of the -o option.
// Trick fpc:
if GetExecutableExt(NewTargetOS)='' then
NewTargetFilename:=NewTargetFilename+'.dummy';
AppendExtraOption('-o'+NewTargetFilename);
end;
// add package options for IDE
//DebugLn(['CreateBuildLazarusOptions blfUseMakeIDECfg=',blfUseMakeIDECfg in FLags,' ExtraOptions="',AExOptions,'" ',PackageOptions]);
if not (blfUseMakeIDECfg in Flags) then
AppendExtraOption(PackageOptions,false);
//DebugLn(['CreateBuildLazarusOptions ',MMDef.Name,' ',AExOptions]);
end;
@ -590,8 +656,10 @@ var
OutputDirRedirected: boolean;
begin
ExOptions:='';
Result:=CreateBuildLazarusOptions(Profiles, Macros, PackageOptions, Flags,
ExOptions, UpdateRevisionInc, OutputDirRedirected);
Result:=CreateBuildLazarusOptions(Profiles,
Profiles.MakeModeDefs.IndexOf(Profiles.MakeModeDefs.ItemIDE),
Macros, PackageOptions, Flags, ExOptions,
UpdateRevisionInc, OutputDirRedirected);
if Result<>mrOk then exit;
Filename:=GetMakeIDEConfigFilename;
try
@ -641,12 +709,46 @@ procedure TConfigureBuildLazarusDlg.FormCreate(Sender: TObject);
var
LCLInterface: TLCLPlatform;
begin
IDEDialogLayoutList.ApplyLayout(Self,700,480);
IDEDialogLayoutList.ApplyLayout(Self,700,529);
Caption := Format(lisConfigureBuildLazarus, ['"', '"']);
BuildIdeRadioGroup.Items.Add(lisLazBuildBuild);
BuildIdeRadioGroup.Items.Add(lisLazBuildCleanBuild);
BuildIdeRadioGroup.ItemIndex:=0;
MakeModeListHeader.Images := IDEImages.Images_16;
with MakeModeListHeader.Sections.Add do
begin
Width := ButtonSize;
MinWidth := Width;
MaxWidth := Width;
ImageIndex := IDEImages.LoadImage(16, 'menu_close');
end;
with MakeModeListHeader.Sections.Add do
begin
Width := ButtonSize;
MinWidth := Width;
MaxWidth := Width;
ImageIndex := IDEImages.LoadImage(16, 'menu_build');
end;
with MakeModeListHeader.Sections.Add do
begin
Width := ButtonSize;
MinWidth := Width;
MaxWidth := Width;
ImageIndex := IDEImages.LoadImage(16, 'menu_build_clean');
end;
with MakeModeListHeader.Sections.Add do
begin
Width := MakeModeListHeader.Width - ModeColumnWidth - 3 * ButtonSize;
MinWidth := Width;
MaxWidth := Width;
Text := lisLazBuildABOPart;
end;
with MakeModeListHeader.Sections.Add do
begin
Width := ModeColumnWidth;
MinWidth := Width;
MaxWidth := Width;
Text := lisLazBuildABOAction;
end;
// Show Build target names in combobox.
LCLWidgetTypeLabel.Caption := lisLCLWidgetType;
@ -751,6 +853,7 @@ end;
procedure TConfigureBuildLazarusDlg.FormShow(Sender: TObject);
begin
CopyMakeModeDefsToUI(fProfiles.MakeModeDefs);
UpdateProfileNamesUI;
end;
@ -759,6 +862,119 @@ begin
LazarusHelp.ShowHelpForIDEControl(Self);
end;
procedure TConfigureBuildLazarusDlg.MakeModeListHeaderResize(Sender: TObject);
begin
if MakeModeListHeader.Sections.Count >= 3 then
MakeModeListHeader.Sections[3].Width := MakeModeListHeader.Width - ModeColumnWidth - 3 * ButtonSize;
end;
procedure TConfigureBuildLazarusDlg.MakeModeListHeaderSectionClick(
HeaderControl: TCustomHeaderControl; Section: THeaderSection);
var
i: Integer;
begin
if Section.Index in [0..2] then begin
with fProfiles.Current do begin
for i := 0 to Length(MakeModes)-1 do
MakeModes[i] := IntToMakeMode(Section.Index);
end;
// Radiobuttons are drawn based on MakeModeSettings in an owner drawn Listbox.
MakeModeListBox.Invalidate;
end;
end;
procedure TConfigureBuildLazarusDlg.MakeModeListBoxDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
var
ButtonState: TThemedButton;
ButtonDetails: TThemedElementDetails;
x: Integer;
ButtonRect: TRect;
TxtH: Integer;
CurRect: TRect;
CurMmDef: TMakeModeDef;
CurMmVal, mm: TMakeMode;
RadioSize: TSize;
begin
if (Index<0) or (Profiles.Count=0) or (Index>=Profiles.MakeModeDefs.Count) then exit;
CurMmDef:=Profiles.MakeModeDefs[Index];
CurMmVal:=fProfiles.Current.MakeModes[Index];
TxtH:=MakeModeListBox.Canvas.TextHeight(CurMmDef.Description);
CurRect:=ARect;
MakeModeListBox.Canvas.Brush.Style:=bsSolid;
MakeModeListBox.Canvas.FillRect(CurRect);
// draw the buttons
x:=0;
for mm:=Low(TMakeMode) to High(TMakeMode) do
begin
// draw button
ButtonRect.Left:=x;
ButtonRect.Top:=ARect.Top+((ARect.Bottom-ARect.Top-ButtonSize) div 2);
ButtonRect.Right:=x+ButtonSize;
ButtonRect.Bottom:=ButtonRect.Top + ButtonSize;
if CurMmVal = mm then // checked
ButtonState := tbRadioButtonCheckedNormal
else
ButtonState := tbRadioButtonUncheckedNormal;
ButtonDetails := ThemeServices.GetElementDetails(ButtonState);
if ThemeServices.HasTransparentParts(ButtonDetails) then
MakeModeListBox.Canvas.FillRect(ButtonRect);
RadioSize := ThemeServices.GetDetailSize(ButtonDetails);
if (RadioSize.cx <> -1) and (RadioSize.cy <> -1) then
begin
ButtonRect.Left := (ButtonRect.Left + ButtonRect.Right - RadioSize.cx) div 2;
ButtonRect.Right := ButtonRect.Left + RadioSize.cx;
ButtonRect.Top := (ButtonRect.Top + ButtonRect.Bottom - RadioSize.cy) div 2;
ButtonRect.Bottom := ButtonRect.Top + RadioSize.cy;
end;
ThemeServices.DrawElement(
MakeModeListBox.Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
ButtonDetails, ButtonRect);
Inc(x, ButtonSize);
end;
MakeModeListBox.Canvas.Brush.Style:=bsClear;
MakeModeListBox.Canvas.TextOut(x+2, ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2,
CurMmDef.Description);
// draw make mode text
x:=MakeModeListBox.ClientWidth-ModeColumnWidth;
MakeModeListBox.Canvas.TextOut(x+2, ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2,
GetTranslatedMakeModes(CurMmVal));
end;
procedure TConfigureBuildLazarusDlg.MakeModeListBoxMouseDown(Sender: TOBject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
NewMakeMode: TMakeMode;
i: Integer;
begin
if not GetMakeModeAtX(X, NewMakeMode) then
exit;
i:=MakeModeListBox.ItemAtPos(Point(X,Y),true);
if (i < 0) or (i >= Profiles.MakeModeDefs.Count) then
exit;
Profiles.Current.MakeModes[i]:=NewMakeMode;
MakeModeListBox.Invalidate;
end;
procedure TConfigureBuildLazarusDlg.MakeModeListBoxShowHint(Sender: TObject; HintInfo: PHintInfo);
var
MakeMode: TMakeMode;
i: Integer;
begin
with HintInfo^ do begin
HintStr:='';
if not GetMakeModeAtX(CursorPos.X, MakeMode) then exit;
i:=MakeModeListBox.ItemAtPos(CursorPos,true);
if (i<0) or (i>=Profiles.MakeModeDefs.Count) then exit;
HintStr:=MakeModeNames[MakeMode];
end;
end;
procedure TConfigureBuildLazarusDlg.ShowOptsMenuItemClick(Sender: TObject);
begin
CopyUIToProfile(Profiles.Current);
@ -784,6 +1000,16 @@ begin
end;
end;
procedure TConfigureBuildLazarusDlg.CopyMakeModeDefsToUI(AMakeModeDefs: TMakeModeDefs);
var
i: Integer;
begin
MakeModeListBox.Items.BeginUpdate;
for i:=0 to AMakeModeDefs.Count-1 do
MakeModeListBox.Items.Add(AMakeModeDefs[i].Description);
MakeModeListBox.Items.EndUpdate;
end;
procedure TConfigureBuildLazarusDlg.CopyProfileToUI(AProfile: TBuildLazarusProfile);
var
i: Integer;
@ -794,7 +1020,6 @@ begin
TargetOSComboBox.Text :=AProfile.TargetOS;
TargetDirectoryComboBox.Text :=AProfile.TargetDirectory;
TargetCPUComboBox.Text :=AProfile.TargetCPU;
BuildIdeRadioGroup.ItemIndex :=ord(AProfile.IdeBuildMode);
OptionsMemo.Lines.Assign(AProfile.OptionsLines);
for i:=0 to DefinesListBox.Items.Count-1 do
DefinesListBox.Checked[i]:=AProfile.Defines.IndexOf(DefinesListBox.Items[i]) > -1;
@ -810,7 +1035,6 @@ begin
AProfile.TargetOS :=TargetOSComboBox.Text;
AProfile.TargetDirectory :=TargetDirectoryComboBox.Text;
AProfile.TargetCPU :=TargetCPUComboBox.Text;
AProfile.IdeBuildMode :=TIdeBuildMode(BuildIdeRadioGroup.ItemIndex);
AProfile.OptionsLines.Assign(OptionsMemo.Lines);
AProfile.Defines.Clear;
for i:=0 to DefinesListBox.Items.Count-1 do
@ -838,6 +1062,42 @@ begin
fUpdatingProfileCombo:=False;
RestartAfterBuildCheckBox.Checked:=fProfiles.RestartAfterBuild;
ConfirmBuildCheckBox.Checked :=fProfiles.ConfirmBuild;
MakeModeListBox.Invalidate; // Triggers owner-drawn update.
end;
function TConfigureBuildLazarusDlg.GetMakeModeAtX(const X: Integer;
out MakeMode: TMakeMode): boolean;
var
i: integer;
begin
Result:=True;
MakeMode:=mmNone;
i := X div ButtonSize;
case i of
0: MakeMode:=mmNone;
1: MakeMode:=mmBuild;
2: MakeMode:=mmCleanBuild;
else
Result:=False;
end;
end;
function TConfigureBuildLazarusDlg.MakeModeToInt(MakeMode: TMakeMode): integer;
begin
case MakeMode of
mmBuild: Result:=1;
mmCleanBuild: Result:=2;
else Result:=0;
end;
end;
function TConfigureBuildLazarusDlg.IntToMakeMode(i: integer): TMakeMode;
begin
case i of
1: Result:=mmBuild;
2: Result:=mmCleanBuild;
else Result:=mmNone;
end;
end;
procedure TConfigureBuildLazarusDlg.PrepareClose;
@ -951,8 +1211,10 @@ begin
CopyUIToProfile(fProfiles.Current); // Save old selection from UI.
fProfiles.CurrentIndex:=(Sender as TComboBox).ItemIndex;
CopyProfileToUI(fProfiles.Current); // Copy new selection to UI.
MakeModeListBox.Invalidate;
end;
end;
end.

View File

@ -1726,7 +1726,8 @@ begin
end;
function TBuildManager.OnRunCompilerWithOptions(
ExtTool: TIDEExternalToolOptions; CompOptions: TBaseCompilerOptions): TModalResult;
ExtTool: TIDEExternalToolOptions; CompOptions: TBaseCompilerOptions
): TModalResult;
begin
if SourceEditorManagerIntf<>nil then
SourceEditorManagerIntf.ClearErrorLines;
@ -2078,16 +2079,18 @@ var
NewTargetOS: String;
NewTargetCPU: String;
NewLCLWidgetSet: TLCLPlatform;
BuildIDE: Boolean;
begin
with MiscellaneousOptions do begin
NewTargetOS:=LowerCase(BuildLazOpts.TargetOS);
NewTargetCPU:=LowerCase(BuildLazOpts.TargetCPU);
NewLCLWidgetSet:=BuildLazOpts.TargetPlatform;
BuildIDE:=BuildLazProfiles.CurrentIdeMode in [mmBuild,mmCleanBuild];
end;
//debugln(['TBuildManager.BuildTargetIDEIsDefault NewTargetOS=',NewTargetOS,' Default=',GetDefaultTargetOS,' NewTargetCPU=',NewTargetCPU,' default=',GetDefaultTargetCPU,' ws=',LCLPlatformDisplayNames[NewLCLWidgetSet],' default=',LCLPlatformDisplayNames[GetDefaultLCLWidgetType]]);
Result:=((NewTargetOS='') or (NewTargetOS=GetDefaultTargetOS))
and ((NewTargetCPU='') or (NewTargetCPU=GetDefaultTargetCPU))
and (NewLCLWidgetSet<>lpNoGUI);
Result:=BuildIDE and ((NewTargetOS='') or (NewTargetOS=GetDefaultTargetOS))
and ((NewTargetCPU='') or (NewTargetCPU=GetDefaultTargetCPU))
and (NewLCLWidgetSet<>lpNoGUI);
end;
end.

View File

@ -40,10 +40,59 @@ uses
type
TIdeBuildMode = (
bmBuild,
bmCleanBuild
TMakeMode = (
mmNone,
mmBuild,
mmCleanBuild
);
TMakeModes = set of TMakeMode;
// Used for the actual mode settings in profiles.
TMakeModeSettings = array of TMakeMode;
{ TMakeModeDef }
TMakeModeDef = class
private
fName: string;
fDescription: string;
fDirectory: string;
fDefaultMakeMode: TMakeMode;
fCommands: array[TMakeMode] of string;
function GetCommands(Mode: TMakeMode): string;
procedure SetCommands(Mode: TMakeMode; const AValue: string);
public
constructor Create;
constructor Create(const NewName, NewDescription, NewDirectory: string;
const NewMakeMode: TMakeMode);
destructor Destroy; override;
procedure Clear;
procedure Assign(Source: TMakeModeDef);
public
property Name: string read fName write fName;
property Description: string read fDescription write fDescription;
property Directory: string read fDirectory write fDirectory;
property DefaultMakeMode: TMakeMode read fDefaultMakeMode write fDefaultMakeMode;
property Commands[Mode: TMakeMode]: string read GetCommands write SetCommands;
end;
{ TMakeModeDefs }
TMakeModeDefs = class(TObjectList)
private
fItemIDE: TMakeModeDef;
fItemIDEIndex: integer;
function GetItems(Index: integer): TMakeModeDef;
public
constructor Create;
destructor Destroy; override;
procedure Clear; override;
procedure Assign(Source: TMakeModeDefs);
// Show the permanent description part in ListBox
function FindName(const Name: string): TMakeModeDef;
public
property ItemIDE: TMakeModeDef read fItemIDE;
property Items[Index: integer]: TMakeModeDef read GetItems; default;
end;
TBuildLazarusProfiles = class;
@ -53,18 +102,25 @@ type
private
fOwnerCnt: TBuildLazarusProfiles;
fName: string;
fCleanAll: boolean;
fTargetOS: string;
fTargetDirectory: string;
fTargetCPU: string;
fTargetPlatform: TLCLPlatform;
fIdeBuildMode: TIdeBuildMode;
fCleanAll: boolean;
fUpdateRevisionInc: boolean;
fOptions: TStringList; // User defined options.
fDefines: TStringList; // Defines selected for this profile.
// User defined options.
fOptions: TStringList;
// Defines selected for this profile.
fDefines: TStringList;
// MakeModeSettings is Synchronised with TMakeModeDefs, same indexes.
fMakeModes: TMakeModeSettings;
function GetExtraOptions: string;
function GetTargetPlatform: TLCLPlatform;
procedure SetExtraOptions(const AValue: string);
procedure SetTargetCPU(const AValue: string);
procedure SetTargetOS(const AValue: string);
procedure SetTargetPlatform(const AValue: TLCLPlatform);
public
constructor Create(AOwnerCnt: TBuildLazarusProfiles; AName: string);
destructor Destroy; override;
@ -76,27 +132,29 @@ type
public
property Name: string read fName;
property ExtraOptions: string read GetExtraOptions write SetExtraOptions;
property TargetOS: string read fTargetOS write fTargetOS;
property TargetDirectory: string read fTargetDirectory write fTargetDirectory;
property TargetCPU: string read fTargetCPU write fTargetCPU;
property TargetPlatform: TLCLPlatform read fTargetPlatform write fTargetPlatform;
property IdeBuildMode: TIdeBuildMode read fIdeBuildMode write fIdeBuildMode;
property CleanAll: boolean read fCleanAll write fCleanAll;
property TargetOS: string read fTargetOS write SetTargetOS;
property TargetDirectory: string read fTargetDirectory write fTargetDirectory;
property TargetCPU: string read fTargetCPU write SetTargetCPU;
property TargetPlatform: TLCLPlatform read GetTargetPlatform write SetTargetPlatform;
property UpdateRevisionInc: boolean read fUpdateRevisionInc write fUpdateRevisionInc;
property OptionsLines: TStringList read fOptions;
property Defines: TStringList read fDefines;
property MakeModes: TMakeModeSettings read fMakeModes;
end;
{ TBuildLazarusProfiles }
TBuildLazarusProfiles = class(TObjectList)
private
fMakeModeDefs: TMakeModeDefs;
fRestartAfterBuild: boolean;
fConfirmBuild: boolean;
fAllDefines: TStringList;
fSelected: TStringList;
fStaticAutoInstallPackages: TStringList;
fCurrentIndex: integer;
function GetCurrentIdeMode: TMakeMode;
function GetCurrentProfile: TBuildLazarusProfile;
function GetItems(Index: integer): TBuildLazarusProfile;
public
@ -110,6 +168,7 @@ type
procedure Save(XMLConfig: TXMLConfig; const Path: string);
procedure Move(CurIndex, NewIndex: Integer); // Replaces TList.Move
public
property MakeModeDefs: TMakeModeDefs read fMakeModeDefs;
property RestartAfterBuild: boolean read fRestartAfterBuild write fRestartAfterBuild;
property ConfirmBuild: boolean read fConfirmBuild write fConfirmBuild;
property AllDefines: TStringList read fAllDefines;
@ -117,6 +176,7 @@ type
property StaticAutoInstallPackages: TStringList read fStaticAutoInstallPackages;
property CurrentIndex: integer read fCurrentIndex write fCurrentIndex;
property Current: TBuildLazarusProfile read GetCurrentProfile;
property CurrentIdeMode: TMakeMode read GetCurrentIdeMode;
property Items[Index: integer]: TBuildLazarusProfile read GetItems; default;
end;
@ -152,6 +212,9 @@ type
end;
const
MakeModeNames: array[TMakeMode] of string = ('None', 'Build', 'Clean+Build' );
var
BuildProfileManagerForm: TBuildProfileManagerForm;
@ -167,22 +230,127 @@ const
DefaultTargetDirectory = ''; // empty will be replaced by '$(ConfDir)/bin';
function IdeBuildModeToStr(BuildMode: TIdeBuildMode): string;
function StrToMakeMode(const s: string): TMakeMode;
begin
case BuildMode of
bmBuild: Result:='Build';
bmCleanBuild: Result:='Clean+Build';
for Result:=Succ(mmNone) to High(TMakeMode) do
if CompareText(s,MakeModeNames[Result])=0 then exit;
Result:=mmNone;
end;
{ TMakeModeDef }
function TMakeModeDef.GetCommands(Mode: TMakeMode): string;
begin
Result:=fCommands[Mode];
end;
procedure TMakeModeDef.SetCommands(Mode: TMakeMode; const AValue: string);
begin
fCommands[Mode]:=AValue;
end;
constructor TMakeModeDef.Create;
begin
inherited Create;
Clear;
end;
constructor TMakeModeDef.Create(const NewName, NewDescription,
NewDirectory: string; const NewMakeMode: TMakeMode);
begin
inherited Create;
Clear;
Name:=NewName;
Description:=NewDescription;
Directory:=NewDirectory;
DefaultMakeMode:=NewMakeMode;
end;
destructor TMakeModeDef.Destroy;
begin
Clear;
inherited Destroy;
end;
procedure TMakeModeDef.Clear;
begin
FCommands[mmNone]:='';
FCommands[mmBuild]:='all';
FCommands[mmCleanBuild]:='clean all';
FDirectory:='';
FName:='';
end;
procedure TMakeModeDef.Assign(Source: TMakeModeDef);
var
mm: TMakeMode;
begin
if (Source=nil) or (Source=Self) then exit;
Name:=Source.Name;
Description:=Source.Description;
Directory:=Source.Directory;
DefaultMakeMode:=Source.DefaultMakeMode;
for mm:=Low(TMakeMode) to High(TMakeMode) do
Commands[mm]:=Source.Commands[mm];
end;
{ TMakeModeDefs }
function TMakeModeDefs.GetItems(Index: integer): TMakeModeDef;
begin
Result:=TMakeModeDef(inherited Items[Index]);
end;
constructor TMakeModeDefs.Create;
begin
inherited Create;
// Hard-coded build values = IDE
FItemIDE:=TMakeModeDef.Create('IDE',lisIDE,'',mmBuild);
FItemIDE.Commands[mmBuild]:='ide';
FItemIDE.Commands[mmCleanBuild]:='cleanide ide';
fItemIDEIndex:=Add(FItemIDE);
end;
destructor TMakeModeDefs.Destroy;
begin
inherited Destroy; // Items are owned by ObjectList and are freed here.
end;
procedure TMakeModeDefs.Clear;
begin
FItemIDE:=nil;
inherited Clear; // Items are freed here, too.
end;
procedure TMakeModeDefs.Assign(Source: TMakeModeDefs);
var
i: Integer;
SrcItem, NewItem: TMakeModeDef;
begin
Clear;
for i:=0 to Source.Count-1 do begin
SrcItem:=Source.Items[i];
NewItem:=TMakeModeDef.Create;
NewItem.Assign(SrcItem);
Add(NewItem);
end;
fItemIDE:=FindName('IDE');
fItemIDEIndex:=Source.fItemIDEIndex;
end;
function StrToIdeBuildMode(const s: string): TIdeBuildMode;
function TMakeModeDefs.FindName(const Name: string): TMakeModeDef;
var
i: Integer;
begin
Result:=bmBuild;
if s='Clean+Build' then
Result:=bmCleanBuild;
Result:=nil;
for i:=0 to Count-1 do
if CompareText(Name,Items[i].Name)=0 then begin
Result:=Items[i];
exit;
end;
end;
{ TBuildLazarusProfile }
constructor TBuildLazarusProfile.Create(AOwnerCnt: TBuildLazarusProfiles;
@ -195,6 +363,10 @@ begin
fName:=AName;
fOptions:=TStringList.Create;
fDefines:=TStringList.Create;
// Set default values for MakeModes.
SetLength(fMakeModes, fOwnerCnt.fMakeModeDefs.Count);
for i:=0 to fOwnerCnt.fMakeModeDefs.Count-1 do
fMakeModes[i]:=fOwnerCnt.fMakeModeDefs[i].DefaultMakeMode;
end;
destructor TBuildLazarusProfile.Destroy;
@ -209,6 +381,12 @@ var
i: Integer;
LCLPlatformStr: string;
begin
// fBuildItems and fMakeModes are synchronized, can use the same index.
with fOwnerCnt do
for i:=0 to fMakeModeDefs.Count-1 do
fMakeModes[i]:=StrToMakeMode(XMLConfig.GetValue(
Path+'Build'+fMakeModeDefs[i].Name+'/Value',
MakeModeNames[fMakeModeDefs[i].DefaultMakeMode]));
FCleanAll :=XMLConfig.GetValue(Path+'CleanAll/Value',false);
TargetOS :=XMLConfig.GetValue(Path+'TargetOS/Value','');
TargetCPU :=XMLConfig.GetValue(Path+'TargetCPU/Value','');
@ -219,7 +397,6 @@ begin
fTargetPlatform :=DirNameToLCLPlatform(LCLPlatformStr);
FTargetDirectory:=AppendPathDelim(SetDirSeparators(
XMLConfig.GetValue(Path+'TargetDirectory/Value', DefaultTargetDirectory)));
IdeBuildMode:=StrToIdeBuildMode(XMLConfig.GetValue(Path+'IdeBuildMode/Value',''));
FUpdateRevisionInc :=XMLConfig.GetValue(Path+'UpdateRevisionInc/Value',true);
LoadStringList(XMLConfig,fOptions,Path+'Options/');
if fOptions.Count=0 then // Support a syntax used earlier by profiles.
@ -231,6 +408,12 @@ procedure TBuildLazarusProfile.Save(XMLConfig: TXMLConfig; const Path: string);
var
i: Integer;
begin
with fOwnerCnt do
for i:=0 to fMakeModeDefs.Count-1 do begin
XMLConfig.SetDeleteValue(Path+'Build'+fMakeModeDefs[i].Name+'/Value',
MakeModeNames[fMakeModes[i]],
MakeModeNames[fMakeModeDefs[i].DefaultMakeMode]);
end;
XMLConfig.SetDeleteValue(Path+'CleanAll/Value',FCleanAll,false);
XMLConfig.SetDeleteValue(Path+'TargetOS/Value',TargetOS,'');
XMLConfig.SetDeleteValue(Path+'TargetCPU/Value',TargetCPU,'');
@ -239,7 +422,6 @@ begin
''); //LCLPlatformDirNames[GetDefaultLCLWidgetType]
XMLConfig.SetDeleteValue(Path+'TargetDirectory/Value',
FTargetDirectory,DefaultTargetDirectory);
XMLConfig.SetDeleteValue(Path+'IdeBuildMode/Value',IdeBuildModeToStr(IdeBuildMode),'');
XMLConfig.SetDeleteValue(Path+'UpdateRevisionInc/Value',FUpdateRevisionInc,true);
SaveStringList(XMLConfig,fOptions,Path+'Options/');
SaveStringList(XMLConfig,fDefines,Path+'Defines/');
@ -257,10 +439,11 @@ begin
TargetDirectory :=Source.TargetDirectory;
TargetCPU :=Source.TargetCPU;
TargetPlatform :=Source.TargetPlatform;
IdeBuildMode :=Source.IdeBuildMode;
UpdateRevisionInc :=Source.UpdateRevisionInc;
fOptions.Assign(Source.fOptions);
fDefines.Assign(Source.fDefines);
for i:=0 to Length(fMakeModes)-1 do
fMakeModes[i]:=Source.MakeModes[i];
end;
function TBuildLazarusProfile.FPCTargetOS: string;
@ -273,6 +456,30 @@ begin
Result:=GetFPCTargetCPU(TargetCPU);
end;
procedure TBuildLazarusProfile.SetTargetCPU(const AValue: string);
begin
if FTargetCPU=AValue then exit;
FTargetCPU:=AValue;
end;
procedure TBuildLazarusProfile.SetTargetOS(const AValue: string);
begin
if fTargetOS=AValue then exit;
fTargetOS:=AValue;
end;
function TBuildLazarusProfile.GetTargetPlatform: TLCLPlatform;
begin
Result:=fTargetPlatform;
// if Result=lpDefault then
// Result:=GetDefaultLCLWidgetType;
end;
procedure TBuildLazarusProfile.SetTargetPlatform(const AValue: TLCLPlatform);
begin
fTargetPlatform:=AValue;
end;
function TBuildLazarusProfile.GetExtraOptions: string;
var
i: Integer;
@ -297,6 +504,7 @@ end;
constructor TBuildLazarusProfiles.Create;
begin
inherited Create;
fMakeModeDefs:=TMakeModeDefs.Create;
fRestartAfterBuild:=True;
fConfirmBuild:=True;
fAllDefines:=TStringList.Create;
@ -306,6 +514,7 @@ end;
destructor TBuildLazarusProfiles.Destroy;
begin
fMakeModeDefs.Free;
inherited Destroy;
// Clear is called by inherited Destroy. Must be freed later.
fStaticAutoInstallPackages.Free;
@ -327,6 +536,7 @@ var
SrcItem, NewItem: TBuildLazarusProfile;
begin
Clear;
fMakeModeDefs.Assign(Source.MakeModeDefs);
RestartAfterBuild :=Source.RestartAfterBuild;
ConfirmBuild:=Source.ConfirmBuild;
fAllDefines.Assign(Source.fAllDefines);
@ -363,12 +573,24 @@ var
begin
Platfrm:=GetDefaultLCLWidgetType;
// Build IDE without Packages
Profile:=TBuildLazarusProfile.Create(Self, lisLazBuildIDEwithoutPackages);
with Profile, fOwnerCnt do begin
fCleanAll:=False;
fTargetPlatform:=Platfrm;
for i:=0 to fMakeModeDefs.Count-1 do
if fMakeModeDefs[i].Description=lisIDE then
fMakeModes[i]:=mmBuild
else
fMakeModes[i]:=mmNone;
end;
Add(Profile);
// Build Debug IDE
Profile:=TBuildLazarusProfile.Create(Self, lisLazBuildDebugIDE);
with Profile, fOwnerCnt do begin
fCleanAll:=False;
fTargetPlatform:=Platfrm;
fIdeBuildMode:=bmBuild;
fUpdateRevisionInc:=True;
{$IFDEF Darwin}
// FPC on darwin has a bug with -Cr
@ -376,6 +598,11 @@ begin
{$ELSE}
fOptions.Add('-gw -gl -godwarfsets -gh -gt -Co -Cr -Ci -Sa');
{$ENDIF}
for i:=0 to fMakeModeDefs.Count-1 do
if fMakeModeDefs[i].Description=lisIDE then
fMakeModes[i]:=mmBuild
else
fMakeModes[i]:=mmNone;
end;
// Return this one as default. Needed when building packages without saved profiles.
Result:=Add(Profile);
@ -385,9 +612,13 @@ begin
with Profile, fOwnerCnt do begin
fCleanAll:=False;
fTargetPlatform:=Platfrm;
fIdeBuildMode:=bmBuild;
fUpdateRevisionInc:=True;
fOptions.Add('-O2 -g- -Xs');
for i:=0 to fMakeModeDefs.Count-1 do
if fMakeModeDefs[i].Description=lisIDE then
fMakeModes[i]:=mmBuild
else
fMakeModes[i]:=mmNone;
end;
Add(Profile);
@ -396,8 +627,9 @@ begin
with Profile, fOwnerCnt do begin
fCleanAll:=False;
fTargetPlatform:=Platfrm;
fIdeBuildMode:=bmCleanBuild;
fUpdateRevisionInc:=True;
for i:=0 to fMakeModeDefs.Count-1 do
fMakeModes[i]:=mmCleanBuild;
end;
Add(Profile);
@ -500,6 +732,11 @@ begin
Result:=Items[fCurrentIndex];
end;
function TBuildLazarusProfiles.GetCurrentIdeMode: TMakeMode;
begin
Result:=Current.fMakeModes[fMakeModeDefs.fItemIDEIndex]
end;
function TBuildLazarusProfiles.GetItems(Index: integer): TBuildLazarusProfile;
begin
Result:=TBuildLazarusProfile(inherited Items[Index]);
@ -640,7 +877,9 @@ var
begin
i:=ProfilesListbox.ItemIndex;
if i<1 then exit;
// Update ProfsToManage collection.
fProfsToManage.Move(i,i-1);
// Update ListBox
ProfilesListbox.Items.Move(i,i-1);
ProfilesListbox.ItemIndex:=i-1;
EnableButtons;
@ -652,7 +891,9 @@ var
begin
i:=ProfilesListbox.ItemIndex;
if (i<0) or (i>=ProfilesListbox.Items.Count-1) then exit;
// Update ProfsToManage collection.
fProfsToManage.Move(i,i+1);
// Update ListBox
ProfilesListbox.Items.Move(i,i+1);
ProfilesListbox.ItemIndex:=i+1;
EnableButtons;

View File

@ -2873,6 +2873,7 @@ resourcestring
lisCTDTemplates = 'Templates';
lisSaveSettings = 'Save Settings';
lisLazBuildCancel = 'Cancel';
lisLazBuildNone = 'None';
lisLazBuildBuild = 'Build';
lisLazBuildBuildAdvanced = 'Build Advanced';
lisLazBuildCleanBuild = 'Clean+Build';
@ -2887,6 +2888,7 @@ resourcestring
lisLazCleanUpBuildAll = 'Clean Up + Build all';
lisLazBuildAdvancedBuildOptions = 'Advanced Build Options';
lisLazBuildABOPart = 'Part';
lisLazBuildABOAction = 'Action';
lisLazBuildABOChooseOutputDir = 'Choose output directory of the IDE executable ';
lisLazBuildDefines = 'Defines';

View File

@ -399,6 +399,9 @@ var
CurResult: TModalResult;
BuildLazProfiles: TBuildLazarusProfiles;
CurProf: TBuildLazarusProfile;
MMDefs: TMakeModeDefs;
MMDef: TMakeModeDef;
MakeMode: TMakeMode;
PkgOptions: String;
InheritedOptionStrings: TInheritedCompOptsStrings;
TargetDir: String;
@ -409,6 +412,7 @@ begin
LoadMiscellaneousOptions;
BuildLazProfiles:=MiscellaneousOptions.BuildLazProfiles;
MMDefs:=BuildLazProfiles.MakeModeDefs;
CurProf:=BuildLazProfiles.Current;
if (Length(OSOverride) <> 0) then
CurProf.TargetOS:=OSOverride;
@ -420,8 +424,25 @@ begin
else
CurProf.TargetPlatform:=GetDefaultLCLWidgetType;
CurProf.ExtraOptions:=BuildIDEOptions;
if BuildAll then
MakeMode:=mmNone;
if BuildAll then begin
CurProf.CleanAll:=true;
MakeMode:=mmBuild;
end;
for i:=0 to MMDefs.Count-1 do begin
MMDef:=MMDefs[i];
if (MMDefs.IndexOf(MMDef) < MMDefs.IndexOf(MMDefs.ItemIDE))
then
// these items are needed for the IDE
CurProf.MakeModes[i]:=MakeMode
else if MMDef=MMDefs.ItemIDE then
// always build the IDE
CurProf.MakeModes[i]:=mmBuild
else
// these are goodies (examples)
CurProf.MakeModes[i]:=mmNone;
end;
MainBuildBoss.SetBuildTargetIDE;
Flags:=[];
@ -454,7 +475,8 @@ begin
PackageGraph.FirstAutoInstallDependency,InheritedOptionStrings{%H-});
// save
CurResult:=SaveIDEMakeOptions(BuildLazProfiles,GlobalMacroList,PkgOptions,Flags);
CurResult:=SaveIDEMakeOptions(BuildLazProfiles,
GlobalMacroList,PkgOptions,Flags+[blfOnlyIDE]);
if CurResult<>mrOk then begin
DebugLn('TLazBuildApplication.BuildLazarusIDE: failed saving idemake.cfg');
exit;
@ -465,7 +487,8 @@ begin
EnvironmentOptions.ExternalTools,GlobalMacroList,
PkgOptions,EnvironmentOptions.CompilerFilename,
EnvironmentOptions.MakeFilename,
Flags+[blfUseMakeIDECfg,blfReplaceExe]);
Flags+[blfUseMakeIDECfg,blfOnlyIDE,blfReplaceExe]
);
if CurResult<>mrOk then begin
DebugLn('TLazBuildApplication.BuildLazarusIDE: Building IDE failed.');
exit;

View File

@ -12123,7 +12123,8 @@ end;
//-----------------------------------------------------------------------------
function TMainIDE.DoRunExternalTool(Index: integer; ShowAbort: Boolean): TModalResult;
function TMainIDE.DoRunExternalTool(Index: integer; ShowAbort: Boolean
): TModalResult;
begin
SourceEditorManager.ClearErrorLines;
Result:=ExternalTools.Run(Index,GlobalMacroList,ShowAbort);
@ -12135,6 +12136,7 @@ var
PkgOptions: string;
InheritedOptionStrings: TInheritedCompOptsStrings;
FPCVersion, FPCRelease, FPCPatch: integer;
IDEBuildFlags: TBuildLazarusFlags;
begin
// create uses section addition for lazarus.pp
Result:=PkgBoss.DoSaveAutoInstallConfig;
@ -12153,8 +12155,9 @@ begin
if (FPCVersion=0) or (FPCRelease=0) or (FPCPatch=0) then ;
// save extra options
IDEBuildFlags:=Flags+[blfOnlyIDE];
Result:=SaveIDEMakeOptions(MiscellaneousOptions.BuildLazProfiles,
GlobalMacroList,PkgOptions,Flags+[blfOnlyIDE]);
GlobalMacroList,PkgOptions,IDEBuildFlags);
if Result<>mrOk then exit;
end;
@ -12189,6 +12192,14 @@ begin
try
MainBuildBoss.SetBuildTargetIDE;
if (blfOnlyIDE in Flags)
and (MiscellaneousOptions.BuildLazProfiles.CurrentIdeMode=mmNone) then begin
debugln(['TMainIDE.DoBuildLazarusSub ignore because blfOnlyIDE and CurrentIdeMode=mmNone']);
CompileProgress.Ready;
Result:=mrIgnore;
exit;
end;
// clean up
if (not (blfDontCleanAll in Flags))
and MiscellaneousOptions.BuildLazProfiles.Current.CleanAll then begin
@ -12196,7 +12207,8 @@ begin
Result:=BuildLazarus(MiscellaneousOptions.BuildLazProfiles,
ExternalTools,GlobalMacroList,
'',EnvironmentOptions.GetCompilerFilename,
EnvironmentOptions.MakeFilename, [blfDontBuild]);
EnvironmentOptions.MakeFilename,
[blfDontBuild]);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Clean up failed.');
exit;
@ -12222,8 +12234,9 @@ begin
PackageGraph.FirstAutoInstallDependency,InheritedOptionStrings);
// check ambiguous units
CodeToolBoss.GetFPCVersionForDirectory(EnvironmentOptions.LazarusDirectory,
FPCVersion,FPCRelease,FPCPatch);
CodeToolBoss.GetFPCVersionForDirectory(
EnvironmentOptions.LazarusDirectory,
FPCVersion,FPCRelease,FPCPatch);
if FPCPatch=0 then ;
CompiledUnitExt:=GetDefaultCompiledUnitExt(FPCVersion,FPCRelease);
Result:=MainBuildBoss.CheckUnitPathForAmbiguousPascalFiles(
@ -12239,13 +12252,15 @@ begin
IDEBuildFlags:=Flags;
if MiscellaneousOptions.BuildLazProfiles.Current.CleanAll then
Include(IDEBuildFlags,blfDontCleanAll);
Result:=SaveIDEMakeOptions(MiscellaneousOptions.BuildLazProfiles,
GlobalMacroList,PkgOptions,IDEBuildFlags-[blfUseMakeIDECfg]);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Save IDEMake options failed.');
exit;
if MiscellaneousOptions.BuildLazProfiles.CurrentIdeMode<>mmNone then begin
Result:=SaveIDEMakeOptions(MiscellaneousOptions.BuildLazProfiles,
GlobalMacroList,PkgOptions,IDEBuildFlags-[blfUseMakeIDECfg]);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Save IDEMake options failed.');
exit;
end;
IDEBuildFlags:=IDEBuildFlags+[blfUseMakeIDECfg];
end;
IDEBuildFlags:=IDEBuildFlags+[blfUseMakeIDECfg];
// make lazarus ide and/or examples
SourceEditorManager.ClearErrorLines;

View File

@ -3923,8 +3923,11 @@ begin
BuildIDEFlags:=[blfDontCleanAll,blfOnlyIDE];
if MainIDE.DoSaveBuildIDEConfigs(BuildIDEFlags)<>mrOk then exit(mrCancel);
if piiifRebuildIDE in Flags then // rebuild Lazarus
if piiifRebuildIDE in Flags then
begin
// rebuild Lazarus
if MainIDE.DoBuildLazarus(BuildIDEFlags)<>mrOk then exit(mrCancel);
end;
finally
FreeDependencyList(NewFirstAutoInstallDependency,pdlRequires);