IDE: Show why Lazarus marks the fppkg-configuration as being corrupt

git-svn-id: trunk@60758 -
This commit is contained in:
joost 2019-03-24 12:50:57 +00:00
parent f11f384ce4
commit bbb8263057
5 changed files with 47 additions and 20 deletions

View File

@ -1377,7 +1377,7 @@ end;
procedure TInitialSetupDialog.UpdateFppkgNote;
var
CurCaption: String;
Msg, Note: string;
Msg, FppkgMsg, Note: string;
Quality: TSDFilenameQuality;
{$IF FPC_FULLVERSION>30100}
ImageIndex: Integer;
@ -1388,7 +1388,7 @@ begin
if (fLastParsedFppkgPrefix=CurCaption) and (CurCaption<>'') then exit;
fLastParsedFppkgPrefix:=CurCaption;
Quality := CheckFppkgConfiguration();
Quality := CheckFppkgConfiguration(FppkgMsg);
Msg := '';
if CheckFppkgQuality(CurCaption,fLastParsedFppkgLibPath,Note)<>sddqCompatible then
@ -1401,7 +1401,7 @@ begin
if Quality=sddqCompatible then
Note := lisOk
else
Note := lisError + lisIncorrectFppkgConfiguration + LineEnding;
Note := lisError + Format(lisIncorrectFppkgConfiguration, [FppkgMsg]) + LineEnding;
if Msg<>'' then
begin
@ -1587,8 +1587,9 @@ begin
end;
procedure TInitialSetupDialog.FppkgWriteConfigButtonClick(Sender: TObject);
{$IF FPC_FULLVERSION>30100}
var
Msg: string;
{$IF FPC_FULLVERSION>30100}
FpcmkcfgExecutable, CompConfigFilename: string;
Proc: TProcessUTF8;
Fppkg: TFppkgHelper;
@ -1659,8 +1660,8 @@ begin
UpdateFppkgNote;
{$ENDIF}
if CheckFppkgConfiguration<>sddqCompatible then
IDEMessageDialog(lisFppkgProblem, lisFppkgWriteConfFailed, mtWarning, [mbOK]);
if CheckFppkgConfiguration(Msg)<>sddqCompatible then
IDEMessageDialog(lisFppkgProblem, Format(lisFppkgWriteConfFailed, [Msg], mtWarning, [mbOK]);
end;
function TInitialSetupDialog.CheckFpcmkcfgQuality(out Note: string): TSDFilenameQuality;

View File

@ -107,7 +107,7 @@ function SearchFPCSrcDirCandidates(StopIfFits: boolean;
const FPCVer: string): TSDFileInfoList;
// Fppkg
function CheckFppkgConfiguration(): TSDFilenameQuality;
function CheckFppkgConfiguration(out Msg: string): TSDFilenameQuality;
// Make
// Checks a given file to see if it is a valid make executable
@ -832,12 +832,12 @@ begin
end;
end;
function CheckFppkgConfiguration(): TSDFilenameQuality;
function CheckFppkgConfiguration(out Msg: string): TSDFilenameQuality;
var
Fppkg: TFppkgHelper;
begin
Fppkg := TFppkgHelper.Instance;
if Fppkg.IsProperlyConfigured then
if Fppkg.IsProperlyConfigured(Msg) then
Result := sddqCompatible
else
Result := sddqInvalid;

View File

@ -1039,7 +1039,7 @@ resourcestring
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.';
lisIncorrectFppkgConfiguration = 'there is a problem with the Fppkg configuration. (%s)';
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 ' +
@ -1050,7 +1050,7 @@ resourcestring
lisFreePascalPrefix = 'Free Pascal compiler prefix';
lisFppkgWriteConfException = 'A problem occurred while trying to create a new ' +
'Fppkg configuration: %s';
lisFppkgWriteConfFailed = 'Failed to create a new Fppkg configuration. You ' +
lisFppkgWriteConfFailed = 'Failed to create a new Fppkg configuration (%s) You ' +
'will have to fix the configuration manually or reinstall Free Pascal.';
lisNoFppkgPrefix = 'empty Free Pascal compiler prefix.';
lisFppkgCreateFileFailed = 'Failed to generate the configuration file "%s".';
@ -1064,6 +1064,10 @@ resourcestring
lifFppkgFpcmkcfgProbTooOld = 'It is probably too old to create the configuration files.';
lisFppkgFpcmkcfgMissing = 'Could not find the fpcmkcfg configuration tool, ' +
'which is needed to create the configuration files.';
lisFppkgRtlNotFound = 'Fppkg reports that the RTL is not installed.';
lisFppkgCompilerNotFound = 'Could not find the compiler [%s] configured for Fppkg.';
lisFppkgCompilerNotExists = 'The compiler [%s] configured for Fppkg does not exist.';
lisFppkgCompilerNotExecutable = 'The compiler [%s] configured for Fppkg is not an executable.';
// file dialogs
lisOpenFile = 'Open File';

View File

@ -1446,7 +1446,7 @@ begin
// check fppkg configuration
if (not ShowSetupDialog)
and (CheckFppkgConfiguration()<>sddqCompatible)
and (CheckFppkgConfiguration(Note)<>sddqCompatible)
then begin
debugln('Warning: (lazarus) fppkg not properly configured.');
ShowSetupDialog:=true;

View File

@ -13,6 +13,7 @@ uses
fprepos,
LazLogger,
LazFileCache,
LazarusIDEStrConsts,
FileUtil,
LazFileUtils;
@ -30,6 +31,7 @@ type
FFPpkg: TpkgFPpkg;
{$ENDIF}
FIsProperlyConfigured: TFppkgPropConfigured;
FConfStatusMessage: string;
function HasFPCPackagesOnly(const PackageName: string): Boolean;
procedure InitializeFppkg;
public
@ -39,7 +41,7 @@ type
function HasPackage(const PackageName: string): Boolean;
procedure ListPackages(AList: TStringList);
function GetPackageUnitPath(const PackageName: string): string;
function IsProperlyConfigured: Boolean;
function IsProperlyConfigured(out Message: string): Boolean;
function GetCompilerFilename: string;
function GetCompilerConfigurationFileName: string;
// Temporary solution, because fpc 3.2.0 does not has support for package-variants
@ -109,11 +111,13 @@ begin
end;
function TFppkgHelper.HasPackage(const PackageName: string): Boolean;
var
Msg: string;
begin
{$IF NOT (FPC_FULLVERSION>30100)}
Result := HasFPCPackagesOnly(PackageName);
{$ELSE }
if IsProperlyConfigured() then
if IsProperlyConfigured(Msg) then
begin
Result :=
Assigned(FFPpkg.FindPackage(PackageName,pkgpkInstalled)) or
@ -261,36 +265,53 @@ begin
{$ENDIF FPC_FULLVERSION>30100}
end;
function TFppkgHelper.IsProperlyConfigured: Boolean;
function TFppkgHelper.IsProperlyConfigured(out Message: string): Boolean;
{$IF FPC_FULLVERSION>30100}
var
CompilerFilename: string;
{$ENDIF FPC_FULLVERSION>30100}
begin
Message := '';
{$IF FPC_FULLVERSION>30100}
if Assigned(FFPpkg) and (FIsProperlyConfigured=fpcUnknown) then
begin
FIsProperlyConfigured := fpcYes;
FConfStatusMessage := '';
if not HasPackage('rtl') then
FIsProperlyConfigured := fpcNo
begin
FIsProperlyConfigured := fpcNo;
FConfStatusMessage := lisFppkgRtlNotFound;
end
else
begin
CompilerFilename := FFPpkg.CompilerOptions.Compiler;
if Pos(PathDelim, CompilerFilename) > 0 then
begin
if not FileExistsCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
begin
FIsProperlyConfigured := fpcNo;
FConfStatusMessage := Format(lisFppkgCompilerNotExists, [CompilerFilename]);
end
else if not FileIsExecutableCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
begin
FIsProperlyConfigured := fpcNo;
FConfStatusMessage := Format(lisFppkgCompilerNotExecutable, [CompilerFilename]);
end;
end
else
begin
CompilerFilename := ExeSearch(CompilerFilename);
if CompilerFilename = '' then
FIsProperlyConfigured := fpcNo
begin
FIsProperlyConfigured := fpcNo;
FConfStatusMessage := Format(lisFppkgCompilerNotFound, [FFPpkg.CompilerOptions.Compiler]);
end
else if not FileIsExecutableCached(CompilerFilename) then
FIsProperlyConfigured := fpcNo
begin
FIsProperlyConfigured := fpcNo;
FConfStatusMessage := Format(lisFppkgCompilerNotExecutable, [CompilerFilename]);
end;
end
end;
end;
@ -298,6 +319,7 @@ begin
{$ELSE}
result := True
{$ENDIF FPC_FULLVERSION>30100}
Message := FConfStatusMessage;
end;
function TFppkgHelper.HasFPCPackagesOnly(const PackageName: string): Boolean;