IDE: Create extra buildmodes better.

git-svn-id: trunk@51162 -
This commit is contained in:
juha 2016-01-03 14:53:10 +00:00
parent dae6a4f4b0
commit 1c326b667f
2 changed files with 56 additions and 52 deletions

View File

@ -30,9 +30,11 @@ unit BuildModesManager;
interface interface
uses uses
Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls, Grids, Menus, ComCtrls, Classes, SysUtils,
ButtonPanel, LCLProc, IDEOptionsIntf, IDEDialogs, TransferMacros, Project, Forms, Controls, Dialogs, StdCtrls, Grids, Menus, ComCtrls, ButtonPanel, LCLProc,
CompOptsIntf, CompilerOptions, Compiler_ModeMatrix, BuildModeDiffDlg, LazarusIDEStrConsts; IDEOptionsIntf, IDEDialogs, CompOptsIntf,
TransferMacros, Project, CompilerOptions, Compiler_ModeMatrix, BuildModeDiffDlg,
EnvironmentOpts, LazarusIDEStrConsts;
type type
@ -109,10 +111,6 @@ procedure UpdateBuildModeCombo(aCombo: TComboBox);
implementation implementation
const
DebugModeName = 'Debug';
ReleaseModeName = 'Release';
{$R *.lfm} {$R *.lfm}
function ShowBuildModesDlg(aShowSession: Boolean): TModalResult; function ShowBuildModesDlg(aShowSession: Boolean): TModalResult;
@ -233,32 +231,6 @@ end;
procedure TBuildModesForm.btnCreateDefaultModesClick(Sender: TObject); procedure TBuildModesForm.btnCreateDefaultModesClick(Sender: TObject);
var var
CurMode: TProjectBuildMode; 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; i: Integer;
begin begin
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
@ -266,20 +238,8 @@ begin
CurMode:=fBuildModes[i] CurMode:=fBuildModes[i]
else else
CurMode:=nil; CurMode:=nil;
// Create Debug and Release modes, activate Debug mode
// Create Debug mode fActiveBuildMode:=fBuildModes.CreateExtraModes(CurMode);
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
FillBuildModesGrid; // show FillBuildModesGrid; // show
// select identifier // select identifier
BuildModesStringGrid.Col:=fModeNameCol; BuildModesStringGrid.Col:=fModeNameCol;
@ -540,9 +500,8 @@ begin
ToolButtonMoveDown.Hint:=Format(lisMoveOnePositionDown, [Identifier]); ToolButtonMoveDown.Hint:=Format(lisMoveOnePositionDown, [Identifier]);
ToolButtonDiff.Hint:=lisShowDifferencesBetweenModes; ToolButtonDiff.Hint:=lisShowDifferencesBetweenModes;
NoteLabel.Caption:=''; NoteLabel.Caption:='';
// ToDo: Save in Environment options and use for new projects.
cbDebugReleaseProject.Caption:=lisCreateDebugAndReleaseModesNewProj; cbDebugReleaseProject.Caption:=lisCreateDebugAndReleaseModesNewProj;
cbDebugReleaseProject.Hint:='Under Construction ...'; // Remove this when implemented. //cbDebugReleaseProject.Hint:='Under Construction ...'; // Remove this when implemented.
btnCreateDefaultModes.Caption:=lisCreateNowForThisProject; btnCreateDefaultModes.Caption:=lisCreateNowForThisProject;
btnCreateDefaultModes.Hint:=''; // ToDo: Figure out a good hint. btnCreateDefaultModes.Hint:=''; // ToDo: Figure out a good hint.
@ -614,7 +573,7 @@ end;
procedure TBuildModesForm.cbDebugReleaseProjectClick(Sender: TObject); procedure TBuildModesForm.cbDebugReleaseProjectClick(Sender: TObject);
begin begin
(Sender as TCheckBox).Checked := False; //(Sender as TCheckBox).Checked := False;
end; end;
procedure TBuildModesForm.BuildModesStringGridDrawCell(Sender: TObject; procedure TBuildModesForm.BuildModesStringGridDrawCell(Sender: TObject;

View File

@ -103,6 +103,9 @@ type
const const
AllUnitCompDependencyTypes = [low(TUnitCompDependencyType)..high(TUnitCompDependencyType)]; AllUnitCompDependencyTypes = [low(TUnitCompDependencyType)..high(TUnitCompDependencyType)];
// Names for extra buildmodes which may be created automatically.
DebugModeName = 'Debug';
ReleaseModeName = 'Release';
type type
@ -543,8 +546,7 @@ type
function CreateDiff(CompOpts: TBaseCompilerOptions; function CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool = nil): boolean; override; // true if differ Tool: TCompilerDiffTool = nil): boolean; override; // true if differ
procedure InvalidateOptions; procedure InvalidateOptions;
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); override;
); override;
public public
property LazProject: TProject read FProject; property LazProject: TProject read FProject;
property BuildMode: TProjectBuildMode read FBuildMode; property BuildMode: TProjectBuildMode read FBuildMode;
@ -652,6 +654,7 @@ type
function IsSessionMode(const ModeIdentifier: string): boolean; function IsSessionMode(const ModeIdentifier: string): boolean;
function IsSharedMode(const ModeIdentifier: string): boolean; function IsSharedMode(const ModeIdentifier: string): boolean;
procedure RenameMatrixMode(const OldName, NewName: string); procedure RenameMatrixMode(const OldName, NewName: string);
function CreateExtraModes(aCurMode: TProjectBuildMode): TProjectBuildMode;
// load, save // load, save
procedure LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadProjOptsFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; procedure LoadSessionFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
@ -6946,6 +6949,48 @@ begin
SessionMatrixOptions.RenameMode(OldName,NewName); SessionMatrixOptions.RenameMode(OldName,NewName);
end; 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 // Methods for LoadFromXMLConfig
procedure TProjectBuildModes.AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string; procedure TProjectBuildModes.AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string;