From 2ae9b91aa013350b49de8375c318e24c1ae70f6f Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 13 Jun 2014 19:16:01 +0000 Subject: [PATCH] IDE: fpc msg parser: incompatible ppu: list all packages git-svn-id: trunk@45499 - --- ide/etfpcmsgparser.pas | 117 ++++++++++++++++++++++++------------ ide/lazarusidestrconsts.pas | 1 - packager/packagesystem.pas | 18 ++++-- 3 files changed, 92 insertions(+), 44 deletions(-) diff --git a/ide/etfpcmsgparser.pas b/ide/etfpcmsgparser.pas index 665dff7fcd..8d6bf4d19e 100644 --- a/ide/etfpcmsgparser.pas +++ b/ide/etfpcmsgparser.pas @@ -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.Urgencynil 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; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 3444d64ab6..e13836bbe3 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -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)'; diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index e209f94ec4..4ae37e5286 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -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;