IDE: fixed extending unit/inc path in PI, fixed checking last pcp ignoring optional Darwin bundle, added dummy external tools for dependencies

git-svn-id: trunk@45986 -
This commit is contained in:
mattias 2014-07-28 08:21:21 +00:00
parent c7e5f91bd9
commit 2afb6b73af
12 changed files with 460 additions and 233 deletions

View File

@ -562,7 +562,8 @@ type
property ExecuteAfter[Index: integer]: TAbstractExternalTool read GetExecuteAfter;
end;
{ TExternalToolGroup }
{ TExternalToolGroup
Hint: Add tools by setting Tool.Group:=Group }
TExternalToolGroup = class(TComponent)
private
@ -576,6 +577,7 @@ type
destructor Destroy; override;
procedure Clear; virtual;
function Count: integer;
procedure Execute; virtual;
property Items[Index: integer]: TAbstractExternalTool read GetItems; default;
property AbortIfOneFails: boolean read FAbortIfOneFails write FAbortIfOneFails;
procedure ToolExited(Tool: TAbstractExternalTool); virtual;
@ -597,6 +599,7 @@ type
procedure Clear; virtual; abstract; // terminate + free all tools
property Items[Index: integer]: TAbstractExternalTool read GetItems; default;
function Add(Title: string): TAbstractExternalTool; virtual; abstract;
function AddDummy(Title: string): TAbstractExternalTool; // a tool, not run, usable for dependencies
function IndexOf(Tool: TAbstractExternalTool): integer; virtual; abstract;
procedure ConsistencyCheck; virtual;
procedure EnterCriticalSection; virtual; abstract;
@ -856,6 +859,19 @@ begin
Result:=FItems.Count;
end;
procedure TExternalToolGroup.Execute;
var
i: Integer;
Tool: TAbstractExternalTool;
begin
for i:=0 to Count-1 do begin
Tool:=Items[i];
if Tool.Terminated then continue;
debugln(['TExternalToolGroup.Execute ',Tool.Title]);
Tool.Execute;
end;
end;
procedure TExternalToolGroup.InternalRemove(Tool: TAbstractExternalTool);
begin
FItems.Remove(Tool);
@ -1452,6 +1468,12 @@ begin
Result:=fItems.Count;
end;
function TIDEExternalTools.AddDummy(Title: string): TAbstractExternalTool;
begin
Result:=Add(Title);
Result.Terminate;
end;
constructor TIDEExternalTools.Create(aOwner: TComponent);
begin
inherited Create(aOwner);

View File

@ -28,7 +28,8 @@ uses
Classes, SysUtils, TypInfo, FileUtil, LazFileCache, Forms, Controls, StdCtrls,
ExtCtrls, Buttons, Dialogs, LCLProc, PropEdits, ObjectInspector,
TransferMacros, LazarusIDEStrConsts, IDEOptionsIntf, IDEUtils,
DbgIntfDebuggerBase, PathEditorDlg, InputHistory, IDEProcs, EnvironmentOpts,
DbgIntfDebuggerBase, PathEditorDlg, InputHistory, IDEProcs, DialogProcs,
EnvironmentOpts,
BaseDebugManager, Debugger;
type

View File

@ -38,8 +38,8 @@ interface
uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Dialogs, ComCtrls,
FileProcs, FileUtil, LazFileUtils, Laz2_XMLCfg, lazutf8classes, LazFileCache,
CodeToolsConfig, CodeCache, CodeToolManager, AVL_Tree, LazIDEIntf, IDEProcs,
LazarusIDEStrConsts, IDEDialogs;
CodeToolsConfig, CodeCache, CodeToolManager, AVL_Tree, LazIDEIntf, IDEDialogs,
IDEProcs, LazarusIDEStrConsts;
type
// load buffer flags
@ -95,6 +95,11 @@ function CheckFileIsWritable(const Filename: string;
ErrorButtons: TMsgDlgButtons = []): TModalResult;
function CheckDirectoryIsWritable(const Filename: string;
ErrorButtons: TMsgDlgButtons = []): TModalResult;
function CheckExecutable(const OldFilename,
NewFilename: string; const ErrorCaption, ErrorMsg: string;
SearchInPath: boolean = true): boolean;
function CheckDirPathExists(const Dir,
ErrorCaption, ErrorMsg: string): TModalResult;
function ChooseSymlink(var Filename: string; AskOnSymlink: boolean): TModalResult;
function CreateSymlinkInteractive(const LinkFilename, TargetFilename: string;
ErrorButtons: TMsgDlgButtons = []): TModalResult;
@ -588,6 +593,40 @@ begin
Result:=mrOk;
end;
function CheckExecutable(const OldFilename,
NewFilename: string; const ErrorCaption, ErrorMsg: string;
SearchInPath: boolean): boolean;
var
Filename: String;
begin
Result:=true;
if OldFilename=NewFilename then exit;
Filename:=NewFilename;
if (not FilenameIsAbsolute(NewFilename)) and SearchInPath then begin
Filename:=FindDefaultExecutablePath(NewFilename);
if Filename='' then
Filename:=NewFilename;
end;
if (not FileIsExecutable(Filename)) then begin
if IDEMessageDialog(ErrorCaption,Format(ErrorMsg,[Filename]),
mtWarning,[mbIgnore,mbCancel])=mrCancel
then begin
Result:=false;
end;
end;
end;
function CheckDirPathExists(const Dir,
ErrorCaption, ErrorMsg: string): TModalResult;
begin
if not DirPathExists(Dir) then begin
Result:=IDEMessageDialog(ErrorCaption,Format(ErrorMsg,[Dir]),mtWarning,
[mbIgnore,mbCancel]);
end else
Result:=mrOk;
end;
function DeleteFileInteractive(const Filename: string;
ErrorButtons: TMsgDlgButtons): TModalResult;
begin

View File

@ -44,7 +44,7 @@ uses
ComponentReg, IDEExternToolIntf, IDEDialogs, MacroDefIntf,
DbgIntfDebuggerBase,
// IDE
IDEProcs, LazarusIDEStrConsts, IDETranslations, LazConf,
IDEProcs, DialogProcs, LazarusIDEStrConsts, IDETranslations, LazConf,
IDEOptionDefs, TransferMacros, ModeMatrixOpts, Debugger;
const
@ -745,10 +745,6 @@ function CharCaseFileActionNameToType(const Action: string): TCharCaseFileAction
function UnitRenameReferencesActionNameToType(const Action: string): TUnitRenameReferencesAction;
function StrToMsgWndFilenameStyle(const s: string): TMsgWndFileNameStyle;
function CheckExecutable(const OldFilename, NewFilename: string;
const ErrorCaption, ErrorMsg: string; SearchInPath: boolean = false): boolean;
function CheckDirPathExists(const Dir,
ErrorCaption, ErrorMsg: string): TModalResult;
function SimpleDirectoryCheck(const OldDir, NewDir,
NotFoundErrMsg: string; out StopChecking: boolean): boolean;
@ -816,40 +812,6 @@ begin
Result:=mwfsShort;
end;
function CheckExecutable(const OldFilename,
NewFilename: string; const ErrorCaption, ErrorMsg: string;
SearchInPath: boolean): boolean;
var
Filename: String;
begin
Result:=true;
if OldFilename=NewFilename then exit;
Filename:=NewFilename;
if (not FilenameIsAbsolute(NewFilename)) and SearchInPath then begin
Filename:=FindDefaultExecutablePath(NewFilename);
if Filename='' then
Filename:=NewFilename;
end;
if (not FileIsExecutable(Filename)) then begin
if IDEMessageDialog(ErrorCaption,Format(ErrorMsg,[Filename]),
mtWarning,[mbIgnore,mbCancel])=mrCancel
then begin
Result:=false;
end;
end;
end;
function CheckDirPathExists(const Dir,
ErrorCaption, ErrorMsg: string): TModalResult;
begin
if not DirPathExists(Dir) then begin
Result:=IDEMessageDialog(ErrorCaption,Format(ErrorMsg,[Dir]),mtWarning,
[mbIgnore,mbCancel]);
end else
Result:=mrOk;
end;
function SimpleDirectoryCheck(const OldDir, NewDir,
NotFoundErrMsg: string; out StopChecking: boolean): boolean;
var

View File

@ -52,11 +52,14 @@ unit etQuickFixes;
interface
uses
Classes, SysUtils, Menus, Dialogs, Controls, CodeToolManager, CodeCache,
CodeTree, CodeAtom, BasicCodeTools, KeywordFuncLists, LazLogger, AvgLvlTree,
LazFileUtils, IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, IDEDialogs, MenuIntf,
ProjectIntf, PackageIntf, CompOptsIntf, etFPCMsgParser, AbstractsMethodsDlg,
LazarusIDEStrConsts;
Classes, SysUtils,
LazLogger, AvgLvlTree, LazFileUtils,
Menus, Dialogs, Controls,
CodeToolManager, CodeCache, CodeTree, CodeAtom, BasicCodeTools,
KeywordFuncLists,
IDEExternToolIntf, IDEMsgIntf, LazIDEIntf, IDEDialogs, MenuIntf,
ProjectIntf, PackageIntf, CompOptsIntf,
etFPCMsgParser, AbstractsMethodsDlg, LazarusIDEStrConsts;
type

View File

@ -613,6 +613,7 @@ end;
destructor TExternalTool.Destroy;
begin
debugln(['TExternalTool.Destroy ',Title]);
EnterCriticalSection;
try
FStage:=etsDestroying;
@ -868,6 +869,7 @@ end;
procedure TExternalTool.AddExecuteBefore(Tool: TAbstractExternalTool);
begin
debugln(['TExternalTool.AddExecuteBefore Self=',Title,' Tool=',Tool.Title]);
if (Tool=Self) or (Tool.IsExecutedBefore(Self)) then
raise Exception.Create('TExternalTool.AddExecuteBefore: that would create a circle');
if (fExecuteBefore<>nil) and (fExecuteBefore.IndexOf(Tool)<0) then
@ -1259,7 +1261,8 @@ begin
InitCriticalSection(FCritSec);
fRunning:=TFPList.Create;
fParsers:=TFPList.Create;
MaxProcessCount:=2;
MaxProcessCount:=2; // even on single cores there is delay due to file reads
// => use 2 processes in parallel by default
if ExternalToolList=nil then
ExternalToolList:=Self;
if ExternalTools=nil then

View File

@ -2,9 +2,9 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
Left = 0
Height = 539
Top = 0
Width = 599
Width = 741
ClientHeight = 539
ClientWidth = 599
ClientWidth = 741
TabOrder = 0
DesignLeft = 481
DesignTop = 150
@ -12,9 +12,9 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 0
Height = 24
Height = 18
Top = 0
Width = 129
Width = 136
Caption = 'chkCreateMakefile'
TabOrder = 0
end
@ -25,35 +25,35 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 114
Top = 214
Width = 599
Height = 103
Top = 218
Width = 741
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'ExecuteAfterGroupBox'
ClientHeight = 97
ClientWidth = 595
ClientHeight = 81
ClientWidth = 733
TabOrder = 3
object lblRunIfExecAfter: TLabel
AnchorSideLeft.Control = ExecuteAfterGroupBox
AnchorSideTop.Control = ExecuteAfterGroupBox
Left = 6
Height = 15
Height = 16
Top = 6
Width = 99
Width = 109
BorderSpacing.Around = 6
Caption = 'lblRunIfExecAfter'
ParentColor = False
end
object ExecuteAfterCommandLabel: TLabel
AnchorSideLeft.Control = ExecuteAfterGroupBox
AnchorSideTop.Control = ExecuteAfterCommandEdit
AnchorSideTop.Control = ExecuteAfterCommandComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 41
Width = 158
Height = 16
Top = 32
Width = 178
BorderSpacing.Around = 6
Caption = 'ExecuteAfterCommandLabel'
ParentColor = False
@ -62,10 +62,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = lblRunIfExecAfter
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterGroupBox
Left = 135
Height = 24
Left = 145
Height = 18
Top = 6
Width = 145
Width = 154
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecAfterCompile'
@ -75,10 +75,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkExecAfterCompile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterGroupBox
Left = 310
Height = 24
Left = 329
Height = 18
Top = 6
Width = 129
Width = 133
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecAfterBuild'
@ -88,85 +88,103 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkExecAfterBuild
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterGroupBox
Left = 469
Height = 24
Left = 492
Height = 18
Top = 6
Width = 123
Width = 126
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecAfterRun'
TabOrder = 2
end
object ExecuteAfterCommandEdit: TEdit
AnchorSideLeft.Control = ExecuteAfterCommandLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkExecAfterCompile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ExecuteAfterGroupBox
AnchorSideRight.Side = asrBottom
Left = 182
Height = 25
Top = 36
Width = 407
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Around = 6
TabOrder = 3
Text = 'ExecuteAfterCommandEdit'
end
object ExecuteAfterScanFPCCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteAfterScanMakeCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterCommandEdit
AnchorSideTop.Side = asrBottom
Left = 379
Height = 24
Top = 67
Width = 199
AnchorSideTop.Control = ExecuteAfterScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 407
Height = 18
Top = 57
Width = 213
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'ExecuteAfterScanFPCCheckBox'
TabOrder = 5
TabOrder = 4
end
object ExecuteAfterScanMakeCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteAfterScanLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterCommandEdit
AnchorSideTop.Control = ExecuteAfterCommandComboBox
AnchorSideTop.Side = asrBottom
Left = 141
Height = 24
Top = 67
Width = 208
Left = 154
Height = 18
Top = 57
Width = 223
BorderSpacing.Around = 6
Caption = 'ExecuteAfterScanMakeCheckBox'
TabOrder = 4
TabOrder = 3
end
object ExecuteAfterShowAllCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteAfterScanFPCCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteAfterCommandEdit
AnchorSideTop.Side = asrBottom
Left = 608
Height = 24
Top = 67
Width = 197
AnchorSideTop.Control = ExecuteAfterScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 650
Height = 18
Top = 57
Width = 211
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'ExecuteAfterShowAllCheckBox'
TabOrder = 6
TabOrder = 5
end
object ExecuteAfterScanLabel: TLabel
AnchorSideLeft.Control = ExecuteAfterGroupBox
AnchorSideTop.Control = ExecuteAfterScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 72
Width = 129
Height = 16
Top = 58
Width = 142
BorderSpacing.Left = 6
Caption = 'ExecuteAfterScanLabel'
ParentColor = False
end
object ExecuteAfterCommandComboBox: TComboBox
AnchorSideLeft.Control = ExecuteAfterCommandLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkExecAfterCompile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ExecAfterBrowseButton
Left = 196
Height = 21
Top = 30
Width = 461
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 6
Text = 'ExecuteAfterCommandComboBox'
end
object ExecAfterBrowseButton: TButton
AnchorSideTop.Control = ExecuteAfterCommandComboBox
AnchorSideRight.Control = ExecuteAfterGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ExecuteAfterCommandComboBox
AnchorSideBottom.Side = asrBottom
Left = 657
Height = 20
Top = 30
Width = 70
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = CompCmdBrowseButtonClick
TabOrder = 7
end
end
object grpCompiler: TGroupBox
AnchorSideLeft.Control = Owner
@ -175,23 +193,23 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 86
Top = 122
Width = 599
Height = 79
Top = 133
Width = 741
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'grpCompiler'
ClientHeight = 69
ClientWidth = 595
ClientHeight = 57
ClientWidth = 733
TabOrder = 2
object lblRunIfCompiler: TLabel
AnchorSideLeft.Control = grpCompiler
AnchorSideTop.Control = grpCompiler
Left = 6
Height = 15
Height = 16
Top = 6
Width = 92
Width = 106
BorderSpacing.Around = 6
Caption = 'lblRunIfCompiler'
ParentColor = False
@ -201,9 +219,9 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideTop.Control = cobCompiler
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 42
Width = 62
Height = 16
Top = 32
Width = 73
BorderSpacing.Around = 6
Caption = 'lblCompiler'
ParentColor = False
@ -212,10 +230,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = lblRunIfCompiler
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = grpCompiler
Left = 128
Height = 24
Left = 142
Height = 18
Top = 6
Width = 138
Width = 152
BorderSpacing.Left = 30
BorderSpacing.Top = 6
Caption = 'chkCompilerCompile'
@ -225,10 +243,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkCompilerCompile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = grpCompiler
Left = 296
Height = 24
Left = 324
Height = 18
Top = 6
Width = 122
Width = 131
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkCompilerBuild'
@ -238,10 +256,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkCompilerBuild
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = grpCompiler
Left = 448
Height = 24
Left = 485
Height = 18
Top = 6
Width = 116
Width = 124
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkCompilerRun'
@ -253,10 +271,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideTop.Control = chkCompilerCompile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BrowseCompilerButton
Left = 80
Height = 27
Top = 36
Width = 488
Left = 91
Height = 21
Top = 30
Width = 566
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Top = 6
@ -271,15 +289,15 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = cobCompiler
AnchorSideBottom.Side = asrBottom
Left = 568
Height = 27
Top = 36
Width = 21
Left = 657
Height = 21
Top = 30
Width = 70
Anchors = [akTop, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = BrowseCompilerButtonClick
OnClick = CompCmdBrowseButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 4
@ -292,34 +310,35 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 86
Top = 30
Width = 599
Height = 103
Top = 24
Width = 741
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'ExecuteBeforeGroupBox'
ClientHeight = 69
ClientWidth = 595
ClientHeight = 81
ClientWidth = 733
TabOrder = 1
object lblRunIfExecBefore: TLabel
AnchorSideLeft.Control = ExecuteBeforeGroupBox
AnchorSideTop.Control = ExecuteBeforeGroupBox
Left = 6
Height = 15
Height = 16
Top = 6
Width = 108
Width = 118
BorderSpacing.Around = 6
Caption = 'lblRunIfExecBefore'
ParentColor = False
end
object ExecuteBeforeCommandLabel: TLabel
AnchorSideLeft.Control = ExecuteBeforeGroupBox
AnchorSideTop.Control = ExecuteBeforeCommandComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 41
Width = 167
Height = 16
Top = 32
Width = 187
BorderSpacing.Around = 6
Caption = 'ExecuteBeforeCommandLabel'
ParentColor = False
@ -328,10 +347,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = lblRunIfExecBefore
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteBeforeGroupBox
Left = 144
Height = 24
Left = 154
Height = 18
Top = 6
Width = 154
Width = 163
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecBeforeCompile'
@ -341,10 +360,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkExecBeforeCompile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteBeforeGroupBox
Left = 328
Height = 24
Left = 347
Height = 18
Top = 6
Width = 138
Width = 142
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecBeforeBuild'
@ -354,10 +373,10 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Control = chkExecBeforeBuild
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteBeforeGroupBox
Left = 496
Height = 24
Left = 519
Height = 18
Top = 6
Width = 132
Width = 135
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'chkExecBeforeRun'
@ -366,11 +385,12 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
object ExecuteBeforeScanFPCCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteBeforeScanMakeCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
Left = 397
Height = 24
Top = 67
Width = 208
AnchorSideTop.Control = ExecuteBeforeScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 425
Height = 18
Top = 57
Width = 222
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'ExecuteBeforeScanFPCCheckBox'
@ -379,11 +399,12 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
object ExecuteBeforeScanMakeCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteBeforeScanLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteBeforeCommandComboBox
AnchorSideTop.Side = asrBottom
Left = 150
Height = 24
Top = 67
Width = 217
Left = 163
Height = 18
Top = 57
Width = 232
BorderSpacing.Around = 6
Caption = 'ExecuteBeforeScanMakeCheckBox'
TabOrder = 3
@ -391,11 +412,12 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
object ExecuteBeforeShowAllCheckBox: TCheckBox
AnchorSideLeft.Control = ExecuteBeforeScanFPCCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
Left = 635
Height = 24
Top = 67
Width = 206
AnchorSideTop.Control = ExecuteBeforeScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 677
Height = 18
Top = 57
Width = 220
BorderSpacing.Left = 24
BorderSpacing.Around = 6
Caption = 'ExecuteBeforeShowAllCheckBox'
@ -406,9 +428,9 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideTop.Control = ExecuteBeforeScanMakeCheckBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 72
Width = 138
Height = 16
Top = 58
Width = 151
BorderSpacing.Left = 6
Caption = 'ExecuteBeforeScanLabel'
ParentColor = False
@ -418,18 +440,36 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkExecBeforeCompile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ExecuteBeforeGroupBox
AnchorSideRight.Side = asrBottom
Left = 191
Height = 27
Top = 36
Width = 398
AnchorSideRight.Control = ExecBeforeBrowseButton
Left = 205
Height = 21
Top = 30
Width = 452
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Around = 6
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 6
Text = 'ExecuteBeforeCommandComboBox'
end
object ExecBeforeBrowseButton: TButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExecuteBeforeCommandComboBox
AnchorSideRight.Control = ExecuteBeforeGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ExecuteBeforeCommandComboBox
AnchorSideBottom.Side = asrBottom
Left = 657
Height = 21
Top = 30
Width = 70
Anchors = [akTop, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = CompCmdBrowseButtonClick
TabOrder = 7
end
end
end

View File

@ -5,10 +5,12 @@ unit compiler_compilation_options;
interface
uses
Controls, StdCtrls, Dialogs, IDEOptionsIntf, Project, CompilerOptions,
CompOptsIntf, IDEDialogs, IDEUtils, FileProcs, DefineTemplates,
CodeToolManager, PackageDefs, LazarusIDEStrConsts, EnvironmentOpts, LazConf,
IDEProcs, InputHistory, InitialSetupProc, Classes, sysutils;
Classes, sysutils,
Controls, StdCtrls, Dialogs,
FileProcs, DefineTemplates, CodeToolManager,
IDEOptionsIntf, CompOptsIntf, IDEDialogs, IDEUtils,
Project, CompilerOptions, PackageDefs, LazarusIDEStrConsts, EnvironmentOpts,
LazConf, IDEProcs, DialogProcs, InputHistory, InitialSetupProc;
type
@ -16,6 +18,7 @@ type
TCompilerCompilationOptionsFrame = class(TAbstractIDEOptionsEditor)
BrowseCompilerButton: TButton;
ExecBeforeBrowseButton: TButton;
chkCompilerBuild: TCheckBox;
chkCompilerCompile: TCheckBox;
chkCompilerRun: TCheckBox;
@ -27,7 +30,8 @@ type
chkExecBeforeCompile: TCheckBox;
chkExecBeforeRun: TCheckBox;
cobCompiler: TComboBox;
ExecuteAfterCommandEdit: TEdit;
ExecAfterBrowseButton: TButton;
ExecuteAfterCommandComboBox: TComboBox;
ExecuteAfterCommandLabel: TLabel;
ExecuteAfterGroupBox: TGroupBox;
ExecuteAfterScanFPCCheckBox: TCheckBox;
@ -46,7 +50,7 @@ type
lblRunIfCompiler: TLabel;
lblRunIfExecAfter: TLabel;
lblRunIfExecBefore: TLabel;
procedure BrowseCompilerButtonClick(Sender: TObject);
procedure CompCmdBrowseButtonClick(Sender: TObject);
private
public
function GetTitle: string; override;
@ -62,49 +66,70 @@ implementation
{ TCompilerCompilationOptionsFrame }
procedure TCompilerCompilationOptionsFrame.BrowseCompilerButtonClick(
procedure TCompilerCompilationOptionsFrame.CompCmdBrowseButtonClick(
Sender: TObject);
var
OpenDialog: TOpenDialog;
AFilename: string;
NewFilename: string;
Quality: TSDFilenameQuality;
Note: string;
s: string;
OldFilename: string;
OldParams: string;
Combo: TComboBox;
begin
OpenDialog:=TOpenDialog.Create(nil);
try
InputHistories.ApplyFileDialogSettings(OpenDialog);
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
OpenDialog.Options:=OpenDialog.Options+[ofFileMustExist];
OldFilename:='';
OldParams:='';
// set title
if Sender=BrowseCompilerButton then
if Sender=BrowseCompilerButton then begin
Combo:=cobCompiler;
OpenDialog.Title:=Format(lisChooseCompilerPath,[GetDefaultCompilerFilename])
else
end else if (Sender=ExecAfterBrowseButton) then begin
Combo:=ExecuteAfterCommandComboBox;
OpenDialog.Title:='Choose an executable';
SplitCmdLine(Combo.Text,OldFilename,OldParams);
end else if (Sender=ExecBeforeBrowseButton) then begin
Combo:=ExecuteBeforeCommandComboBox;
OpenDialog.Title:='Choose an executable';
SplitCmdLine(Combo.Text,OldFilename,OldParams);
end else
exit;
if OpenDialog.Execute then begin
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
if Sender=BrowseCompilerButton then begin
// check compiler filename
if IsFPCExecutable(AFilename,s) then begin
// check compiler
Quality:=CheckCompilerQuality(AFilename,Note,
CodeToolBoss.FPCDefinesCache.TestFilename);
if Quality<>sddqCompatible then begin
if IDEMessageDialog(lisCCOWarningCaption, Format(
lisTheCompilerFileDoesNotLookCorrect, [AFilename, #13, Note]),
mtWarning,[mbIgnore,mbCancel])<>mrIgnore
then
exit;
end;
end else begin
// maybe a script
if not OpenDialog.Execute then exit;
NewFilename:=TrimAndExpandFilename(OpenDialog.Filename);
if Sender=BrowseCompilerButton then begin
// check compiler filename
if IsFPCExecutable(NewFilename,s) then begin
// check compiler
Quality:=CheckCompilerQuality(NewFilename,Note,
CodeToolBoss.FPCDefinesCache.TestFilename);
if Quality<>sddqCompatible then begin
if IDEMessageDialog(lisCCOWarningCaption, Format(
lisTheCompilerFileDoesNotLookCorrect, [NewFilename, #13, Note]),
mtWarning,[mbIgnore,mbCancel])<>mrIgnore
then
exit;
end;
SetComboBoxText(cobCompiler,AFilename,cstFilename);
end else begin
// maybe a script
if not CheckExecutable(OldFilename,NewFilename,'Invalid Executable','The file "%s" is not executable.')
then
exit;
end;
end else if (Sender=ExecBeforeBrowseButton)
or (Sender=ExecAfterBrowseButton) then begin
// check executable
if not CheckExecutable(OldFilename,NewFilename,'Invalid Executable','The file "%s" is not executable.')
then
exit;
end;
InputHistories.StoreFileDialogSettings(OpenDialog);
SetComboBoxText(Combo,NewFilename,cstFilename);
finally
InputHistories.StoreFileDialogSettings(OpenDialog);
OpenDialog.Free;
end;
end;
@ -146,7 +171,7 @@ begin
chkExecAfterBuild.Caption := lisBuildStage;
chkExecAfterCompile.Caption := lisCompileStage;
chkExecAfterRun.Caption := lisRunStage;
ExecuteAfterCommandEdit.Text := '';
ExecuteAfterCommandComboBox.Text := '';
ExecuteAfterCommandLabel.Caption := lisCOCommand;
ExecuteAfterScanLabel.Caption := lisCOScanForMessages;
ExecuteAfterScanFPCCheckBox.Caption := 'FPC'; // do not translate name
@ -193,6 +218,11 @@ begin
Items.EndUpdate;
end;
ExecuteBeforeCommandComboBox.Items.Assign(
InputHistories.HistoryLists.GetList('BuildExecBefore',true,rltFile));
ExecuteAfterCommandComboBox.Items.Assign(
InputHistories.HistoryLists.GetList('BuildExecAfter',true,rltFile));
if Options is TProjectCompilerOptions then
with TProjectCompilerOptions(Options) do
begin
@ -230,7 +260,7 @@ begin
cobCompiler.AnchorParallel(akTop, 0, lblCompiler.Parent);
end;
ExecuteAfterCommandEdit.Text := Options.ExecuteAfter.Command;
ExecuteAfterCommandComboBox.Text := Options.ExecuteAfter.Command;
ExecuteAfterScanFPCCheckBox.Checked := Options.ExecuteAfter.ScanForFPCMessages;
ExecuteAfterScanMakeCheckBox.Checked := Options.ExecuteAfter.ScanForMakeMessages;
ExecuteAfterShowAllCheckBox.Checked := Options.ExecuteAfter.ShowAllMessages;
@ -282,6 +312,11 @@ begin
Options.CompilerPath := cobCompiler.Text;
EnvironmentOptions.CompilerFileHistory.Assign(cobCompiler.Items);
InputHistories.HistoryLists.GetList('BuildExecBefore',true,rltFile).Assign(
ExecuteBeforeCommandComboBox.Items);
InputHistories.HistoryLists.GetList('BuildExecAfter',true,rltFile).Assign(
ExecuteAfterCommandComboBox.Items);
if Options is TProjectCompilerOptions then
begin
TProjectCompilerOptions(Options).CompileReasons :=
@ -290,7 +325,7 @@ begin
else if Options is TPkgCompilerOptions then
TPkgCompilerOptions(Options).SkipCompiler := chkCompilerCompile.Checked;
Options.ExecuteAfter.Command := ExecuteAfterCommandEdit.Text;
Options.ExecuteAfter.Command := ExecuteAfterCommandComboBox.Text;
Options.ExecuteAfter.ScanForFPCMessages := ExecuteAfterScanFPCCheckBox.Checked;
Options.ExecuteAfter.ScanForMakeMessages :=ExecuteAfterScanMakeCheckBox.Checked;
Options.ExecuteAfter.ShowAllMessages := ExecuteAfterShowAllCheckBox.Checked;

View File

@ -31,8 +31,9 @@ interface
uses
Classes, SysUtils, LCLProc, FileUtil, CodeToolManager, DefineTemplates, Forms,
StdCtrls, Dialogs, Controls, Spin, EnvironmentOpts, MacroIntf,
LazarusIDEStrConsts, InputHistory, LazConf, IDEProcs, IDEOptionsIntf,
IDEDialogs, IDEUtils, InitialSetupProc;
IDEOptionsIntf, IDEDialogs,
LazarusIDEStrConsts, InputHistory, LazConf, IDEProcs,
IDEUtils, InitialSetupProc, DialogProcs;
type

View File

@ -1146,6 +1146,21 @@ procedure TMainIDE.LoadGlobalOptions;
{$ENDIF}
{$ENDIF}
end;
function NormalizeLazExe(LazExe: string): string;
{$IFDEF Darwin}
var
p: SizeInt;
{$ENDIF}
begin
Result:=TrimFilename(LazExe);
{$IFDEF Darwin}
p:=Pos('.app/Contents/MacOS/',Result);
if p>0 then
Result:=LeftStr(LazExe,p-1);
{$ENDIF}
end;
var
EnvOptsCfgExisted: boolean;
s, LastCalled: String;
@ -1188,9 +1203,10 @@ begin
// check if this PCP was used by another lazarus exe
s := ExtractFileName(ParamStrUTF8(0));
CurPrgName := TrimFilename(AppendPathDelim(ProgramDirectory(False)) + s);
AltPrgName := TrimFilename(AppendPathDelim(AppendPathDelim(GetPrimaryConfigPath) + 'bin') + s);
LastCalled := EnvironmentOptions.LastCalledByLazarusFullPath;
CurPrgName := NormalizeLazExe(AppendPathDelim(ProgramDirectory(False)) + s);
AltPrgName := NormalizeLazExe(AppendPathDelim(AppendPathDelim(GetPrimaryConfigPath) + 'bin') + s);
LastCalled := NormalizeLazExe(EnvironmentOptions.LastCalledByLazarusFullPath);
if (LastCalled = '') then
begin
// this PCP was not yet used (at least not with a version with LastCalledByLazarusFullPath)
@ -1214,6 +1230,10 @@ begin
// => either the user forgot to pass a --pcp
// or the user uninstalled and installed to another directory
// => warn
debugln(['TMainIDE.LoadGlobalOptions ']);
debugln([' LastCalled="',LastCalled,'"']);
debugln([' CurPrgName="',CurPrgName,'"']);
debugln([' AltPrgName="',AltPrgName,'"']);
MsgResult := IDEQuestionDialog(lisIncorrectConfigurationDirectoryFound,
Format(lisIDEConficurationFoundMayBelongToOtherLazarus,
[LineEnding, GetSecondConfDirWarning, GetPrimaryConfigPath,

View File

@ -120,6 +120,9 @@ type
procedure Clear;
function Add(Tool: TAbstractExternalTool): integer;
function Count: integer; inline;
function GetDummyTool: TAbstractExternalTool;
function GetFirstOrDummy: TAbstractExternalTool;
function GetLastOrDummy: TAbstractExternalTool;
property Tools[Index: integer]: TAbstractExternalTool read GetTools; default;
property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end;
@ -611,6 +614,28 @@ begin
Result:=fTools.Count;
end;
function TLazPkgGraphBuildItem.GetDummyTool: TAbstractExternalTool;
begin
Result:=ExternalToolList.AddDummy('Dummy tool for building package '+LazPackage.Name);
Add(Result);
end;
function TLazPkgGraphBuildItem.GetFirstOrDummy: TAbstractExternalTool;
begin
if Count>0 then
Result:=TAbstractExternalTool(fTools[0])
else
Result:=GetDummyTool;
end;
function TLazPkgGraphBuildItem.GetLastOrDummy: TAbstractExternalTool;
begin
if Count>0 then
Result:=TAbstractExternalTool(fTools[Count-1])
else
Result:=GetDummyTool;
end;
function TLazPkgGraphBuildItem.GetTools(Index: integer): TAbstractExternalTool;
begin
Result:=TAbstractExternalTool(fTools[Index]);
@ -1701,6 +1726,7 @@ begin
PkgCompileTool.ErrorMessage='',SrcPPUFileExists,false);
if MsgResult<>mrOk then begin
Data.ErrorMessage:='SavePackageCompiledState failed';
PkgCompileTool.ErrorMessage:=Data.ErrorMessage;
DebugLn(['TLazPackageGraph.OnExtToolBuildStopped SavePackageCompiledState failed: ',APackage.IDAsString]);
exit;
end;
@ -1713,6 +1739,7 @@ begin
MsgResult:=ConvertPackageRSTFiles(APackage);
if MsgResult<>mrOk then begin
Data.ErrorMessage:='ConvertPackageRSTFiles failed';
PkgCompileTool.ErrorMessage:=Data.ErrorMessage;
DebugLn('TLazPackageGraph.CompilePackage ConvertPackageRSTFiles failed: ',APackage.IDAsString);
IDEMessagesWindow.AddCustomMessage(mluError,
Format(lisUpdatingPoFilesFailedForPackage, [APackage.IDAsString]));
@ -3507,6 +3534,19 @@ function TLazPackageGraph.CompileRequiredPackages(APackage: TLazPackage;
Policy: TPackageUpdatePolicy): TModalResult;
var
BuildItems: TObjectList;
function PkgToBuildItem(Pkg: TLazPackage): TLazPkgGraphBuildItem;
var
i: Integer;
begin
for i:=0 to BuildItems.Count-1 do begin
Result:=TLazPkgGraphBuildItem(BuildItems[i]);
if Result.LazPackage=Pkg then exit;
end;
Result:=nil;
end;
var
PkgList: TFPList;
i: Integer;
Flags: TPkgCompileFlags;
@ -3515,7 +3555,14 @@ var
BuildItem: TLazPkgGraphBuildItem;
j: Integer;
Tool: TAbstractExternalTool;
{$IFDEF EnableGroupCompile}
ToolData: TLazPkgGraphExtToolData;
{$ENDIF}
aDependency: TPkgDependency;
RequiredBuildItem: TLazPkgGraphBuildItem;
Tool1: TAbstractExternalTool;
Tool2: TAbstractExternalTool;
ToolGroup: TExternalToolGroup;
begin
{$IFDEF VerbosePkgCompile}
debugln('TLazPackageGraph.CompileRequiredPackages A MinPolicy=',dbgs(Policy),' SkipDesignTimePackages=',SkipDesignTimePackages);
@ -3527,6 +3574,7 @@ begin
if PkgList<>nil then begin
//DebugLn('TLazPackageGraph.CompileRequiredPackages B Count=',IntToStr(PkgList.Count));
BuildItems:=nil;
ToolGroup:=nil;
BeginUpdate(false);
try
for i:=PkgList.Count-1 downto 0 do begin
@ -3554,6 +3602,7 @@ begin
CurPkg:=TLazPackage(PkgList[i]);
{$IFDEF EnableGroupCompile}
BuildItem:=TLazPkgGraphBuildItem.Create(nil);
BuildItem.LazPackage:=CurPkg;
BuildItems.Add(BuildItem);
{$ELSE}
BuildItem:=nil;
@ -3561,29 +3610,67 @@ begin
Result:=CompilePackage(CurPkg,Flags,false,BuildItem);
if Result<>mrOk then exit;
if (BuildItem<>nil) and (BuildItem.Count>0) then begin
// set dependencies
if (BuildItem<>nil) and (not (lpfNeedGroupCompile in CurPkg.Flags))
then begin
// package is up-to-date
//debugln(['TLazPackageGraph.CompileRequiredPackages no build needed: pkg=',CurPkg.Name]);
BuildItems.Remove(BuildItem);
end;
end;
// add tool dependencies
for i:=0 to BuildItems.Count-1 do begin
BuildItem:=TLazPkgGraphBuildItem(BuildItems[i]);
CurPkg:=BuildItem.LazPackage;
if BuildItem.Count=0 then continue;
// add tools to ToolGroup
if ToolGroup=nil then
ToolGroup:=TExternalToolGroup.Create(nil);
for j:=0 to BuildItem.Count-1 do
BuildItem[j].Group:=ToolGroup;
// add dependencies between tools of this package (execute before, compile, after)
for j:=1 to BuildItem.Count-1 do begin
Tool1:=BuildItem[j-1];
Tool2:=BuildItem[j];
Tool2.AddExecuteBefore(Tool1);
end;
// add dependencies between packages
aDependency:=CurPkg.FirstRequiredDependency;
while aDependency<>nil do begin
RequiredBuildItem:=PkgToBuildItem(aDependency.RequiredPackage);
aDependency:=aDependency.NextRequiresDependency;
if RequiredBuildItem=nil then continue;
if not (lpfNeedGroupCompile in RequiredBuildItem.LazPackage.Flags) then
continue;
Tool1:=BuildItem.GetFirstOrDummy;
Tool2:=RequiredBuildItem.GetLastOrDummy;
Tool1.AddExecuteBefore(Tool2);
end;
end;
// execute
{$IFDEF EnableGroupCompile}
ToolGroup.Execute;
ToolGroup.WaitForExit;
{$ELSE}
for i:=0 to BuildItems.Count-1 do begin
BuildItem:=TLazPkgGraphBuildItem(BuildItems[i]);
for j:=0 to BuildItem.Count-1 do begin
Tool:=BuildItem[j];
if Tool.Terminated then continue;
debugln(['TLazPackageGraph.CompileRequiredPackages ',Tool.Title]);
if Tool.Data is TLazPkgGraphExtToolData then
ToolData:=TLazPkgGraphExtToolData(Tool.Data)
else
ToolData:=nil;
Tool.Execute;
Tool.WaitForExit;
if (Tool.ErrorMessage<>'') or ((ToolData<>nil) and (ToolData.ErrorMessage<>''))
then
if Tool.ErrorMessage<>'' then
exit(mrCancel);
end;
end;
{$ENDIF}
finally
FreeAndNil(ToolGroup);
FreeAndNil(BuildItems);
FreeAndNil(PkgList);
EndUpdate;
@ -4794,7 +4881,9 @@ begin
exit;
end;
if OldShortenSrc<>NewShortenSrc then begin
{$IFDEF VerbosePkgCompile}
DebugLn('TLazPackageGraph.SavePackageMainSource Src changed ',dbgs(length(OldShortenSrc)),' ',dbgs(length(NewShortenSrc)));
{$ENDIF}
end;
// save source

View File

@ -2454,9 +2454,21 @@ var
end;
end;
// unit paths
if not TargetFilesEdit.ExtendUnitSearchPath(NewUnitPaths) then exit(false);
if (NewUnitPaths<>'') and not TargetFilesEdit.ExtendUnitSearchPath(NewUnitPaths)
then begin
{$IFDEF VerbosePkgEditDrag}
debugln(['ExtendSearchPaths ExtendUnitSearchPath failed: NewUnitPaths="',NewUnitPaths,'"']);
{$ENDIF}
exit(false);
end;
// include paths
if not TargetFilesEdit.ExtendIncSearchPath(NewIncPaths) then exit(false);
if (NewIncPaths<>'') and not TargetFilesEdit.ExtendIncSearchPath(NewIncPaths)
then begin
{$IFDEF VerbosePkgEditDrag}
debugln(['ExtendSearchPaths ExtendIncSearchPath failed: NewIncPaths="',NewIncPaths,'"']);
{$ENDIF}
exit(false);
end;
Result:=true;
end;