mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 12:09:16 +02:00
implemented searching debugging files in include paths
git-svn-id: trunk@4178 -
This commit is contained in:
parent
00a3d4a023
commit
4f8cbb7ce8
@ -207,6 +207,7 @@ type
|
||||
function GetPascalCompilerForDirectory(const Directory: string): TPascalCompiler;
|
||||
function GetCompilerModeForDirectory(const Directory: string): TCompilerMode;
|
||||
function GetCompiledSrcExtForDirectory(const Directory: string): string;
|
||||
function FindUnitInUnitLinks(const Directory, UnitName: string): string;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@ -700,6 +701,20 @@ begin
|
||||
Result:='.ppw';
|
||||
end;
|
||||
|
||||
function TCodeToolManager.FindUnitInUnitLinks(const Directory, UnitName: string
|
||||
): string;
|
||||
var
|
||||
Evaluator: TExpressionEvaluator;
|
||||
UnitLinks: string;
|
||||
UnitLinkStart, UnitLinkEnd: integer;
|
||||
begin
|
||||
Result:='';
|
||||
Evaluator:=DefineTree.GetDefinesForDirectory(Directory,true);
|
||||
if Evaluator=nil then exit;
|
||||
UnitLinks:=Evaluator[ExternalMacroStart+'UnitLinks'];
|
||||
SearchUnitInUnitLinks(UnitLinks,UnitName,UnitLinkStart,UnitLinkEnd,Result);
|
||||
end;
|
||||
|
||||
function TCodeToolManager.InitCurCodeTool(Code: TCodeBuffer): boolean;
|
||||
var MainCode: TCodeBuffer;
|
||||
begin
|
||||
|
@ -392,7 +392,8 @@ const
|
||||
|
||||
function DefineActionNameToAction(const s: string): TDefineAction;
|
||||
function DefineTemplateFlagsToString(Flags: TDefineTemplateFlags): string;
|
||||
|
||||
function SearchUnitInUnitLinks(const UnitLinks, TheUnitName: string;
|
||||
var UnitLinkStart, UnitLinkEnd: integer; var Filename: string): boolean;
|
||||
|
||||
implementation
|
||||
|
||||
@ -404,7 +405,6 @@ type
|
||||
Filename: string;
|
||||
end;
|
||||
|
||||
|
||||
// some useful functions
|
||||
|
||||
function DefineActionNameToAction(const s: string): TDefineAction;
|
||||
@ -442,6 +442,69 @@ begin
|
||||
Result:=CompareFilenames(DirDef1.Path,DirDef2.Path);
|
||||
end;
|
||||
|
||||
function SearchUnitInUnitLinks(const UnitLinks, TheUnitName: string;
|
||||
var UnitLinkStart, UnitLinkEnd: integer; var Filename: string): boolean;
|
||||
var
|
||||
UnitLinkLen: integer;
|
||||
begin
|
||||
Result:=false;
|
||||
Filename:='';
|
||||
if TheUnitName='' then exit;
|
||||
{$IFDEF ShowTriedFiles}
|
||||
writeln('TFindDeclarationTool.FindUnitSource.SearchUnitInUnitLinks length(UnitLinks)=',length(UnitLinks));
|
||||
{$ENDIF}
|
||||
if UnitLinkStart<1 then
|
||||
UnitLinkStart:=1;
|
||||
while UnitLinkStart<=length(UnitLinks) do begin
|
||||
while (UnitLinkStart<=length(UnitLinks))
|
||||
and (UnitLinks[UnitLinkStart] in [#10,#13]) do
|
||||
inc(UnitLinkStart);
|
||||
UnitLinkEnd:=UnitLinkStart;
|
||||
while (UnitLinkEnd<=length(UnitLinks)) and (UnitLinks[UnitLinkEnd]<>' ')
|
||||
do
|
||||
inc(UnitLinkEnd);
|
||||
UnitLinkLen:=UnitLinkEnd-UnitLinkStart;
|
||||
if UnitLinkLen>0 then begin
|
||||
{$IFDEF ShowTriedFiles}
|
||||
writeln(' unit "',copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart),'" ',CompareSubStrings(TheUnitName,UnitLinks,1,
|
||||
UnitLinkStart,UnitLinkLen,false));
|
||||
{$ENDIF}
|
||||
if (UnitLinkLen=length(TheUnitName))
|
||||
and (AnsiStrLIComp(PChar(TheUnitName),@UnitLinks[UnitLinkStart],
|
||||
UnitLinkLen)=0)
|
||||
then begin
|
||||
// unit found -> parse filename
|
||||
UnitLinkStart:=UnitLinkEnd+1;
|
||||
UnitLinkEnd:=UnitLinkStart;
|
||||
while (UnitLinkEnd<=length(UnitLinks))
|
||||
and (not (UnitLinks[UnitLinkEnd] in [#10,#13])) do
|
||||
inc(UnitLinkEnd);
|
||||
if UnitLinkEnd>UnitLinkStart then begin
|
||||
Filename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart);
|
||||
if FileExists(Filename) then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
// try also different extensions
|
||||
if CompareFileExt(Filename,'.pp',false)=0 then
|
||||
Filename:=ChangeFileExt(Filename,'.pas')
|
||||
else
|
||||
Filename:=ChangeFileExt(Filename,'.pp');
|
||||
if FileExists(Filename) then begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
UnitLinkStart:=UnitLinkEnd+1;
|
||||
while (UnitLinkStart<=length(UnitLinks))
|
||||
and (not (UnitLinks[UnitLinkStart] in [#10,#13])) do
|
||||
inc(UnitLinkStart);
|
||||
end;
|
||||
end else
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TDefineTemplate }
|
||||
|
||||
|
@ -108,6 +108,8 @@ type
|
||||
Flags: TPkgCompileFlags): TModalResult; virtual; abstract;
|
||||
function OnRenameFile(const OldFilename,
|
||||
NewFilename: string): TModalResult; virtual; abstract;
|
||||
function FindIncludeFileInProjectDependencies(Project1: TProject;
|
||||
const Filename: string): string; virtual; abstract;
|
||||
|
||||
function OnProjectInspectorOpen(Sender: TObject): boolean; virtual; abstract;
|
||||
function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags
|
||||
|
@ -884,7 +884,9 @@ begin
|
||||
// add unit paths
|
||||
UsageOptions.UnitPath:=
|
||||
'$(LazarusDir)/lcl/units;$(LazarusDir)/lcl/units/$(LCLWidgetType)';
|
||||
|
||||
// add include path
|
||||
CompilerOptions.IncludeFiles:='$(LazarusDir)/lcl/include';
|
||||
|
||||
// use the lcl/units/allunits.o file as indicator,
|
||||
// if LCL has been recompiled
|
||||
OutputStateFile:='$(LazarusDir)/lcl/units/allunits.o';
|
||||
|
@ -154,6 +154,8 @@ type
|
||||
function GetPublishPackageDir(APackage: TLazPackage): string;
|
||||
function OnRenameFile(const OldFilename,
|
||||
NewFilename: string): TModalResult; override;
|
||||
function FindIncludeFileInProjectDependencies(Project1: TProject;
|
||||
const Filename: string): string; override;
|
||||
|
||||
// package graph
|
||||
function AddPackageToGraph(APackage: TLazPackage; Replace: boolean): TModalResult;
|
||||
@ -2097,6 +2099,40 @@ begin
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TPkgManager.FindIncludeFileInProjectDependencies(Project1: TProject;
|
||||
const Filename: string): string;
|
||||
|
||||
Search filename in the include paths of all required packages
|
||||
------------------------------------------------------------------------------}
|
||||
function TPkgManager.FindIncludeFileInProjectDependencies(Project1: TProject;
|
||||
const Filename: string): string;
|
||||
var
|
||||
APackage: TLazPackage;
|
||||
IncPath: String;
|
||||
PkgList: Tlist;
|
||||
i: Integer;
|
||||
begin
|
||||
Result:='';
|
||||
if FilenameIsAbsolute(Filename) then begin
|
||||
Result:=Filename;
|
||||
exit;
|
||||
end;
|
||||
PkgList:=nil;
|
||||
PackageGraph.GetAllRequiredPackages(Project1.FirstRequiredDependency,PkgList);
|
||||
if PkgList=nil then exit;
|
||||
try
|
||||
for i:=0 to PkgList.Count-1 do begin
|
||||
APackage:=TLazPackage(PkgList[i]);
|
||||
IncPath:=APackage.CompilerOptions.IncludeFiles;
|
||||
Result:=SearchFileInPath(Filename,APackage.Directory,IncPath,';',[]);
|
||||
if Result<>'' then exit;
|
||||
end;
|
||||
finally
|
||||
PkgList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPkgManager.DoAddActiveUnitToAPackage: TModalResult;
|
||||
var
|
||||
ActiveSourceEditor: TSourceEditor;
|
||||
|
Loading…
Reference in New Issue
Block a user