mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 08:59:13 +02:00
codetools: TFPCUnitSetCache.GetUnitSrcFile: always return source file in search path first
git-svn-id: trunk@41410 -
This commit is contained in:
parent
5df0a63a69
commit
3c5ec2b499
@ -8422,21 +8422,31 @@ end;
|
|||||||
|
|
||||||
function TFPCUnitSetCache.GetUnitSrcFile(const AnUnitName: string;
|
function TFPCUnitSetCache.GetUnitSrcFile(const AnUnitName: string;
|
||||||
MustHavePPU: boolean; SkipPPUCheckIfTargetIsSourceOnly: boolean): string;
|
MustHavePPU: boolean; SkipPPUCheckIfTargetIsSourceOnly: boolean): string;
|
||||||
|
{ Searches the unit in the FPC search path and sources.
|
||||||
|
MustHavePPU: only search the sources if there is a ppu in the search path
|
||||||
|
}
|
||||||
var
|
var
|
||||||
Tree: TStringToStringTree;
|
Tree: TStringToStringTree;
|
||||||
ConfigCache: TFPCTargetConfigCache;
|
ConfigCache: TFPCTargetConfigCache;
|
||||||
|
UnitInFPCPath: String;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
{$IFDEF ShowTriedUnits}
|
{$IFDEF ShowTriedUnits}
|
||||||
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" MustHavePPU=',MustHavePPU,' SkipPPUCheckIfNoneExists=',SkipPPUCheckIfNoneExists]);
|
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" MustHavePPU=',MustHavePPU,' SkipPPUCheckIfNoneExists=',SkipPPUCheckIfNoneExists]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Tree:=GetUnitToSourceTree(false);
|
Tree:=GetUnitToSourceTree(false);
|
||||||
if MustHavePPU then begin
|
|
||||||
ConfigCache:=GetConfigCache(false);
|
ConfigCache:=GetConfigCache(false);
|
||||||
if (ConfigCache.Units<>nil)
|
if (ConfigCache.Units<>nil) then begin
|
||||||
and (CompareFileExt(ConfigCache.Units[AnUnitName],'ppu',false)<>0)
|
UnitInFPCPath:=ConfigCache.Units[AnUnitName];
|
||||||
then begin
|
if (CompareFileExt(UnitInFPCPath,'ppu',false)=0) then begin
|
||||||
|
// there is a ppu
|
||||||
|
end else if UnitInFPCPath<>'' then begin
|
||||||
|
// there is a pp or pas in the FPC search path
|
||||||
|
Result:=UnitInFPCPath;
|
||||||
|
exit;
|
||||||
|
end else begin
|
||||||
// unit has no ppu in the FPC ppu search path
|
// unit has no ppu in the FPC ppu search path
|
||||||
|
if MustHavePPU then begin
|
||||||
if ConfigCache.HasPPUs then begin
|
if ConfigCache.HasPPUs then begin
|
||||||
// but there are other ppu files
|
// but there are other ppu files
|
||||||
{$IFDEF ShowTriedUnits}
|
{$IFDEF ShowTriedUnits}
|
||||||
@ -8449,28 +8459,18 @@ begin
|
|||||||
{$IFDEF ShowTriedUnits}
|
{$IFDEF ShowTriedUnits}
|
||||||
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" there are no ppu files for this target']);
|
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" there are no ppu files for this target']);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not SkipPPUCheckIfTargetIsSourceOnly then
|
if (not SkipPPUCheckIfTargetIsSourceOnly) then
|
||||||
exit;
|
exit;
|
||||||
// => search directly in the sources
|
// => search directly in the sources
|
||||||
// this allows cross editing even if FPC is not installed for this target
|
// this allows cross editing even if FPC is not installed for this target
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
if Tree<>nil then begin
|
if Tree<>nil then begin
|
||||||
Result:=Tree[AnUnitName];
|
Result:=Tree[AnUnitName];
|
||||||
if (Result<>'') and (not FilenameIsAbsolute(Result)) then
|
if (Result<>'') and (not FilenameIsAbsolute(Result)) then
|
||||||
Result:=FPCSourceDirectory+Result;
|
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}
|
{$IFDEF ShowTriedUnits}
|
||||||
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" Result=',Result]);
|
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" Result=',Result]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
Loading…
Reference in New Issue
Block a user