From 73d34d3088828d57cba079afe6ead295d5f3f9e8 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 9 Sep 2011 19:00:32 +0000 Subject: [PATCH] codetools: find sources in fpc unit search paths git-svn-id: trunk@32240 - --- components/codetools/codetoolmanager.pas | 2 +- components/codetools/definetemplates.pas | 15 +++++++++++++-- components/codetools/directorycacher.pas | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index ef0c72fe9a..f3c0ebb034 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -5630,7 +5630,7 @@ begin debugln(['TCodeToolManager.DirectoryCachePoolGetUnitFromSet outdated UnitSet="',dbgstr(UnitSet),'"']); exit; end; - Result:=UnitSetCache.GetUnitSrcFile(AnUnitName); + Result:=UnitSetCache.GetUnitSrcFile(AnUnitName,false); end; function TCodeToolManager.DirectoryCachePoolGetCompiledUnitFromSet( diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index f8f0e505e6..2b8c1afae7 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -8810,7 +8810,7 @@ begin if ConfigCache.HasPPUs then begin // but there are other ppu files {$IFDEF ShowTriedUnits} - debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" unit has no ppu file in FPC path, but there are other']); + debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" unit has no ppu file in FPC path, but there are other ppu']); {$ENDIF} exit; end else begin @@ -8828,8 +8828,19 @@ begin end; if Tree<>nil then begin Result:=Tree[AnUnitName]; - if Result<>'' then + if (Result<>'') and (not FilenameIsAbsolute(Result)) then Result:=FPCSourceDirectory+Result; + if (Result='') then begin + // maybe the source is in the fpc search path + ConfigCache:=GetConfigCache(false); + if ConfigCache<>nil then begin + Result:=ConfigCache.Units[AnUnitName]; + if (CompareFileExt(Result,'ppu',false)=0) then begin + Result:=''; + exit; + end; + end; + end; {$IFDEF ShowTriedUnits} debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" Result=',Result]); {$ENDIF} diff --git a/components/codetools/directorycacher.pas b/components/codetools/directorycacher.pas index 3f475ac0c0..330379a32e 100644 --- a/components/codetools/directorycacher.pas +++ b/components/codetools/directorycacher.pas @@ -1223,7 +1223,7 @@ begin Result:=FindUnitSourceInCleanSearchPath(AUnitName,SrcPath,AnyCase); end; if Result='' then begin - // search in unit links + // search in unit set {$IFDEF ShowTriedUnits} DebugLn(['TCTDirectoryCache.FindUnitSourceInCompletePath unit ',AUnitName,' not found in SrcPath="',SrcPath,'" Directory="',Directory,'" searchin in unitset ...']); {$ENDIF}