implemented adjusting project compiler paths on saving project as

git-svn-id: trunk@8570 -
This commit is contained in:
mattias 2006-01-19 23:37:55 +00:00
parent 8e7fce284d
commit 8aaac32221
2 changed files with 57 additions and 0 deletions

View File

@ -121,6 +121,9 @@ function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
function CreateRelativeSearchPath(const SearchPath, BaseDirectory: string): string;
function RebaseSearchPath(const SearchPath,
OldBaseDirectory, NewBaseDirectory: string;
SkipPathsStartingWithMakro: boolean): string;
function ShortenSearchPath(const SearchPath, BaseDirectory,
ChompDirectory: string): string;
function GetNextDirectoryInSearchPath(const SearchPath: string;
@ -428,6 +431,40 @@ begin
SetLength(Result,ResultStartPos-1);
end;
function RebaseSearchPath(const SearchPath, OldBaseDirectory,
NewBaseDirectory: string; SkipPathsStartingWithMakro: boolean): string;
// change every relative search path
var
EndPos: Integer;
StartPos: Integer;
CurPath: String;
begin
Result:=SearchPath;
if CompareFilenames(OldBaseDirectory,NewBaseDirectory)=0 then exit;
EndPos:=1;
repeat
StartPos:=EndPos;
while (StartPos<=length(Result)) and (Result[StartPos]=';') do
inc(StartPos);
if StartPos>length(Result) then break;
EndPos:=StartPos;
while (EndPos<=length(Result)) and (Result[EndPos]<>';') do
inc(EndPos);
if EndPos>StartPos then begin
CurPath:=copy(Result,StartPos,EndPos-StartPos);
if (not FilenameIsAbsolute(CurPath))
and ((not SkipPathsStartingWithMakro) or (CurPath[1]<>'$'))
then begin
CurPath:=TrimFilename(AppendPathDelim(OldBaseDirectory)+CurPath);
CurPath:=CreateRelativePath(CurPath,NewBaseDirectory);
Result:=copy(Result,1,StartPos-1)+CurPath
+copy(Result,EndPos,length(Result));
EndPos:=StartPos+length(CurPath);
end;
end;
until false;
end;
function ShortenSearchPath(const SearchPath, BaseDirectory,
ChompDirectory: string): string;
// Every search path that is a subdirectory of ChompDirectory will be shortened.

View File

@ -5035,6 +5035,26 @@ begin
// update source notebook page names
UpdateSourceNames;
end;
// update paths
Project1.CompilerOptions.OtherUnitFiles:=
RebaseSearchPath(Project1.CompilerOptions.OtherUnitFiles,OldProjectPath,
Project1.ProjectDirectory,true);
Project1.CompilerOptions.IncludeFiles:=
RebaseSearchPath(Project1.CompilerOptions.IncludeFiles,OldProjectPath,
Project1.ProjectDirectory,true);
Project1.CompilerOptions.Libraries:=
RebaseSearchPath(Project1.CompilerOptions.Libraries,OldProjectPath,
Project1.ProjectDirectory,true);
Project1.CompilerOptions.ObjectPath:=
RebaseSearchPath(Project1.CompilerOptions.ObjectPath,OldProjectPath,
Project1.ProjectDirectory,true);
Project1.CompilerOptions.SrcPath:=
RebaseSearchPath(Project1.CompilerOptions.SrcPath,OldProjectPath,
Project1.ProjectDirectory,true);
Project1.CompilerOptions.DebugPath:=
RebaseSearchPath(Project1.CompilerOptions.DebugPath,OldProjectPath,
Project1.ProjectDirectory,true);
// invalidate cached substituted macros
IncreaseCompilerParseStamp;