diff --git a/ide/buildmodesmanager.lfm b/ide/buildmodesmanager.lfm index d9d0a1d4df..46d20c0fd0 100644 --- a/ide/buildmodesmanager.lfm +++ b/ide/buildmodesmanager.lfm @@ -12,36 +12,34 @@ object BuildModesForm: TBuildModesForm OnDestroy = FormDestroy OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.5' + LCLVersion = '1.7' object ButtonPanel1: TButtonPanel Left = 6 - Height = 29 - Top = 319 + Height = 32 + Top = 316 Width = 600 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True - OKButton.OnClick = OKButtonClick HelpButton.Name = 'HelpButton' HelpButton.DefaultCaption = True CloseButton.Name = 'CloseButton' CloseButton.DefaultCaption = True CancelButton.Name = 'CancelButton' CancelButton.DefaultCaption = True - CancelButton.OnClick = CancelButtonClick TabOrder = 2 ShowButtons = [pbOK, pbCancel, pbHelp] ShowBevel = False end object ToolBar1: TToolBar - AnchorSideLeft.Control = cbDebugReleaseProject - AnchorSideTop.Control = cbDebugReleaseProject + AnchorSideLeft.Control = btnCreateDefaultModes + AnchorSideTop.Control = btnCreateDefaultModes AnchorSideTop.Side = asrBottom Left = 6 Height = 28 - Top = 37 + Top = 39 Width = 154 Align = alNone - BorderSpacing.Top = 9 + BorderSpacing.Top = 6 ButtonHeight = 26 ButtonWidth = 26 Caption = 'ToolBar1' @@ -106,8 +104,8 @@ object BuildModesForm: TBuildModesForm AnchorSideTop.Side = asrCenter Left = 166 Height = 17 - Top = 43 - Width = 56 + Top = 45 + Width = 66 BorderSpacing.Left = 6 Caption = 'NoteLabel' Font.Color = clMaroon @@ -120,8 +118,8 @@ object BuildModesForm: TBuildModesForm AnchorSideTop.Control = ToolBar1 AnchorSideTop.Side = asrBottom Left = 6 - Height = 244 - Top = 71 + Height = 242 + Top = 73 Width = 602 Anchors = [akTop, akLeft, akRight, akBottom] AutoFillColumns = True @@ -132,13 +130,13 @@ object BuildModesForm: TBuildModesForm ButtonStyle = cbsCheckboxColumn MaxSize = 50 Title.Caption = 'Active' - Width = 199 + Width = 200 end item ButtonStyle = cbsCheckboxColumn MaxSize = 50 Title.Caption = 'InSession' - Width = 199 + Width = 200 end item MaxSize = 500 @@ -154,42 +152,26 @@ object BuildModesForm: TBuildModesForm OnSelection = BuildModesStringGridSelection OnValidateEntry = BuildModesStringGridValidateEntry ColWidths = ( - 199 - 199 + 200 + 200 200 ) end - object cbDebugReleaseProject: TCheckBox + object btnCreateDefaultModes: TButton AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner Left = 6 - Height = 22 + Height = 27 Top = 6 - Width = 310 - BorderSpacing.Left = 6 - BorderSpacing.Top = 6 - Caption = 'Create Debug and Release modes for new projects' - OnClick = cbDebugReleaseProjectClick - ParentShowHint = False - ShowHint = True - TabOrder = 3 - end - object btnCreateDefaultModes: TButton - AnchorSideLeft.Control = cbDebugReleaseProject - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = cbDebugReleaseProject - AnchorSideTop.Side = asrCenter - Left = 322 - Height = 29 - Top = 3 - Width = 162 + Width = 183 AutoSize = True BorderSpacing.Left = 6 + BorderSpacing.Top = 6 Caption = 'Create now for this project' OnClick = btnCreateDefaultModesClick ParentShowHint = False ShowHint = True - TabOrder = 4 + TabOrder = 3 end object BuildModesPopupMenu: TPopupMenu left = 168 diff --git a/ide/buildmodesmanager.pas b/ide/buildmodesmanager.pas index 558da2c546..97564b4da6 100644 --- a/ide/buildmodesmanager.pas +++ b/ide/buildmodesmanager.pas @@ -30,9 +30,11 @@ unit BuildModesManager; interface uses - Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls, Grids, Menus, ComCtrls, - ButtonPanel, LCLProc, IDEOptionsIntf, IDEDialogs, TransferMacros, Project, - CompOptsIntf, CompilerOptions, Compiler_ModeMatrix, BuildModeDiffDlg, LazarusIDEStrConsts; + Classes, SysUtils, + Forms, Controls, Dialogs, StdCtrls, Grids, Menus, ComCtrls, ButtonPanel, LCLProc, + IDEOptionsIntf, IDEDialogs, CompOptsIntf, + TransferMacros, Project, CompilerOptions, Compiler_ModeMatrix, BuildModeDiffDlg, + EnvironmentOpts, LazarusIDEStrConsts; type @@ -41,7 +43,6 @@ type TBuildModesForm = class(TForm) btnCreateDefaultModes: TButton; BuildModesStringGrid: TStringGrid; - cbDebugReleaseProject: TCheckBox; ImageList1: TImageList; BuildModesPopupMenu: TPopupMenu; ButtonPanel1: TButtonPanel; @@ -57,8 +58,6 @@ type procedure btnCreateDefaultModesClick(Sender: TObject); procedure BuildModesStringGridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; {%H-}aState: TGridDrawState); - procedure CancelButtonClick(Sender: TObject); - procedure cbDebugReleaseProjectClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure DiffSpeedButtonClick(Sender: TObject); @@ -73,7 +72,6 @@ type procedure BuildModesStringGridValidateEntry(Sender: TObject; aCol, aRow: Integer; const OldValue: string; var NewValue: String); procedure FormShow(Sender: TObject); - procedure OKButtonClick(Sender: TObject); private fActiveBuildMode: TProjectBuildMode; fBuildModes: TProjectBuildModes; @@ -109,10 +107,6 @@ procedure UpdateBuildModeCombo(aCombo: TComboBox); implementation -const - DebugModeName = 'Debug'; - ReleaseModeName = 'Release'; - {$R *.lfm} function ShowBuildModesDlg(aShowSession: Boolean): TModalResult; @@ -233,32 +227,6 @@ end; procedure TBuildModesForm.btnCreateDefaultModesClick(Sender: TObject); var CurMode: TProjectBuildMode; - - procedure AssignAndSetBooleans(aMode: TProjectBuildMode; IsDebug: Boolean); - begin - if CurMode<>nil then - aMode.Assign(CurMode); // clone from currently selected mode - with aMode.CompilerOptions do - begin - // Smart linking - SmartLinkUnit:=not IsDebug; - LinkSmart:=not IsDebug; - // Checks - IOChecks:=IsDebug; - RangeChecks:=IsDebug; - OverflowChecks:=IsDebug; - StackChecks:=IsDebug; - IncludeAssertionCode:=IsDebug; - // Debug flags - GenerateDebugInfo:=IsDebug; - UseExternalDbgSyms:=IsDebug; - UseHeaptrc:=IsDebug; - TrashVariables:=IsDebug; - end; - end; - -var - NewMode: TProjectBuildMode; i: Integer; begin i:=BuildModesStringGrid.Row-1; @@ -266,20 +234,8 @@ begin CurMode:=fBuildModes[i] else CurMode:=nil; - - // Create Debug mode - NewMode:=fBuildModes.Add(DebugModeName); - AssignAndSetBooleans(NewMode, True); - NewMode.CompilerOptions.OptimizationLevel:=1; // Optimization - NewMode.CompilerOptions.DebugInfoType:=dsDwarf2Set; // Debug - fActiveBuildMode:=NewMode; // activate Debug mode - - // Create Release mode - NewMode:=fBuildModes.Add(ReleaseModeName); - AssignAndSetBooleans(NewMode, False); - NewMode.CompilerOptions.OptimizationLevel:=3; // Optimization, slow, but safe, -O4 is dangerous - NewMode.CompilerOptions.DebugInfoType:=dsAuto; // Debug - + // Create Debug and Release modes, activate Debug mode + fActiveBuildMode:=fBuildModes.CreateExtraModes(CurMode); FillBuildModesGrid; // show // select identifier BuildModesStringGrid.Col:=fModeNameCol; @@ -540,11 +496,7 @@ begin ToolButtonMoveDown.Hint:=Format(lisMoveOnePositionDown, [Identifier]); ToolButtonDiff.Hint:=lisShowDifferencesBetweenModes; NoteLabel.Caption:=''; - // ToDo: Save in Environment options and use for new projects. - cbDebugReleaseProject.Caption:=lisCreateDebugAndReleaseModesNewProj; - cbDebugReleaseProject.Hint:='Under Construction ...'; // Remove this when implemented. - - btnCreateDefaultModes.Caption:=lisCreateNowForThisProject; + btnCreateDefaultModes.Caption:=lisCreateDebugAndReleaseModes; btnCreateDefaultModes.Hint:=''; // ToDo: Figure out a good hint. btnCreateDefaultModes.Visible := (fBuildModes.Find(DebugModeName)=Nil) and (fBuildModes.Find(ReleaseModeName)=Nil); @@ -602,21 +554,6 @@ begin Result:=fBuildModes[i]; end; -procedure TBuildModesForm.OKButtonClick(Sender: TObject); -begin - ; -end; - -procedure TBuildModesForm.CancelButtonClick(Sender: TObject); -begin - ; -end; - -procedure TBuildModesForm.cbDebugReleaseProjectClick(Sender: TObject); -begin - (Sender as TCheckBox).Checked := False; -end; - procedure TBuildModesForm.BuildModesStringGridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); begin diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 51d3425ff3..43fc36e0c0 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -5630,8 +5630,7 @@ resourcestring lisMoveOnePositionDown = 'Move "%s" one position down'; lisShowDifferencesBetweenModes = 'Show differences between modes ...'; lisBuildMode = 'Build Mode: %s'; - lisCreateDebugAndReleaseModesNewProj = 'Create Debug and Release modes for new projects'; - lisCreateNowForThisProject = 'Create now for this project'; + lisCreateDebugAndReleaseModes = 'Create Debug and Release modes'; lisChangeBuildMode = 'Change build mode'; lisWarningThisIsTheMainUnitTheNewMainUnitWillBePas = '%sWarning: This is ' +'the main unit. The new main unit will be %s.pas.'; diff --git a/ide/project.pp b/ide/project.pp index 23aa7e80f6..0dbdfffdbd 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -103,6 +103,9 @@ type const AllUnitCompDependencyTypes = [low(TUnitCompDependencyType)..high(TUnitCompDependencyType)]; + // Names for extra buildmodes which may be created automatically. + DebugModeName = 'Debug'; + ReleaseModeName = 'Release'; type @@ -543,8 +546,7 @@ type function CreateDiff(CompOpts: TBaseCompilerOptions; Tool: TCompilerDiffTool = nil): boolean; override; // true if differ procedure InvalidateOptions; - procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean - ); override; + procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); override; public property LazProject: TProject read FProject; property BuildMode: TProjectBuildMode read FBuildMode; @@ -652,6 +654,7 @@ type function IsSessionMode(const ModeIdentifier: string): boolean; function IsSharedMode(const ModeIdentifier: string): boolean; procedure RenameMatrixMode(const OldName, NewName: string); + function CreateExtraModes(aCurMode: TProjectBuildMode): TProjectBuildMode; // load, save procedure LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; @@ -6944,6 +6947,48 @@ begin SessionMatrixOptions.RenameMode(OldName,NewName); end; +function TProjectBuildModes.CreateExtraModes(aCurMode: TProjectBuildMode): TProjectBuildMode; +// Create Debug and Release buildmodes. Return the created debug mode. +// Params: aCurMode - existing mode to copy settings from. + + procedure AssignAndSetBooleans(aMode: TProjectBuildMode; IsDebug: Boolean); + begin + if Assigned(aCurMode) then + aMode.Assign(aCurMode); // clone from currently selected mode + with aMode.CompilerOptions do + begin + // Smart linking + SmartLinkUnit:=not IsDebug; + LinkSmart:=not IsDebug; + // Checks + IOChecks:=IsDebug; + RangeChecks:=IsDebug; + OverflowChecks:=IsDebug; + StackChecks:=IsDebug; + IncludeAssertionCode:=IsDebug; + // Debug flags + GenerateDebugInfo:=IsDebug; + UseExternalDbgSyms:=IsDebug; + UseHeaptrc:=IsDebug; + TrashVariables:=IsDebug; + end; + end; + +var + RelMode: TProjectBuildMode; +begin + // Create Debug mode + Result:=Add(DebugModeName); + AssignAndSetBooleans(Result, True); + Result.CompilerOptions.OptimizationLevel:=1; // Optimization + Result.CompilerOptions.DebugInfoType:=dsDwarf2Set; // Debug + // Create Release mode + RelMode:=Add(ReleaseModeName); + AssignAndSetBooleans(RelMode, False); + RelMode.CompilerOptions.OptimizationLevel:=3; // Optimization, slow, but safe, -O4 is dangerous + RelMode.CompilerOptions.DebugInfoType:=dsAuto; // No Debug +end; + // Methods for LoadFromXMLConfig procedure TProjectBuildModes.AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string;