mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 01:59:16 +02:00
codetools: TLinkScanner: use directorycacher
This commit is contained in:
parent
ec14525a1a
commit
f75c120bdb
@ -4116,7 +4116,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if MissingIncludeFile=nil then
|
if MissingIncludeFile=nil then
|
||||||
MissingIncludeFile:=TMissingIncludeFile.Create(AFilename,'');
|
MissingIncludeFile:=TMissingIncludeFile.Create(AFilename,'');
|
||||||
MissingIncludeFile.IncludePath:=IncludePath;
|
MissingIncludeFile.IncludePath:=Values.Variables[ExternalMacroStart+'INCPATH'];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SearchPath(const APath, RelFilename: string): boolean;
|
function SearchPath(const APath, RelFilename: string): boolean;
|
||||||
@ -4135,9 +4135,11 @@ var
|
|||||||
|
|
||||||
function Search(const RelFilename: string): boolean;
|
function Search(const RelFilename: string): boolean;
|
||||||
var
|
var
|
||||||
IsVirtualUnit: Boolean;
|
IsVirtualUnit, AnyCase: Boolean;
|
||||||
|
Dir, IncFile: String;
|
||||||
begin
|
begin
|
||||||
IsVirtualUnit:=not FilenameIsAbsolute(FMainSourceFilename);
|
Dir:=ExtractFilePath(FMainSourceFilename);
|
||||||
|
IsVirtualUnit:=not FilenameIsAbsolute(Dir);
|
||||||
if IsVirtualUnit then begin
|
if IsVirtualUnit then begin
|
||||||
// main source is virtual -> allow virtual include file
|
// main source is virtual -> allow virtual include file
|
||||||
NewCode:=LoadIncludeFile(RelFilename,true);
|
NewCode:=LoadIncludeFile(RelFilename,true);
|
||||||
@ -4146,7 +4148,7 @@ var
|
|||||||
end else begin
|
end else begin
|
||||||
// main source has absolute filename
|
// main source has absolute filename
|
||||||
// -> search in directory of unit
|
// -> search in directory of unit
|
||||||
ExpFilename:=ExtractFilePath(FMainSourceFilename)+RelFilename;
|
ExpFilename:=Dir+RelFilename;
|
||||||
NewCode:=LoadIncludeFile(ExpFilename);
|
NewCode:=LoadIncludeFile(ExpFilename);
|
||||||
Result:=(NewCode<>nil);
|
Result:=(NewCode<>nil);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
@ -4154,32 +4156,14 @@ var
|
|||||||
|
|
||||||
if not HasPathDelims then begin
|
if not HasPathDelims then begin
|
||||||
// file without path -> search in inc paths
|
// file without path -> search in inc paths
|
||||||
if MissingIncludeFile=nil then
|
|
||||||
IncludePath:=Values.Variables[ExternalMacroStart+'INCPATH']
|
|
||||||
else
|
|
||||||
IncludePath:=MissingIncludeFile.IncludePath;
|
|
||||||
|
|
||||||
{$IFDEF VerboseIncludeSearch}
|
AnyCase:=Values.IsDefined('PAS2JS');
|
||||||
DebugLn('TLinkScanner.SearchIncludeFile IncPath="',IncludePath,'"');
|
|
||||||
{$ENDIF}
|
IncFile:=DirectoryCachePool.FindIncludeFileInDirectory(Dir,AFilename,AnyCase);
|
||||||
PathStart:=1;
|
if IncFile<>'' then begin
|
||||||
PathEnd:=PathStart;
|
NewCode:=FOnLoadSource(Self,ExpFilename,true);
|
||||||
while PathEnd<=length(IncludePath) do begin
|
Result:=(NewCode<>nil);
|
||||||
if IncludePath[PathEnd]=';' then begin
|
exit;
|
||||||
if PathEnd>PathStart then begin
|
|
||||||
CurPath:=TrimFilename(copy(IncludePath,PathStart,PathEnd-PathStart));
|
|
||||||
Result:=SearchPath(CurPath,RelFilename);
|
|
||||||
if Result then exit;
|
|
||||||
end;
|
|
||||||
PathStart:=PathEnd+1;
|
|
||||||
PathEnd:=PathStart;
|
|
||||||
end else
|
|
||||||
inc(PathEnd);
|
|
||||||
end;
|
|
||||||
if PathEnd>PathStart then begin
|
|
||||||
CurPath:=TrimFilename(copy(IncludePath,PathStart,PathEnd-PathStart));
|
|
||||||
Result:=SearchPath(CurPath,RelFilename);
|
|
||||||
if Result then exit;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// then search the include file in directories defines in fpc.cfg (by -Fi option)
|
// then search the include file in directories defines in fpc.cfg (by -Fi option)
|
||||||
@ -4187,7 +4171,7 @@ var
|
|||||||
begin
|
begin
|
||||||
NewCode:=FOnLoadSource(Self,ExpFilename,true);
|
NewCode:=FOnLoadSource(Self,ExpFilename,true);
|
||||||
Result:=(NewCode<>nil);
|
Result:=(NewCode<>nil);
|
||||||
if Result then exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user