IDE: Added the option to create new fppkg configuration files to the initial setup dialog

git-svn-id: trunk@60308 -
This commit is contained in:
joost 2019-02-02 20:54:24 +00:00
parent 928d0a0075
commit ba29464f49
6 changed files with 588 additions and 123 deletions

View File

@ -10,7 +10,7 @@ object InitialSetupDialog: TInitialSetupDialog
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '1.1'
LCLVersion = '2.1.0.0'
object PropertiesTreeView: TTreeView
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = WelcomePaintBox
@ -18,13 +18,12 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideRight.Control = Splitter1
AnchorSideBottom.Control = BtnPanel
Left = 6
Height = 285
Height = 276
Top = 54
Width = 159
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
DefaultItemHeight = 18
Images = ImageList1
ReadOnly = True
ScrollBars = ssNone
@ -40,7 +39,7 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideBottom.Control = PropertiesTreeView
AnchorSideBottom.Side = asrBottom
Left = 165
Height = 285
Height = 276
Top = 54
Width = 5
Align = alNone
@ -48,21 +47,21 @@ object InitialSetupDialog: TInitialSetupDialog
end
object BtnPanel: TPanel
Left = 10
Height = 26
Top = 349
Height = 35
Top = 340
Width = 600
Align = alBottom
AutoSize = True
BorderSpacing.Around = 10
BevelOuter = bvNone
ClientHeight = 26
ClientHeight = 35
ClientWidth = 600
TabOrder = 2
object StartIDEBitBtn: TBitBtn
Left = 498
Height = 26
Left = 485
Height = 35
Top = 0
Width = 102
Width = 115
Align = alRight
AutoSize = True
Caption = 'StartIDEBitBtn'
@ -80,13 +79,13 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideBottom.Control = Splitter1
AnchorSideBottom.Side = asrBottom
Left = 170
Height = 285
Height = 276
Top = 54
Width = 444
ActivePage = FPCSourcesTabSheet
ActivePage = FppkgTabSheet
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 6
TabIndex = 2
TabIndex = 5
TabOrder = 3
OnChange = PropertiesPageControlChange
Options = [nboHidePageListPopup]
@ -96,13 +95,13 @@ object InitialSetupDialog: TInitialSetupDialog
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6
ClientHeight = 251
ClientWidth = 440
ClientHeight = 243
ClientWidth = 434
object LazDirLabel: TLabel
Left = 6
Height = 17
Height = 19
Top = 6
Width = 428
Width = 422
Align = alTop
Caption = 'LazDirLabel'
ParentColor = False
@ -115,9 +114,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideRight.Control = LazarusTabSheet
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 29
Width = 428
Height = 36
Top = 31
Width = 422
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
OnChange = LazDirComboBoxChange
@ -128,9 +127,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = LazDirBrowseButton
AnchorSideTop.Side = asrBottom
Left = 6
Height = 146
Top = 99
Width = 428
Height = 106
Top = 114
Width = 422
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
@ -148,9 +147,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 29
Top = 64
Width = 151
Height = 35
Top = 73
Width = 155
AutoSize = True
Caption = 'LazDirBrowseButton'
OnClick = LazDirBrowseButtonClick
@ -163,13 +162,13 @@ object InitialSetupDialog: TInitialSetupDialog
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6
ClientHeight = 251
ClientWidth = 440
ClientHeight = 243
ClientWidth = 434
object CompilerLabel: TLabel
Left = 6
Height = 17
Height = 19
Top = 6
Width = 428
Width = 422
Align = alTop
Caption = 'CompilerLabel'
ParentColor = False
@ -182,9 +181,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideRight.Control = CompilerTabSheet
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 29
Width = 428
Height = 36
Top = 31
Width = 422
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
OnChange = CompilerComboBoxChange
@ -196,9 +195,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = CompilerComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 29
Top = 64
Width = 170
Height = 35
Top = 73
Width = 172
AutoSize = True
Caption = 'CompilerBrowseButton'
OnClick = CompilerBrowseButtonClick
@ -213,9 +212,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideBottom.Control = CompilerTabSheet
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 146
Top = 99
Width = 428
Height = 106
Top = 114
Width = 422
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
'CompilerMemo'
@ -232,13 +231,13 @@ object InitialSetupDialog: TInitialSetupDialog
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6
ClientHeight = 254
ClientWidth = 440
ClientHeight = 243
ClientWidth = 434
object FPCSrcDirLabel: TLabel
Left = 6
Height = 15
Height = 19
Top = 6
Width = 428
Width = 422
Align = alTop
Caption = 'FPCSrcDirLabel'
ParentColor = False
@ -246,9 +245,9 @@ object InitialSetupDialog: TInitialSetupDialog
end
object FPCSrcDirComboBox: TComboBox
Left = 6
Height = 27
Top = 27
Width = 428
Height = 36
Top = 31
Width = 422
Align = alTop
ItemHeight = 0
OnChange = FPCSrcDirComboBoxChange
@ -260,9 +259,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = FPCSrcDirComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 25
Top = 60
Width = 161
Height = 35
Top = 73
Width = 182
AutoSize = True
Caption = 'FPCSrcDirBrowseButton'
OnClick = FPCSrcDirBrowseButtonClick
@ -272,9 +271,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = FPCSrcDirBrowseButton
AnchorSideTop.Side = asrBottom
Left = 6
Height = 157
Top = 91
Width = 428
Height = 106
Top = 114
Width = 422
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
@ -290,10 +289,10 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FPCSrcDirBrowseButton
AnchorSideTop.Side = asrCenter
Left = 179
Height = 15
Top = 65
Width = 58
Left = 200
Height = 19
Top = 81
Width = 60
BorderSpacing.Left = 12
Caption = 'Scanning'
ParentColor = False
@ -303,9 +302,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ScanLabel
AnchorSideTop.Side = asrCenter
Left = 243
Left = 266
Height = 20
Top = 62
Top = 80
Width = 102
BorderSpacing.Left = 6
Style = pbstMarquee
@ -318,9 +317,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ScanProgressBar
AnchorSideRight.Side = asrBottom
Left = 351
Left = 374
Height = 25
Top = 60
Top = 78
Width = 78
Caption = 'Stop'
OnClick = StopScanButtonClick
@ -329,13 +328,13 @@ object InitialSetupDialog: TInitialSetupDialog
end
object MakeExeTabSheet: TTabSheet
Caption = 'MakeExeTabSheet'
ClientHeight = 254
ClientWidth = 440
ClientHeight = 243
ClientWidth = 434
object MakeExeComboBox: TComboBox
Left = 6
Height = 27
Top = 27
Width = 428
Height = 36
Top = 31
Width = 422
Align = alTop
BorderSpacing.Around = 6
ItemHeight = 0
@ -345,9 +344,9 @@ object InitialSetupDialog: TInitialSetupDialog
end
object MakeExeLabel: TLabel
Left = 6
Height = 15
Height = 19
Top = 6
Width = 428
Width = 422
Align = alTop
BorderSpacing.Around = 6
Caption = 'MakeExeLabel'
@ -359,9 +358,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = MakeExeComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 25
Top = 60
Width = 156
Height = 35
Top = 73
Width = 171
AutoSize = True
BorderSpacing.Around = 6
Caption = 'MakeExeBrowseButton'
@ -372,9 +371,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = MakeExeBrowseButton
AnchorSideTop.Side = asrBottom
Left = 6
Height = 157
Top = 91
Width = 428
Height = 106
Top = 114
Width = 422
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
@ -389,13 +388,13 @@ object InitialSetupDialog: TInitialSetupDialog
end
object DebuggerTabSheet: TTabSheet
Caption = 'DebuggerTabSheet'
ClientHeight = 251
ClientWidth = 440
ClientHeight = 243
ClientWidth = 434
object DebuggerComboBox: TComboBox
Left = 6
Height = 21
Top = 29
Width = 428
Height = 36
Top = 31
Width = 422
Align = alTop
BorderSpacing.Around = 6
ItemHeight = 0
@ -405,9 +404,9 @@ object InitialSetupDialog: TInitialSetupDialog
end
object DebuggerLabel: TLabel
Left = 6
Height = 17
Height = 19
Top = 6
Width = 428
Width = 422
Align = alTop
BorderSpacing.Around = 6
Caption = 'DebuggerLabel'
@ -419,9 +418,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = DebuggerComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 29
Top = 64
Width = 173
Height = 35
Top = 73
Width = 176
AutoSize = True
BorderSpacing.Around = 6
Caption = 'DebuggerBrowseButton'
@ -432,9 +431,9 @@ object InitialSetupDialog: TInitialSetupDialog
AnchorSideTop.Control = DebuggerBrowseButton
AnchorSideTop.Side = asrBottom
Left = 6
Height = 146
Top = 99
Width = 428
Height = 123
Top = 114
Width = 422
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
@ -447,6 +446,82 @@ object InitialSetupDialog: TInitialSetupDialog
TabOrder = 2
end
end
object FppkgTabSheet: TTabSheet
Caption = 'FppkgTabSheet'
ClientHeight = 243
ClientWidth = 434
object FppkgComboBox: TComboBox
Left = 6
Height = 36
Top = 31
Width = 422
Align = alTop
BorderSpacing.Around = 6
ItemHeight = 0
OnChange = FppkgComboBoxChange
TabOrder = 0
Text = 'FppkgComboBox'
end
object FppkgLabel: TLabel
Left = 6
Height = 19
Top = 6
Width = 422
Align = alTop
BorderSpacing.Around = 6
Caption = 'FppkgLabel'
ParentColor = False
WordWrap = True
end
object FppkgBrowseButton: TButton
AnchorSideLeft.Control = DebuggerTabSheet
AnchorSideTop.Control = FppkgComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 35
Top = 73
Width = 151
AutoSize = True
BorderSpacing.Around = 6
Caption = 'FppkgBrowseButton'
OnClick = FppkgBrowseButtonClick
TabOrder = 1
end
object FppkgMemo: TMemo
AnchorSideTop.Control = FppkgBrowseButton
AnchorSideTop.Side = asrBottom
Left = 6
Height = 123
Top = 114
Width = 422
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
Lines.Strings = (
'FPCSrcDirMemo'
''
''
)
ReadOnly = True
TabOrder = 2
end
object FppkgWriteConfigButton: TButton
AnchorSideLeft.Control = DebuggerTabSheet
AnchorSideTop.Control = FppkgComboBox
AnchorSideTop.Side = asrBottom
Left = 247
Height = 35
Top = 73
Width = 181
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'FppkgWriteConfigButton'
Enabled = False
OnClick = FppkgWriteConfigButtonClick
TabOrder = 3
end
end
end
object WelcomePaintBox: TPaintBox
Left = 0
@ -457,7 +532,7 @@ object InitialSetupDialog: TInitialSetupDialog
OnPaint = WelcomePaintBoxPaint
end
object ImageList1: TImageList
left = 55
top = 145
Left = 55
Top = 145
end
end

View File

@ -43,14 +43,16 @@ uses
// RTL + FCL + LCL
Classes, SysUtils,
Forms, Controls, Buttons, Dialogs, Graphics, ComCtrls, ExtCtrls, StdCtrls, LCLProc,
pkgglobals, UTF8Process,
// CodeTools
FileProcs, CodeToolManager, DefineTemplates,
// LazUtils
FileUtil, LazUTF8, LazUTF8Classes, LazFileUtils, LazFileCache, LazLoggerBase,
// Other
MacroDefIntf, GDBMIDebugger, DbgIntfDebuggerBase,
MacroDefIntf, GDBMIDebugger, DbgIntfDebuggerBase, IDEDialogs,
TransferMacros, LazarusIDEStrConsts, LazConf, EnvironmentOpts, IDEImagesIntf,
AboutFrm, IDETranslations, BaseBuildManager, InitialSetupProc;
AboutFrm, IDETranslations, BaseBuildManager, InitialSetupProc, FppkgHelper,
IDEProcs;
type
TInitialSetupDialog = class;
@ -116,6 +118,12 @@ type
StartIDEBitBtn: TBitBtn;
StopScanButton: TBitBtn;
WelcomePaintBox: TPaintBox;
FppkgTabSheet: TTabSheet;
FppkgComboBox: TComboBox;
FppkgLabel: TLabel;
FppkgBrowseButton: TButton;
FppkgMemo: TMemo;
FppkgWriteConfigButton: TButton;
procedure CompilerBrowseButtonClick(Sender: TObject);
procedure CompilerComboBoxChange(Sender: TObject);
procedure DebuggerBrowseButtonClick(Sender: TObject);
@ -135,6 +143,9 @@ type
procedure StopScanButtonClick(Sender: TObject);
procedure WelcomePaintBoxPaint(Sender: TObject);
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
procedure FppkgComboBoxChange(Sender: TObject);
procedure FppkgBrowseButtonClick(Sender: TObject);
procedure FppkgWriteConfigButtonClick(Sender: TObject);
private
FFlags: TSDFlags;
FLastParsedLazDir: string;
@ -142,6 +153,8 @@ type
fLastParsedFPCSrcDir: string;
fLastParsedMakeExe: string;
fLastParsedDebugger: string;
fLastParsedFppkgPrefix: string;
fLastParsedFppkgLibPath: string;
FIdleConnected: boolean;
ImgIDError: LongInt;
ImgIDWarning: LongInt;
@ -160,6 +173,7 @@ type
procedure UpdateFPCSrcDirCandidate(aFPCSrcDirInfo: TSDFileInfo);
procedure UpdateMakeExeCandidates;
procedure UpdateDebuggerCandidates;
procedure UpdateFppkgCandidates;
procedure FillComboboxWithFileInfoList(ABox: TComboBox; List: TSDFileInfoList;
ItemIndex: integer = 0);
procedure SetIdleConnected(const AValue: boolean);
@ -168,6 +182,7 @@ type
procedure UpdateFPCSrcDirNote;
procedure UpdateMakeExeNote;
procedure UpdateDebuggerNote;
procedure UpdateFppkgNote;
function FirstErrorNode: TTreeNode;
function GetFPCVer: string;
function GetFirstCandidate(Candidates: TSDFileInfoList;
@ -176,12 +191,14 @@ type
procedure ShowHideScanControls(aShow: Boolean);
procedure ThreadTerminated(Sender: TObject); // called in main thread by fSearchFpcSourceThread.OnTerminate
procedure TranslateResourceStrings;
function CheckFppkgQuality(APrefix: string; out LibPath, Note: string): TSDFilenameQuality;
public
TVNodeLazarus: TTreeNode;
TVNodeCompiler: TTreeNode;
TVNodeFPCSources: TTreeNode;
TVNodeMakeExe: TTreeNode;
TVNodeDebugger: TTreeNode;
TVNodeFppkg: TTreeNode;
procedure Init; //Check for config errors, find and show alternatives
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
end;
@ -477,6 +494,7 @@ begin
FPCSourcesTabSheet.Caption:=lisFPCSources;
MakeExeTabSheet.Caption:='Make';
DebuggerTabSheet.Caption:=lisDebugger;
FppkgTabSheet.Caption := 'Fppkg';
FHeadGraphic:=TPortableNetworkGraphic.Create;
FHeadGraphic.LoadFromResourceName(HInstance, 'ide_icon48x48');
@ -486,6 +504,12 @@ begin
TVNodeFPCSources:=PropertiesTreeView.Items.Add(nil,FPCSourcesTabSheet.Caption);
TVNodeMakeExe:=PropertiesTreeView.Items.Add(nil,MakeExeTabSheet.Caption);
TVNodeDebugger:=PropertiesTreeView.Items.Add(nil,DebuggerTabSheet.Caption);
{$IF FPC_FULLVERSION>30100}
TVNodeFppkg:=PropertiesTreeView.Items.Add(nil,FppkgTabSheet.Caption);
FppkgTabSheet.TabVisible := True;
{$ELSE}
FppkgTabSheet.TabVisible := False;
{$ENDIF FPC_FULLVERSION>30100}
ImgIDError := Imagelist1.AddResourceName(HInstance, 'state_error');
ImgIDWarning := Imagelist1.AddResourceName(HInstance, 'state_warning');
@ -732,6 +756,10 @@ begin
end else if sdfDebuggerFilenameNeedsUpdate in FFlags then begin
UpdateDebuggerCandidates;
UpdateDebuggerNote;
end else if sdfFppkgFpcPrefixNeedsUpdate in FFlags then begin
fLastParsedFppkgPrefix := '';
UpdateFppkgCandidates;
UpdateFppkgNote;
end else
IdleConnected:=false;
end;
@ -749,17 +777,25 @@ begin
FPCSourcesTabSheet.Caption:=lisFPCSources;
MakeExeTabSheet.Caption:='Make';
DebuggerTabSheet.Caption:=lisDebugger;
FppkgTabSheet.Caption:='Fppkg';
TVNodeLazarus.Text:=LazarusTabSheet.Caption;
TVNodeCompiler.Text:=CompilerTabSheet.Caption;
TVNodeFPCSources.Text:=FPCSourcesTabSheet.Caption;
TVNodeMakeExe.Text:=MakeExeTabSheet.Caption;
TVNodeDebugger.Text:=DebuggerTabSheet.Caption;
{$IF FPC_FULLVERSION>30100}
TVNodeFppkg.Text:=FppkgTabSheet.Caption;
{$ENDIF FPC_FULLVERSION>30100}
LazDirBrowseButton.Caption:=lisPathEditBrowse;
LazDirLabel.Caption:=SimpleFormat(
lisTheLazarusDirectoryContainsTheSourcesOfTheIDEAndTh, [PathDelim]);
FppkgLabel.Caption:=lisFppkgInstallationPath;
FppkgBrowseButton.Caption:=lisPathEditBrowse;
FppkgWriteConfigButton.Caption:=lisCreateFppkgConfig;
CompilerBrowseButton.Caption:=lisPathEditBrowse;
CompilerLabel.Caption:=SimpleFormat(lisTheFreePascalCompilerExecutableTypicallyHasTheName,
[DefineTemplates.GetDefaultCompilerFilename,
@ -1006,7 +1042,7 @@ begin
TVNodeCompiler.ImageIndex:=ImageIndex;
TVNodeCompiler.SelectedIndex:=ImageIndex;
FFlags:=FFlags+[sdfFPCSrcDirNeedsUpdate,
FFlags:=FFlags+[sdfFPCSrcDirNeedsUpdate,sdfFppkgFpcPrefixNeedsUpdate,
sdfMakeExeFilenameNeedsUpdate,sdfDebuggerFilenameNeedsUpdate];
IdleConnected:=true;
end;
@ -1322,6 +1358,10 @@ begin
fLastParsedDebugger:='. .';
UpdateDebuggerNote;
// Fppkg
UpdateFppkgCandidates;
UpdateFppkgNote;
// select first error
Node:=FirstErrorNode;
if Node=nil then
@ -1329,5 +1369,237 @@ begin
PropertiesTreeView.Selected:=Node;
end;
procedure TInitialSetupDialog.UpdateFppkgNote;
var
CurCaption: String;
Msg, Note: string;
Quality: TSDFilenameQuality;
ImageIndex: Integer;
begin
if csDestroying in ComponentState then exit;
CurCaption:=FppkgComboBox.Text;
if fLastParsedFppkgPrefix=CurCaption then exit;
fLastParsedFppkgPrefix:=CurCaption;
Quality := CheckFppkgConfiguration();
Msg := '';
if CheckFppkgQuality(CurCaption,fLastParsedFppkgLibPath,Note)<>sddqCompatible then
Msg := Note;
if (CheckFPCExeQuality(fLastParsedCompiler,Note, CodeToolBoss.CompilerDefinesCache.TestFilename)<>sddqCompatible) then
Msg := Msg + lisWarning + lisFppkgCompilerProblem +Note;
if Quality=sddqCompatible then
Note := lisOk
else
Note := lisError + lisIncorrectFppkgConfiguration + LineEnding;
if Msg<>'' then
begin
Note := Note + LineEnding + Msg;
FppkgWriteConfigButton.Enabled := False;
end
else
begin
FppkgWriteConfigButton.Enabled := True;
end;
FppkgMemo.Text := Note;
ImageIndex:=QualityToImgIndex(Quality);
{$IF FPC_FULLVERSION>30100}
TVNodeFppkg.ImageIndex:=ImageIndex;
TVNodeFppkg.SelectedIndex:=ImageIndex;
{$ENDIF FPC_FULLVERSION>30100}
IdleConnected:=true;
end;
function TInitialSetupDialog.CheckFppkgQuality(APrefix: string; out LibPath, Note: string): TSDFilenameQuality;
var
SR: TRawByteSearchRec;
LibPathValid: Boolean;
begin
Result := sddqInvalid;
LibPath := '';
APrefix:=TrimFilename(APrefix);
if not FileExistsCached(APrefix) then
begin
Note:= lisWarning + lisFreePascalPrefix + ' ' + lisISDDirectoryNotFound + LineEnding;
end
else if not DirPathExistsCached(APrefix) then
begin
Note:= lisWarning + lisFreePascalPrefix + ' ' + lisPathIsNoDirectory + LineEnding;
end
else
begin
LibPathValid := True;
LibPath := IncludeTrailingPathDelimiter(ConcatPaths([APrefix, 'lib', 'fpc']));
if not DirPathExistsCached(LibPath) then
begin
LibPath := IncludeTrailingPathDelimiter(ConcatPaths([APrefix, 'lib64', 'fpc']));
if not DirPathExistsCached(LibPath) then
begin
LibPathValid := False;
end;
end;
if LibPathValid and (FindFirstUTF8(LibPath+AllFilesMask, faDirectory, SR) = 0) then
begin
LibPathValid := False;
repeat
if (SR.Name<>'.') and (SR.Name<>'..') then
begin
if DirPathExistsCached(LibPath+SR.Name+PathDelim+'fpmkinst') and
DirPathExistsCached(LibPath+SR.Name+PathDelim+'units') then
begin
LibPathValid := True;
Result := sddqCompatible;
Break;
end;
end;
until FindNext(SR) <> 0;
FindCloseUTF8(SR);
end;
if not LibPathValid then
Note:= Note + lisWarning + lisNotAValidFppkgPrefix + LineEnding
else
Note:='';
end;
end;
procedure TInitialSetupDialog.FppkgComboBoxChange(Sender: TObject);
begin
UpdateFppkgNote;
end;
procedure TInitialSetupDialog.UpdateFppkgCandidates;
function SearchFppkgFpcPrefixCandidates: TSDFileInfoList;
function CheckPath(APath: string; var List: TSDFileInfoList): boolean;
var
Item: TSDFileInfo;
LibPath, Note: String;
begin
Result:=false;
if APath='' then exit;
ForcePathDelims(APath);
// check if already checked
if Assigned(List) and List.CaptionExists(APath) then exit;
if CheckFppkgQuality(APath, LibPath, Note) = sddqCompatible then
begin
if List=nil then
List:=TSDFileInfoList.create(true);
Item:=List.AddNewItem(APath, APath);
Item.Quality:=sddqCompatible;
Result := True;
end;
end;
begin
Result:=nil;
CheckPath(ExtractFileDir(ExtractFileDir(EnvironmentOptions.GetParsedCompilerFilename)), Result);
{$ifdef windows}
CheckPath('c:\pp', Result);
CheckPath('d:\pp', Result);
{$else}
CheckPath('/usr', Result);
CheckPath('/usr/local', Result);
{$endif unix}
end;
var
Files: TSDFileInfoList;
begin
Exclude(FFlags,sdfFppkgFpcPrefixNeedsUpdate);
Files:=SearchFppkgFpcPrefixCandidates;
FreeAndNil(FCandidates[sddtFppkgFpcPrefix]);
FCandidates[sddtFppkgFpcPrefix]:=Files;
FillComboboxWithFileInfoList(FppkgComboBox,Files);
end;
procedure TInitialSetupDialog.FppkgBrowseButtonClick(Sender: TObject);
var
Dlg: TSelectDirectoryDialog;
begin
Dlg:=TSelectDirectoryDialog.Create(nil);
try
Dlg.Title:=lisSelectFPCPath;
Dlg.Options:=Dlg.Options+[ofPathMustExist];
if not Dlg.Execute then exit;
FppkgComboBox.Text:=Dlg.FileName;
finally
Dlg.Free;
end;
UpdateFppkgNote;
end;
procedure TInitialSetupDialog.FppkgWriteConfigButtonClick(Sender: TObject);
{$IF FPC_FULLVERSION>30100}
var
FpcmkcfgExecutable, CompConfigFilename: string;
Proc: TProcessUTF8;
Fppkg: TFppkgHelper;
{$ENDIF}
begin
{$IF FPC_FULLVERSION>30100}
try
FpcmkcfgExecutable := FindFPCTool('fpcmkcfg'+GetExecutableExt, EnvironmentOptions.GetParsedCompilerFilename);
if FpcmkcfgExecutable<>'' then
begin
Proc := TProcessUTF8.Create(nil);
try
// Write fppkg.cfg
Proc.Executable := FpcmkcfgExecutable;
proc.Parameters.Add('-3');
proc.Parameters.Add('-o');
proc.Parameters.Add(GetFppkgConfigFile(False, False));
proc.Parameters.Add('-d');
proc.Parameters.Add('globalpath='+fLastParsedFppkgLibPath);
proc.Parameters.Add('-d');
proc.Parameters.Add('globalprefix='+fLastParsedFppkgPrefix);
proc.Execute;
Fppkg:=TFppkgHelper.Instance;
Fppkg.ReInitialize;
// Write default compiler configuration file
CompConfigFilename := Fppkg.GetCompilerConfigurationFileName;
if CompConfigFilename <> '' then
begin
proc.Parameters.Clear;
proc.Parameters.Add('-4');
proc.Parameters.Add('-o');
proc.Parameters.Add(CompConfigFilename);
proc.Parameters.Add('-d');
proc.Parameters.Add('fpcbin='+EnvironmentOptions.GetParsedCompilerFilename);
proc.Execute;
end;
Fppkg.ReInitialize;
finally
Proc.Free;
end;
end;
except
on E: Exception do
IDEMessageDialog(lisFppkgProblem, Format(lisFppkgWriteConfException, [E.Message]), mtWarning, [mbOK]);
end;
fLastParsedFppkgPrefix := '';
UpdateFppkgNote;
{$ENDIF}
if CheckFppkgConfiguration<>sddqCompatible then
IDEMessageDialog(lisFppkgProblem, lisFppkgWriteConfFailed, mtWarning, [mbOK]);
end;
end.

View File

@ -40,7 +40,7 @@ uses
LazFileCache, LazUTF8, LazUTF8Classes, LazFileUtils, FileUtil,
LazLoggerBase, Laz2_XMLCfg,
// IDE
LazarusIDEStrConsts, LazConf, EnvironmentOpts;
LazarusIDEStrConsts, LazConf, EnvironmentOpts, FppkgHelper;
type
TSDFilenameQuality = (
@ -71,14 +71,16 @@ type
sddtCompilerFilename,
sddtFPCSrcDir,
sddtMakeExeFilename,
sddtDebuggerFilename
sddtDebuggerFilename,
sddtFppkgFpcPrefix
);
TSDFlag = (
sdfCompilerFilenameNeedsUpdate,
sdfFPCSrcDirNeedsUpdate,
sdfMakeExeFilenameNeedsUpdate,
sdfDebuggerFilenameNeedsUpdate
sdfDebuggerFilenameNeedsUpdate,
sdfFppkgFpcPrefixNeedsUpdate
);
TSDFlags = set of TSDFlag;
@ -104,6 +106,9 @@ function CheckFPCSrcDirQuality(ADirectory: string; out Note: string;
function SearchFPCSrcDirCandidates(StopIfFits: boolean;
const FPCVer: string): TSDFileInfoList;
// Fppkg
function CheckFppkgConfiguration(): TSDFilenameQuality;
// Make
// Checks a given file to see if it is a valid make executable
function CheckMakeExeQuality(AFilename: string; out Note: string): TSDFilenameQuality;
@ -827,6 +832,17 @@ begin
end;
end;
function CheckFppkgConfiguration(): TSDFilenameQuality;
var
Fppkg: TFppkgHelper;
begin
Fppkg := TFppkgHelper.Instance;
if Fppkg.IsProperlyConfigured then
Result := sddqCompatible
else
Result := sddqInvalid;
end;
function CheckMakeExeQuality(AFilename: string; out Note: string
): TSDFilenameQuality;
begin

View File

@ -1038,6 +1038,20 @@ resourcestring
lisCreateIt = 'Create it';
lisInvalidFileName = 'Invalid file name';
lisTheTargetFileNameIsADirectory = 'The target file name is a directory.';
lisNotAValidFppkgPrefix ='Free Pascal compiler not found at the given prefix.';
lisIncorrectFppkgConfiguration = 'the Fppkg configuration is corrupt.';
lisFppkgCompilerProblem = 'there is a problem with the Free Pascal compiler executable, ';
lisFppkgInstallationPath = 'The prefix of the Free Pascal Compiler installation ' +
'is required to create new configuration files for Fppkg. For example it has ' +
'the file "lib/fpc" or "lib64/fpc"';
lisSelectFPCPath = 'Select the path where FPC is installed';
lisCreateFppkgConfig = 'Create new Fppkg configuration';
lisFppkgProblem = 'Problem with Fppkg configuration';
lisFreePascalPrefix = 'Free Pascal compiler prefix';
lisFppkgWriteConfException = 'A problem occured while trying to create a new ' +
'Fppkg configuration: %s';
lisFppkgWriteConfFailed = 'Failed to create a new Fppkg configuration. You ' +
'will have to fix the configuration manually or reinstall Free Pascal.';
// file dialogs
lisOpenFile = 'Open File';
@ -1147,10 +1161,6 @@ resourcestring
lisSaveAllChecked = 'Save All Checked';
lisActivate = 'Activate';
lisActivateSelected = 'Activate Selected';
lisFppkgInitializeFailedCaption = 'Failed to initialize Fppkg';
lisFppkgInitializeFailed =
'An error occurred during the initialization of Fppkg: %s.' + sLineBreak +
'Check your Fppkg configuration and restart Lazarus to be able to use Fppkg''s functionality.';
// hints
lisHintSaveAll = 'Save all';
@ -6220,6 +6230,7 @@ resourcestring
dbgBreakPropertyGroupNotFound = 'Some groups in the Enable/Disable list do not exist.%0:s'
+'Create them?%0:s%0:s%1:s';
lisFileIsDirectory = 'File is directory';
lisPathIsNoDirectory = 'is not a directory';
lisUnableToCreateNewFileBecauseThereIsAlreadyADirecto = 'Unable to create '
+'new file because there is already a directory with this name.';

View File

@ -1444,6 +1444,14 @@ begin
ShowSetupDialog:=true;
end;
// check fppkg configuration
if (not ShowSetupDialog)
and (CheckFppkgConfiguration()<>sddqCompatible)
then begin
debugln('Warning: (lazarus) fppkg not properly configured.');
ShowSetupDialog:=true;
end;
// show setup dialog
if ShowSetupDialog then begin
OldLazDir:=EnvironmentOptions.LazarusDirectory;

View File

@ -7,13 +7,14 @@ interface
uses
Classes,
SysUtils,
{$IFNDEF VER3_0}
IDEDialogs,
{$IF FPC_FULLVERSION>30100}
pkgFppkg,
LazarusIDEStrConsts,
{$ENDIF}
fprepos,
Dialogs;
LazLogger,
LazFileCache,
FileUtil,
LazFileUtils;
type
@ -25,11 +26,12 @@ type
TFppkgHelper = class
private
{$IFNDEF VER3_0}
{$IF FPC_FULLVERSION>30100}
FFPpkg: TpkgFPpkg;
{$ENDIF}
FIsProperlyConfigured: TFppkgPropConfigured;
function HasFPCPackagesOnly(const PackageName: string): Boolean;
procedure InitializeFppkg;
public
constructor Create;
destructor Destroy; override;
@ -38,9 +40,12 @@ type
procedure ListPackages(AList: TStringList);
function GetPackageUnitPath(const PackageName: string): string;
function IsProperlyConfigured: Boolean;
function GetCompilerFilename: string;
function GetCompilerConfigurationFileName: string;
// Temporary solution, because fpc 3.2.0 does not has support for package-variants
// in TFPPackage
function GetPackageVariantArray(const PackageName: string): TFppkgPackageVariantArray;
procedure ReInitialize;
end;
implementation
@ -50,8 +55,8 @@ var
{ TFppkgHelper }
constructor TFppkgHelper.Create;
{$IFDEF VER3_0}
procedure TFppkgHelper.InitializeFppkg;
{$IF NOT (FPC_FULLVERSION>30100)}
begin
end;
{$ELSE}
@ -75,19 +80,24 @@ begin
FPpkg := nil;
except
on E: Exception do
IDEMessageDialog(lisFppkgInitializeFailed, Format(lisFppkgInitializeFailed, [E.Message]), mtWarning, [mbOK]);
debugln(['InitializeFppkg failed: '+E.Message]);
end;
finally
FPpkg.Free;
end;
end;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
constructor TFppkgHelper.Create;
begin
InitializeFppkg;
end;
destructor TFppkgHelper.Destroy;
begin
{$IFNDEF VER3_0}
{$IF FPC_FULLVERSION>30100}
FFPpkg.Free;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
inherited Destroy;
end;
@ -100,7 +110,7 @@ end;
function TFppkgHelper.HasPackage(const PackageName: string): Boolean;
begin
{$IFDEF VER3_0}
{$IF NOT (FPC_FULLVERSION>30100)}
Result := HasFPCPackagesOnly(PackageName);
{$ELSE }
if IsProperlyConfigured() then
@ -124,19 +134,18 @@ begin
end
else
Result := HasFPCPackagesOnly(PackageName);
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
end;
procedure TFppkgHelper.ListPackages(AList: TStringList);
{$IFNDEF VER3_0}
{$IF FPC_FULLVERSION>30100}
var
I, J: Integer;
Repository: TFPRepository;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
begin
{$IFDEF VER3_0}
if AList=nil then ;
{$ELSE}
AList.Clear;
{$IF FPC_FULLVERSION>30100}
if not Assigned(FFPpkg) then
Exit;
for I := 0 to FFPpkg.RepositoryList.Count -1 do
@ -147,20 +156,20 @@ begin
AList.AddObject(Repository.Packages[J].Name, Repository.Packages[J]);
end;
end;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
end;
function TFppkgHelper.GetPackageUnitPath(const PackageName: string): string;
{$IFNDEF VER3_0}
{$IF FPC_FULLVERSION>30100}
var
FppkgPackage: TFPPackage;
{$IF not (FPC_FULLVERSION>30300)}
PackageVariantsArray: TFppkgPackageVariantArray;
{$ENDIF}
i: Integer;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
begin
{$IFDEF VER3_0}
{$IF NOT (FPC_FULLVERSION>30100)}
if PackageName='' then ;
Result := '';
{$ELSE}
@ -194,7 +203,7 @@ begin
// be installed into, and use the corresponding packagestructure.
Result := '';
end;
{$ENDIF VER3_0}
{$ENDIF FPC_FULLVERSION>30100}
end;
function TFppkgHelper.GetPackageVariantArray(const PackageName: string): TFppkgPackageVariantArray;
@ -253,16 +262,42 @@ begin
end;
function TFppkgHelper.IsProperlyConfigured: Boolean;
{$IF FPC_FULLVERSION>30100}
var
CompilerFilename: string;
{$ENDIF FPC_FULLVERSION>30100}
begin
{$IF FPC_FULLVERSION>30100}
if Assigned(FFPpkg) and (FIsProperlyConfigured=fpcUnknown) then
begin
FIsProperlyConfigured := fpcYes;
if not HasPackage('rtl') then
FIsProperlyConfigured := fpcNo;
FIsProperlyConfigured := fpcNo
else
begin
CompilerFilename := FFPpkg.CompilerOptions.Compiler;
if Pos(PathDelim, CompilerFilename) > 0 then
begin
if not FileExistsCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
else if not FileIsExecutableCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
end
else
begin
CompilerFilename := ExeSearch(CompilerFilename);
if CompilerFilename = '' then
FIsProperlyConfigured := fpcNo
else if not FileIsExecutableCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
end
end;
end;
{$ENDIF FPC_FULLVERSION>30100}
result := FIsProperlyConfigured=fpcYes;
{$ELSE}
result := True
{$ENDIF FPC_FULLVERSION>30100}
end;
function TFppkgHelper.HasFPCPackagesOnly(const PackageName: string): Boolean;
@ -405,6 +440,54 @@ begin
Result := False;
end;
function TFppkgHelper.GetCompilerFilename: string;
begin
Result := '';
{$IF FPC_FULLVERSION>30100}
if Assigned(FFPpkg) then
begin
Result := FFPpkg.CompilerOptions.Compiler;
end;
{$ENDIF}
end;
procedure TFppkgHelper.ReInitialize;
begin
FIsProperlyConfigured := fpcUnknown;
{$IF FPC_FULLVERSION>30100}
FFPpkg.Free;
{$ENDIF}
InitializeFppkg;
end;
function TFppkgHelper.GetCompilerConfigurationFileName: string;
{$IF FPC_FULLVERSION>30100}
var
FPpkg: TpkgFPpkg;
{$ENDIF}
begin
Result := '';
{$IF FPC_FULLVERSION>30100}
if Assigned(FFPpkg) then
Result:=ConcatPaths([FFPpkg.Options.GlobalSection.CompilerConfigDir, FFPpkg.Options.CommandLineSection.CompilerConfig])
else
begin
FPpkg := TpkgFPpkg.Create(nil);
try
try
FPpkg.InitializeGlobalOptions('');
Result:=ConcatPaths([FPpkg.Options.GlobalSection.CompilerConfigDir, FPpkg.Options.CommandLineSection.CompilerConfig])
except
on E: Exception do
debugln(['Fppkg initialize global options failed: '+E.Message]);
end;
finally
FPpkg.Free;
end;
end
{$ENDIF}
end;
finalization
GFppkgHelper.Free;
end.