mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 05:16:48 +02:00
IDE: project definitions are now automatically added to all directories in the unit search path (same for packages)
git-svn-id: trunk@10221 -
This commit is contained in:
parent
13689073c2
commit
01c3d62fc8
@ -119,6 +119,7 @@ function FindFPCTool(const Executable, CompilerFilename: string): string;
|
|||||||
// search paths
|
// search paths
|
||||||
function TrimSearchPath(const SearchPath, BaseDirectory: string): string;
|
function TrimSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||||
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
||||||
|
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
|
||||||
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
||||||
function RemoveNonExistingPaths(const SearchPath, BaseDirectory: string): string;
|
function RemoveNonExistingPaths(const SearchPath, BaseDirectory: string): string;
|
||||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||||
@ -134,6 +135,8 @@ function GetNextUsedDirectoryInSearchPath(const SearchPath,
|
|||||||
FilterDir: string; var NextStartPos: integer): string;
|
FilterDir: string; var NextStartPos: integer): string;
|
||||||
function SearchDirectoryInSearchPath(const SearchPath, Directory: string;
|
function SearchDirectoryInSearchPath(const SearchPath, Directory: string;
|
||||||
DirStartPos: integer = 1): integer;
|
DirStartPos: integer = 1): integer;
|
||||||
|
function SearchDirectoryInSearchPath(SearchPath: TStrings;
|
||||||
|
const Directory: string; DirStartPos: integer = 0): integer;
|
||||||
|
|
||||||
// XMLConfig
|
// XMLConfig
|
||||||
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
|
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
|
||||||
@ -405,6 +408,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
|
||||||
|
var
|
||||||
|
l: Integer;
|
||||||
|
EndPos: Integer;
|
||||||
|
StartPos: Integer;
|
||||||
|
begin
|
||||||
|
l:=length(AddSearchPath);
|
||||||
|
EndPos:=1;
|
||||||
|
while EndPos<=l do begin
|
||||||
|
StartPos:=EndPos;
|
||||||
|
while (AddSearchPath[StartPos]=';') do begin
|
||||||
|
inc(StartPos);
|
||||||
|
if StartPos>l then exit;
|
||||||
|
end;
|
||||||
|
EndPos:=StartPos;
|
||||||
|
while (EndPos<=l) and (AddSearchPath[EndPos]<>';') do inc(EndPos);
|
||||||
|
if SearchDirectoryInSearchPath(SearchPath,AddSearchPath,StartPos)<1 then
|
||||||
|
begin
|
||||||
|
// new path found -> add
|
||||||
|
SearchPath.Add(copy(AddSearchPath,StartPos,EndPos-StartPos));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
||||||
var
|
var
|
||||||
OldPathLen: Integer;
|
OldPathLen: Integer;
|
||||||
@ -641,6 +668,46 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SearchDirectoryInSearchPath(SearchPath: TStrings;
|
||||||
|
const Directory: string; DirStartPos: integer): integer;
|
||||||
|
var
|
||||||
|
DirLen: Integer;
|
||||||
|
DirEndPos: Integer;
|
||||||
|
CurDirLen: Integer;
|
||||||
|
CurPath: string;
|
||||||
|
begin
|
||||||
|
Result:=-1;
|
||||||
|
DirLen:=length(Directory);
|
||||||
|
if (SearchPath.Count=0)
|
||||||
|
or (Directory='') or (DirStartPos>DirLen) or (Directory[DirStartPos]=';') then
|
||||||
|
exit;
|
||||||
|
DirEndPos:=DirStartPos;
|
||||||
|
while (DirEndPos<=DirLen) and (Directory[DirEndPos]<>';') do inc(DirEndPos);
|
||||||
|
// ignore PathDelim at end
|
||||||
|
if (DirEndPos>DirStartPos) and (Directory[DirEndPos-1]=PathDelim) then begin
|
||||||
|
while (DirEndPos>DirStartPos) and (Directory[DirEndPos-1]=PathDelim) do
|
||||||
|
dec(DirEndPos);
|
||||||
|
// check if it is the root path '/'
|
||||||
|
if DirEndPos=DirStartPos then DirEndPos:=DirStartPos+1;
|
||||||
|
end;
|
||||||
|
CurDirLen:=DirEndPos-DirStartPos;
|
||||||
|
|
||||||
|
// search in all search paths
|
||||||
|
Result:=SearchPath.Count-1;
|
||||||
|
while Result>=0 do begin
|
||||||
|
CurPath:=SearchPath[Result];
|
||||||
|
if (CurPath<>'') and
|
||||||
|
(FileUtil.CompareFilenames(@CurPath[1],CurDirLen,
|
||||||
|
@Directory[DirStartPos],CurDirLen,
|
||||||
|
false)=0)
|
||||||
|
then begin
|
||||||
|
// directory found
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
dec(Result);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||||
UsePointDirectory: boolean): string;
|
UsePointDirectory: boolean): string;
|
||||||
begin
|
begin
|
||||||
|
@ -379,6 +379,7 @@ type
|
|||||||
fLastSourceDirsIDAsString: string;
|
fLastSourceDirsIDAsString: string;
|
||||||
fLastSourceDirStamp: integer;
|
fLastSourceDirStamp: integer;
|
||||||
FLastCustomOptions: string;
|
FLastCustomOptions: string;
|
||||||
|
fLastUnitPath: string;
|
||||||
procedure SetActive(const AValue: boolean);
|
procedure SetActive(const AValue: boolean);
|
||||||
procedure UpdateMain;
|
procedure UpdateMain;
|
||||||
procedure UpdateSrcDirIfDef;
|
procedure UpdateSrcDirIfDef;
|
||||||
@ -4130,23 +4131,32 @@ var
|
|||||||
SrcDirDefTempl: TDefineTemplate;
|
SrcDirDefTempl: TDefineTemplate;
|
||||||
IDHasChanged: Boolean;
|
IDHasChanged: Boolean;
|
||||||
SrcDirMarkDefTempl: TDefineTemplate;
|
SrcDirMarkDefTempl: TDefineTemplate;
|
||||||
|
CurUnitPath: String;
|
||||||
begin
|
begin
|
||||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories ',Project.IDAsString,' Active=',dbgs(Active),' TimeStamp=',dbgs(fLastSourceDirStamp),' Project.TimeStamp=',dbgs(Project.SourceDirectories.TimeStamp));
|
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories ',Project.IDAsString,' Active=',dbgs(Active),' TimeStamp=',dbgs(fLastSourceDirStamp),' Project.TimeStamp=',dbgs(Project.SourceDirectories.TimeStamp));
|
||||||
if (not Project.NeedsDefineTemplates) or (not Active) then exit;
|
if (not Project.NeedsDefineTemplates) or (not Active) then exit;
|
||||||
|
|
||||||
// quick check if something has changed
|
// quick check if something has changed
|
||||||
IDHasChanged:=fLastSourceDirsIDAsString<>Project.IDAsString;
|
IDHasChanged:=fLastSourceDirsIDAsString<>Project.IDAsString;
|
||||||
|
CurUnitPath:=Project.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
||||||
|
CurUnitPath:=CreateAbsoluteSearchPath(CurUnitPath,
|
||||||
|
Project.CompilerOptions.BaseDirectory);
|
||||||
|
|
||||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories A');
|
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories A');
|
||||||
if (fLastSourceDirectories<>nil)
|
if (fLastSourceDirectories<>nil)
|
||||||
and (fLastSourceDirStamp=Project.SourceDirectories.TimeStamp)
|
and (fLastSourceDirStamp=Project.SourceDirectories.TimeStamp)
|
||||||
and (not IDHasChanged) then
|
and (not IDHasChanged)
|
||||||
|
and (CurUnitPath=fLastUnitPath) then
|
||||||
exit;
|
exit;
|
||||||
fLastSourceDirStamp:=Project.SourceDirectories.TimeStamp;
|
fLastSourceDirStamp:=Project.SourceDirectories.TimeStamp;
|
||||||
fLastSourceDirsIDAsString:=Project.IDAsString;
|
fLastSourceDirsIDAsString:=Project.IDAsString;
|
||||||
|
fLastUnitPath:=CurUnitPath;
|
||||||
|
|
||||||
NewSourceDirs:=Project.SourceDirectories.CreateFileList;
|
NewSourceDirs:=Project.SourceDirectories.CreateFileList;
|
||||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories B "',NewSourceDirs.Text,'"');
|
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories B "',NewSourceDirs.Text,'"');
|
||||||
try
|
try
|
||||||
|
MergeSearchPaths(NewSourceDirs,CurUnitPath);
|
||||||
|
|
||||||
// real check if something has changed
|
// real check if something has changed
|
||||||
if (fLastSourceDirectories<>nil)
|
if (fLastSourceDirectories<>nil)
|
||||||
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
||||||
|
@ -45,8 +45,10 @@ begin
|
|||||||
if Handle <> 0 then Control := TWinControl(GetLCLObject(Pointer(Handle)))
|
if Handle <> 0 then Control := TWinControl(GetLCLObject(Pointer(Handle)))
|
||||||
else Control := nil;
|
else Control := nil;
|
||||||
|
|
||||||
If (Control <> nil) and (not GTK_WIDGET_DOUBLE_BUFFERED((PGTKWidget(Handle)))) and (Control.DoubleBuffered) then
|
If (Control <> nil) and (not GTK_WIDGET_DOUBLE_BUFFERED((PGTKWidget(Handle))))
|
||||||
begin
|
and (Control.DoubleBuffered)
|
||||||
|
then begin
|
||||||
|
//DebugLn(['TGtk2WidgetSet.BeginPaint ',DbgSName(Control)]);
|
||||||
paintrect.x := PS.rcPaint.Left;
|
paintrect.x := PS.rcPaint.Left;
|
||||||
paintrect.y := PS.rcPaint.Top;
|
paintrect.y := PS.rcPaint.Top;
|
||||||
paintrect.width := PS.rcPaint.Right- PS.rcPaint.Left;
|
paintrect.width := PS.rcPaint.Right- PS.rcPaint.Left;
|
||||||
@ -54,7 +56,8 @@ begin
|
|||||||
if (paintrect.width <= 0) or (paintrect.height <=0) then begin
|
if (paintrect.width <= 0) or (paintrect.height <=0) then begin
|
||||||
paintrect.x := 0;
|
paintrect.x := 0;
|
||||||
paintrect.y := 0;
|
paintrect.y := 0;
|
||||||
gdk_drawable_get_size(TDeviceContext(Result).Drawable, @paintrect.width, @paintrect.height);
|
gdk_drawable_get_size(TDeviceContext(Result).Drawable,
|
||||||
|
@paintrect.width, @paintrect.height);
|
||||||
end;
|
end;
|
||||||
gdk_window_freeze_updates(TDeviceContext(Result).Drawable);
|
gdk_window_freeze_updates(TDeviceContext(Result).Drawable);
|
||||||
gdk_window_begin_paint_rect (TDeviceContext(Result).Drawable, @paintrect);
|
gdk_window_begin_paint_rect (TDeviceContext(Result).Drawable, @paintrect);
|
||||||
|
@ -476,6 +476,7 @@ type
|
|||||||
fLastSourceDirStamp: integer;
|
fLastSourceDirStamp: integer;
|
||||||
fLastSourceDirsIDAsString: string;
|
fLastSourceDirsIDAsString: string;
|
||||||
FLastCustomOptions: string;
|
FLastCustomOptions: string;
|
||||||
|
fLastUnitPath: string;
|
||||||
FLazPackage: TLazPackage;
|
FLazPackage: TLazPackage;
|
||||||
FMain: TDefineTemplate;
|
FMain: TDefineTemplate;
|
||||||
FOutputDir: TDefineTemplate;
|
FOutputDir: TDefineTemplate;
|
||||||
@ -3811,20 +3812,29 @@ var
|
|||||||
SrcDirDefTempl: TDefineTemplate;
|
SrcDirDefTempl: TDefineTemplate;
|
||||||
IDHasChanged: Boolean;
|
IDHasChanged: Boolean;
|
||||||
SrcDirMarkDefTempl: TDefineTemplate;
|
SrcDirMarkDefTempl: TDefineTemplate;
|
||||||
|
CurUnitPath: String;
|
||||||
begin
|
begin
|
||||||
if (not LazPackage.NeedsDefineTemplates) or (not Active) then exit;
|
if (not LazPackage.NeedsDefineTemplates) or (not Active) then exit;
|
||||||
|
|
||||||
// quick check if something has changed
|
// quick check if something has changed
|
||||||
IDHasChanged:=fLastSourceDirsIDAsString<>LazPackage.IDAsString;
|
IDHasChanged:=fLastSourceDirsIDAsString<>LazPackage.IDAsString;
|
||||||
|
CurUnitPath:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
||||||
|
CurUnitPath:=CreateAbsoluteSearchPath(CurUnitPath,
|
||||||
|
LazPackage.CompilerOptions.BaseDirectory);
|
||||||
|
|
||||||
if (fLastSourceDirectories<>nil)
|
if (fLastSourceDirectories<>nil)
|
||||||
and (fLastSourceDirStamp=LazPackage.SourceDirectories.TimeStamp)
|
and (fLastSourceDirStamp=LazPackage.SourceDirectories.TimeStamp)
|
||||||
and (not IDHasChanged) then
|
and (not IDHasChanged)
|
||||||
|
and (CurUnitPath=fLastUnitPath) then
|
||||||
exit;
|
exit;
|
||||||
fLastSourceDirStamp:=LazPackage.SourceDirectories.TimeStamp;
|
fLastSourceDirStamp:=LazPackage.SourceDirectories.TimeStamp;
|
||||||
fLastSourceDirsIDAsString:=LazPackage.IDAsString;
|
fLastSourceDirsIDAsString:=LazPackage.IDAsString;
|
||||||
|
fLastUnitPath:=CurUnitPath;
|
||||||
|
|
||||||
NewSourceDirs:=LazPackage.SourceDirectories.CreateFileList;
|
NewSourceDirs:=LazPackage.SourceDirectories.CreateFileList;
|
||||||
try
|
try
|
||||||
|
MergeSearchPaths(NewSourceDirs,CurUnitPath);
|
||||||
|
|
||||||
// real check if something has changed
|
// real check if something has changed
|
||||||
if (fLastSourceDirectories<>nil)
|
if (fLastSourceDirectories<>nil)
|
||||||
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
||||||
|
@ -1254,7 +1254,8 @@ begin
|
|||||||
GetCompilerOptions;
|
GetCompilerOptions;
|
||||||
Caption:=Format(lisPckEditCompilerOptionsForPackage,[LazPackage.IDAsString]);
|
Caption:=Format(lisPckEditCompilerOptionsForPackage,[LazPackage.IDAsString]);
|
||||||
ReadOnly:=LazPackage.ReadOnly;
|
ReadOnly:=LazPackage.ReadOnly;
|
||||||
ShowModal;
|
if ShowModal=mrOk then
|
||||||
|
LazPackage.DefineTemplates.AllChanged;
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
|
Loading…
Reference in New Issue
Block a user