mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 00:59:30 +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
|
||||
function TrimSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
||||
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
|
||||
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
|
||||
function RemoveNonExistingPaths(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;
|
||||
function SearchDirectoryInSearchPath(const SearchPath, Directory: string;
|
||||
DirStartPos: integer = 1): integer;
|
||||
function SearchDirectoryInSearchPath(SearchPath: TStrings;
|
||||
const Directory: string; DirStartPos: integer = 0): integer;
|
||||
|
||||
// XMLConfig
|
||||
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
|
||||
@ -405,6 +408,30 @@ begin
|
||||
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;
|
||||
var
|
||||
OldPathLen: Integer;
|
||||
@ -641,6 +668,46 @@ begin
|
||||
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;
|
||||
UsePointDirectory: boolean): string;
|
||||
begin
|
||||
|
@ -379,6 +379,7 @@ type
|
||||
fLastSourceDirsIDAsString: string;
|
||||
fLastSourceDirStamp: integer;
|
||||
FLastCustomOptions: string;
|
||||
fLastUnitPath: string;
|
||||
procedure SetActive(const AValue: boolean);
|
||||
procedure UpdateMain;
|
||||
procedure UpdateSrcDirIfDef;
|
||||
@ -4130,23 +4131,32 @@ var
|
||||
SrcDirDefTempl: TDefineTemplate;
|
||||
IDHasChanged: Boolean;
|
||||
SrcDirMarkDefTempl: TDefineTemplate;
|
||||
CurUnitPath: String;
|
||||
begin
|
||||
//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;
|
||||
|
||||
// quick check if something has changed
|
||||
IDHasChanged:=fLastSourceDirsIDAsString<>Project.IDAsString;
|
||||
CurUnitPath:=Project.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
||||
CurUnitPath:=CreateAbsoluteSearchPath(CurUnitPath,
|
||||
Project.CompilerOptions.BaseDirectory);
|
||||
|
||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories A');
|
||||
if (fLastSourceDirectories<>nil)
|
||||
and (fLastSourceDirStamp=Project.SourceDirectories.TimeStamp)
|
||||
and (not IDHasChanged) then
|
||||
and (not IDHasChanged)
|
||||
and (CurUnitPath=fLastUnitPath) then
|
||||
exit;
|
||||
fLastSourceDirStamp:=Project.SourceDirectories.TimeStamp;
|
||||
fLastSourceDirsIDAsString:=Project.IDAsString;
|
||||
fLastUnitPath:=CurUnitPath;
|
||||
|
||||
NewSourceDirs:=Project.SourceDirectories.CreateFileList;
|
||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories B "',NewSourceDirs.Text,'"');
|
||||
try
|
||||
MergeSearchPaths(NewSourceDirs,CurUnitPath);
|
||||
|
||||
// real check if something has changed
|
||||
if (fLastSourceDirectories<>nil)
|
||||
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
||||
|
@ -45,8 +45,10 @@ begin
|
||||
if Handle <> 0 then Control := TWinControl(GetLCLObject(Pointer(Handle)))
|
||||
else Control := nil;
|
||||
|
||||
If (Control <> nil) and (not GTK_WIDGET_DOUBLE_BUFFERED((PGTKWidget(Handle)))) and (Control.DoubleBuffered) then
|
||||
begin
|
||||
If (Control <> nil) and (not GTK_WIDGET_DOUBLE_BUFFERED((PGTKWidget(Handle))))
|
||||
and (Control.DoubleBuffered)
|
||||
then begin
|
||||
//DebugLn(['TGtk2WidgetSet.BeginPaint ',DbgSName(Control)]);
|
||||
paintrect.x := PS.rcPaint.Left;
|
||||
paintrect.y := PS.rcPaint.Top;
|
||||
paintrect.width := PS.rcPaint.Right- PS.rcPaint.Left;
|
||||
@ -54,7 +56,8 @@ begin
|
||||
if (paintrect.width <= 0) or (paintrect.height <=0) then begin
|
||||
paintrect.x := 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;
|
||||
gdk_window_freeze_updates(TDeviceContext(Result).Drawable);
|
||||
gdk_window_begin_paint_rect (TDeviceContext(Result).Drawable, @paintrect);
|
||||
|
@ -476,6 +476,7 @@ type
|
||||
fLastSourceDirStamp: integer;
|
||||
fLastSourceDirsIDAsString: string;
|
||||
FLastCustomOptions: string;
|
||||
fLastUnitPath: string;
|
||||
FLazPackage: TLazPackage;
|
||||
FMain: TDefineTemplate;
|
||||
FOutputDir: TDefineTemplate;
|
||||
@ -3811,20 +3812,29 @@ var
|
||||
SrcDirDefTempl: TDefineTemplate;
|
||||
IDHasChanged: Boolean;
|
||||
SrcDirMarkDefTempl: TDefineTemplate;
|
||||
CurUnitPath: String;
|
||||
begin
|
||||
if (not LazPackage.NeedsDefineTemplates) or (not Active) then exit;
|
||||
|
||||
// quick check if something has changed
|
||||
IDHasChanged:=fLastSourceDirsIDAsString<>LazPackage.IDAsString;
|
||||
CurUnitPath:=LazPackage.CompilerOptions.ParsedOpts.GetParsedValue(pcosUnitPath);
|
||||
CurUnitPath:=CreateAbsoluteSearchPath(CurUnitPath,
|
||||
LazPackage.CompilerOptions.BaseDirectory);
|
||||
|
||||
if (fLastSourceDirectories<>nil)
|
||||
and (fLastSourceDirStamp=LazPackage.SourceDirectories.TimeStamp)
|
||||
and (not IDHasChanged) then
|
||||
and (not IDHasChanged)
|
||||
and (CurUnitPath=fLastUnitPath) then
|
||||
exit;
|
||||
fLastSourceDirStamp:=LazPackage.SourceDirectories.TimeStamp;
|
||||
fLastSourceDirsIDAsString:=LazPackage.IDAsString;
|
||||
fLastUnitPath:=CurUnitPath;
|
||||
|
||||
NewSourceDirs:=LazPackage.SourceDirectories.CreateFileList;
|
||||
try
|
||||
MergeSearchPaths(NewSourceDirs,CurUnitPath);
|
||||
|
||||
// real check if something has changed
|
||||
if (fLastSourceDirectories<>nil)
|
||||
and (NewSourceDirs.Count=fLastSourceDirectories.Count)
|
||||
|
@ -1254,7 +1254,8 @@ begin
|
||||
GetCompilerOptions;
|
||||
Caption:=Format(lisPckEditCompilerOptionsForPackage,[LazPackage.IDAsString]);
|
||||
ReadOnly:=LazPackage.ReadOnly;
|
||||
ShowModal;
|
||||
if ShowModal=mrOk then
|
||||
LazPackage.DefineTemplates.AllChanged;
|
||||
Free;
|
||||
end;
|
||||
UpdateButtons;
|
||||
|
Loading…
Reference in New Issue
Block a user