mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 06:01:51 +02:00
IDE: fpc msg parser: incompatible ppu: list all packages
git-svn-id: trunk@45499 -
This commit is contained in:
parent
c707ad2c7c
commit
2ae9b91aa0
@ -1650,30 +1650,71 @@ procedure TIDEFPCParser.ImproveMsgUnitNotFound(aPhase: TExtToolParserSyncPhase;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure FindPPUInInstalledPkgs(MissingUnitname: string;
|
||||
var PPUFilename, PkgName: string);
|
||||
procedure FindPPUFiles(MissingUnitname: string; PkgList: TFPList;
|
||||
PPUFiles: TStringList // Strings:PPUFilename, Objects:TIDEPackage
|
||||
);
|
||||
var
|
||||
i: Integer;
|
||||
Pkg: TIDEPackage;
|
||||
DirCache: TCTDirectoryCache;
|
||||
PPUFilename: String;
|
||||
UnitOutDir: String;
|
||||
begin
|
||||
// search ppu in installed packages
|
||||
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
|
||||
Pkg:=PackageEditingInterface.GetPackages(i);
|
||||
if Pkg.AutoInstall=pitNope then continue;
|
||||
if PkgList=nil then exit;
|
||||
for i:=0 to PkgList.Count-1 do begin
|
||||
Pkg:=TIDEPackage(PkgList[i]);
|
||||
UnitOutDir:=Pkg.LazCompilerOptions.GetUnitOutputDirectory(false);
|
||||
//debugln(['TQuickFixUnitNotFoundPosition.Execute ',Pkg.Name,' UnitOutDir=',UnitOutDir]);
|
||||
if FilenameIsAbsolute(UnitOutDir) then begin
|
||||
DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(UnitOutDir,true,false);
|
||||
PPUFilename:=DirCache.FindFile(MissingUnitname+'.ppu',ctsfcLoUpCase);
|
||||
//debugln(['TQuickFixUnitNotFoundPosition.Execute ShortPPU=',PPUFilename]);
|
||||
if PPUFilename<>'' then begin
|
||||
PkgName:=Pkg.Name;
|
||||
PPUFilename:=AppendPathDelim(DirCache.Directory)+PPUFilename;
|
||||
break;
|
||||
end;
|
||||
if not FilenameIsAbsolute(UnitOutDir) then continue;
|
||||
DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(UnitOutDir,true,false);
|
||||
PPUFilename:=DirCache.FindFile(MissingUnitname+'.ppu',ctsfcLoUpCase);
|
||||
//debugln(['TQuickFixUnitNotFoundPosition.Execute ShortPPU=',PPUFilename]);
|
||||
if PPUFilename='' then continue;
|
||||
PPUFilename:=AppendPathDelim(DirCache.Directory)+PPUFilename;
|
||||
PPUFiles.AddObject(PPUFilename,Pkg);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure FindPPUInInstalledPkgs(MissingUnitname: string;
|
||||
PPUFiles: TStringList // Strings:PPUFilename, Objects:TIDEPackage
|
||||
);
|
||||
var
|
||||
i: Integer;
|
||||
Pkg: TIDEPackage;
|
||||
PkgList: TFPList;
|
||||
begin
|
||||
// search ppu in installed packages
|
||||
PkgList:=TFPList.Create;
|
||||
try
|
||||
for i:=0 to PackageEditingInterface.GetPackageCount-1 do begin
|
||||
Pkg:=PackageEditingInterface.GetPackages(i);
|
||||
if Pkg.AutoInstall=pitNope then continue;
|
||||
PkgList.Add(Pkg);
|
||||
end;
|
||||
FindPPUFiles(MissingUnitname,PkgList,PPUFiles);
|
||||
finally
|
||||
PkgList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure FindPPUInModuleAndDeps(MissingUnitname: string; Module: TObject;
|
||||
PPUFiles: TStringList // Strings:PPUFilename, Objects:TIDEPackage
|
||||
);
|
||||
var
|
||||
PkgList: TFPList;
|
||||
begin
|
||||
PkgList:=nil;
|
||||
try
|
||||
PackageEditingInterface.GetRequiredPackages(Module,PkgList);
|
||||
if (Module is TIDEPackage) then begin
|
||||
if PkgList=nil then
|
||||
PkgList:=TFPList.Create;
|
||||
if PkgList.IndexOf(Module)<0 then
|
||||
PkgList.Add(Module);
|
||||
end;
|
||||
FindPPUFiles(MissingUnitname,PkgList,PPUFiles);
|
||||
finally
|
||||
PkgList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1718,6 +1759,8 @@ var
|
||||
PkgName: String;
|
||||
OnlyInstalled: Boolean;
|
||||
s: String;
|
||||
PPUFiles: TStringList; // Strings:PPUFilename, Objects:TIDEPackage
|
||||
i: Integer;
|
||||
begin
|
||||
if MsgLine.Urgency<mluError then exit;
|
||||
if not IsMsgID(MsgLine,FPCMsgIDCantFindUnitUsedBy,fMsgItemCantFindUnitUsedBy)
|
||||
@ -1791,6 +1834,7 @@ begin
|
||||
// fix line and column
|
||||
Owners:=nil;
|
||||
UsedByOwner:=nil;
|
||||
PPUFiles:=TStringList.Create;
|
||||
try
|
||||
if CodeBuf<>nil then begin
|
||||
FixSourcePos(CodeBuf,MissingUnitname);
|
||||
@ -1811,29 +1855,27 @@ begin
|
||||
{$ENDIF}
|
||||
PkgName:='';
|
||||
OnlyInstalled:=IsFileInIDESrcDir(CodeBuf.Filename);
|
||||
if OnlyInstalled and (PPUFilename='') then begin
|
||||
FindPPUInInstalledPkgs(MissingUnitname,PPUFilename,PkgName);
|
||||
end;
|
||||
|
||||
if OnlyInstalled then begin
|
||||
FindPPUInInstalledPkgs(MissingUnitname,PPUFiles);
|
||||
end else if UsedByOwner<>nil then
|
||||
FindPPUInModuleAndDeps(MissingUnitName,UsedByOwner,PPUFiles);
|
||||
FindPackage(MissingUnitname,PkgName,OnlyInstalled);
|
||||
if PPUFilename<>'' then begin
|
||||
// there is a ppu file in the unit path
|
||||
if PPUFilename<>'' then begin
|
||||
// there is a ppu file, but the compiler didn't like it
|
||||
// => change message
|
||||
s:=Format(lisCannotFind, [MissingUnitname]);
|
||||
if UsedByUnit<>'' then
|
||||
s+=Format(lisUsedBy, [UsedByUnit]);
|
||||
s+=Format(lisIncompatiblePpu, [PPUFilename]);
|
||||
if PkgName<>'' then
|
||||
s+=Format(lisPackage3, [PkgName]);
|
||||
end else if PkgName<>'' then begin
|
||||
// ppu is missing, but the package is known
|
||||
// => change message
|
||||
s:=Format(lisCanTFindPpuOfUnit, [MissingUnitname]);
|
||||
if UsedByUnit<>'' then
|
||||
s+=Format(lisUsedBy, [UsedByUnit]);
|
||||
s+=Format(lisMaybePackageNeedsACleanRebuild, [PkgName]);
|
||||
if PPUFiles.Count>0 then begin
|
||||
// there is a ppu file, but the compiler didn't like it
|
||||
// => change message
|
||||
s:=Format(lisCannotFind, [MissingUnitname]);
|
||||
if UsedByUnit<>'' then
|
||||
s+=Format(lisUsedBy, [UsedByUnit]);
|
||||
s+=Format(lisIncompatiblePpu, [PPUFilename]);
|
||||
if PPUFiles.Count=1 then
|
||||
s+=Format(lisPackage3, [TIDEPackage(PPUFiles.Objects[0]).Name])
|
||||
else begin
|
||||
s+=', multiple packages: ';
|
||||
for i:=0 to PPUFiles.Count-1 do begin
|
||||
if i>0 then
|
||||
s+=', ';
|
||||
s+=TIDEPackage(PPUFiles.Objects[i]).Name;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// there is no ppu file in the unit path
|
||||
@ -1862,6 +1904,7 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
finally
|
||||
PPUFiles.Free;
|
||||
Owners.Free;
|
||||
end;
|
||||
end;
|
||||
|
@ -5715,7 +5715,6 @@ resourcestring
|
||||
lisCannotFindUnit = 'Cannot find unit %s';
|
||||
lisIncompatiblePpu = ', incompatible ppu=%s';
|
||||
lisPackage3 = ', package %s';
|
||||
lisCanTFindPpuOfUnit = 'Can''t find ppu of unit %s';
|
||||
lisQuickFixError = 'QuickFix error';
|
||||
lisPositionOutsideOfSource = '%s (position outside of source';
|
||||
lisHideWithProjectOptionVm = 'Hide with project option (-vm%s)';
|
||||
|
@ -4427,6 +4427,7 @@ begin
|
||||
// clean up if wanted
|
||||
if CleanUp then begin
|
||||
if DeleteAllFilesInOutputDir then begin
|
||||
// delete all files in output directory
|
||||
DirCache:=CodeToolBoss.DirectoryCachePool.GetCache(OutputDir,true,false);
|
||||
if DirCache<>nil then begin
|
||||
CleanFiles:=TStringList.Create;
|
||||
@ -4434,6 +4435,8 @@ begin
|
||||
DirCache.GetFiles(CleanFiles,false);
|
||||
for i:=0 to CleanFiles.Count-1 do begin
|
||||
OutputFileName:=AppendPathDelim(OutputDir)+CleanFiles[i];
|
||||
if ConsoleVerbosity>1 then
|
||||
debugln(['clean up '+APackage.IDAsString+': '+OutputFileName]);
|
||||
Result:=DeleteFileInteractive(OutputFileName,[mbIgnore,mbAbort]);
|
||||
if Result in [mrCancel,mrAbort] then exit;
|
||||
end;
|
||||
@ -4441,16 +4444,19 @@ begin
|
||||
CleanFiles.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
for i:=0 to APackage.FileCount-1 do begin
|
||||
CurFile:=APackage.Files[i];
|
||||
if not (CurFile.FileType in PkgFileUnitTypes) then continue;
|
||||
if not DeleteAllFilesInOutputDir then begin
|
||||
// delete .ppu/.o file of each registered unit
|
||||
end else begin
|
||||
// delete .ppu/.o file of each registered unit
|
||||
for i:=0 to APackage.FileCount-1 do begin
|
||||
CurFile:=APackage.Files[i];
|
||||
if not (CurFile.FileType in PkgFileUnitTypes) then continue;
|
||||
OutputFileName:=AppendPathDelim(OutputDir)+CurFile.Unit_Name+'.ppu';
|
||||
if ConsoleVerbosity>1 then
|
||||
debugln(['clean up '+APackage.IDAsString+': '+OutputFileName]);
|
||||
Result:=DeleteFileInteractive(OutputFileName,[mbIgnore,mbAbort]);
|
||||
if Result in [mrCancel,mrAbort] then exit;
|
||||
OutputFileName:=ChangeFileExt(OutputFileName,'.o');
|
||||
if ConsoleVerbosity>1 then
|
||||
debugln(['clean up '+APackage.IDAsString+': '+OutputFileName]);
|
||||
Result:=DeleteFileInteractive(OutputFileName,[mbIgnore,mbAbort]);
|
||||
if Result in [mrCancel,mrAbort] then exit;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user