mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:59:14 +02:00
codetools: implemented include directives with sub paths
git-svn-id: trunk@10511 -
This commit is contained in:
parent
48bf90bf1d
commit
f2dddc5c8f
@ -263,7 +263,7 @@ type
|
|||||||
function IncludeDirective: boolean;
|
function IncludeDirective: boolean;
|
||||||
function IncludeFile(const AFilename: string): boolean;
|
function IncludeFile(const AFilename: string): boolean;
|
||||||
function IncludePathDirective: boolean;
|
function IncludePathDirective: boolean;
|
||||||
function SearchIncludeFile(const AFilename: string; var NewCode: Pointer;
|
function SearchIncludeFile(AFilename: string; var NewCode: Pointer;
|
||||||
var MissingIncludeFile: TMissingIncludeFile): boolean;
|
var MissingIncludeFile: TMissingIncludeFile): boolean;
|
||||||
function ShortSwitchDirective: boolean;
|
function ShortSwitchDirective: boolean;
|
||||||
function ReadNextSwitchDirective: boolean;
|
function ReadNextSwitchDirective: boolean;
|
||||||
@ -2487,12 +2487,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLinkScanner.SearchIncludeFile(const AFilename: string;
|
function TLinkScanner.SearchIncludeFile(AFilename: string;
|
||||||
var NewCode: Pointer; var MissingIncludeFile: TMissingIncludeFile): boolean;
|
var NewCode: Pointer; var MissingIncludeFile: TMissingIncludeFile): boolean;
|
||||||
var PathStart, PathEnd: integer;
|
var PathStart, PathEnd: integer;
|
||||||
IncludePath, PathDivider, CurPath: string;
|
IncludePath, PathDivider, CurPath: string;
|
||||||
ExpFilename: string;
|
ExpFilename: string;
|
||||||
SecondaryFilename: String;
|
SecondaryFilename: String;
|
||||||
|
HasPathDelims: Boolean;
|
||||||
|
|
||||||
function SearchPath(const APath: string): boolean;
|
function SearchPath(const APath: string): boolean;
|
||||||
begin
|
begin
|
||||||
@ -2533,7 +2534,12 @@ begin
|
|||||||
if not Result then SetMissingIncludeFile;
|
if not Result then SetMissingIncludeFile;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// include filename is relative
|
// include filename is relative
|
||||||
|
// beware of 'dir/file.inc'
|
||||||
|
HasPathDelims:=(System.Pos('/',AFilename)>0) or (System.Pos('\',AFilename)>0);
|
||||||
|
if HasPathDelims then
|
||||||
|
DoDirSeparators(AFilename);
|
||||||
|
|
||||||
// first search include file in the directory of the main source
|
// first search include file in the directory of the main source
|
||||||
{$IFDEF VerboseIncludeSearch}
|
{$IFDEF VerboseIncludeSearch}
|
||||||
@ -2545,7 +2551,7 @@ begin
|
|||||||
NewCode:=LoadSourceCaseLoUp(ExpFilename);
|
NewCode:=LoadSourceCaseLoUp(ExpFilename);
|
||||||
Result:=(NewCode<>nil);
|
Result:=(NewCode<>nil);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
end else begin
|
end else if (not HasPathDelims) then begin
|
||||||
// main source has relative filename (= virtual)
|
// main source has relative filename (= virtual)
|
||||||
NewCode:=FOnLoadSource(Self,TrimFilename(AFilename),true);
|
NewCode:=FOnLoadSource(Self,TrimFilename(AFilename),true);
|
||||||
if NewCode=nil then begin
|
if NewCode=nil then begin
|
||||||
@ -2563,43 +2569,46 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// then search the include file in the include path
|
// then search the include file in the include path
|
||||||
if MissingIncludeFile=nil then
|
if not HasPathDelims then begin
|
||||||
IncludePath:=Values.Variables[ExternalMacroStart+'INCPATH']
|
if MissingIncludeFile=nil then
|
||||||
else
|
IncludePath:=Values.Variables[ExternalMacroStart+'INCPATH']
|
||||||
IncludePath:=MissingIncludeFile.IncludePath;
|
else
|
||||||
|
IncludePath:=MissingIncludeFile.IncludePath;
|
||||||
|
|
||||||
if Values.IsDefined('DELPHI') then
|
if Values.IsDefined('DELPHI') then
|
||||||
PathDivider:=':'
|
PathDivider:=':'
|
||||||
else
|
else
|
||||||
PathDivider:=':;';
|
PathDivider:=':;';
|
||||||
{$IFDEF VerboseIncludeSearch}
|
{$IFDEF VerboseIncludeSearch}
|
||||||
DebugLn('TLinkScanner.SearchIncludeFile IncPath="',IncludePath,'" PathDivider="',PathDivider,'"');
|
DebugLn('TLinkScanner.SearchIncludeFile IncPath="',IncludePath,'" PathDivider="',PathDivider,'"');
|
||||||
{$ENDIF}
|
|
||||||
PathStart:=1;
|
|
||||||
PathEnd:=PathStart;
|
|
||||||
while PathEnd<=length(IncludePath) do begin
|
|
||||||
if ((Pos(IncludePath[PathEnd],PathDivider))>0)
|
|
||||||
{$IFDEF MSWindows}
|
|
||||||
and (not ((PathEnd-PathStart=1) // ignore colon in drive
|
|
||||||
and (IncludePath[PathEnd]=':')
|
|
||||||
and (IsWordChar[IncludePath[PathEnd-1]])))
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
then begin
|
PathStart:=1;
|
||||||
if PathEnd>PathStart then begin
|
PathEnd:=PathStart;
|
||||||
CurPath:=TrimFilename(copy(IncludePath,PathStart,PathEnd-PathStart));
|
while PathEnd<=length(IncludePath) do begin
|
||||||
Result:=SearchPath(CurPath);
|
if ((Pos(IncludePath[PathEnd],PathDivider))>0)
|
||||||
if Result then exit;
|
{$IFDEF MSWindows}
|
||||||
end;
|
and (not ((PathEnd-PathStart=1) // ignore colon in drive
|
||||||
PathStart:=PathEnd+1;
|
and (IncludePath[PathEnd]=':')
|
||||||
PathEnd:=PathStart;
|
and (IsWordChar[IncludePath[PathEnd-1]])))
|
||||||
end else
|
{$ENDIF}
|
||||||
inc(PathEnd);
|
then begin
|
||||||
end;
|
if PathEnd>PathStart then begin
|
||||||
if PathEnd>PathStart then begin
|
CurPath:=TrimFilename(copy(IncludePath,PathStart,PathEnd-PathStart));
|
||||||
CurPath:=TrimFilename(copy(IncludePath,PathStart,PathEnd-PathStart));
|
Result:=SearchPath(CurPath);
|
||||||
Result:=SearchPath(CurPath);
|
if Result then exit;
|
||||||
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);
|
||||||
|
if Result then exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SetMissingIncludeFile;
|
SetMissingIncludeFile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user