From 8aaac322219e0f36eab10eafa73fa85a716404fd Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 19 Jan 2006 23:37:55 +0000 Subject: [PATCH] implemented adjusting project compiler paths on saving project as git-svn-id: trunk@8570 - --- ide/ideprocs.pp | 37 +++++++++++++++++++++++++++++++++++++ ide/main.pp | 20 ++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/ide/ideprocs.pp b/ide/ideprocs.pp index c518c6c499..f673ee46a3 100644 --- a/ide/ideprocs.pp +++ b/ide/ideprocs.pp @@ -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. diff --git a/ide/main.pp b/ide/main.pp index 961d4ed080..745e9fe463 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -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;