From 09c5679a89b2a4e67fdf7f19c2ee123262881c22 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 3 Sep 2012 13:54:32 +0000 Subject: [PATCH] aarre: load unit/inc path from lpk git-svn-id: trunk@38501 - --- components/aarre/src/aarrebase.lpk | 11 +++-- components/aarre/src/aarrepkglist.pas | 58 +++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/components/aarre/src/aarrebase.lpk b/components/aarre/src/aarrebase.lpk index 8273117dc4..b15392c55c 100644 --- a/components/aarre/src/aarrebase.lpk +++ b/components/aarre/src/aarrebase.lpk @@ -5,7 +5,7 @@ - + @@ -21,13 +21,16 @@ - + - + - + + + + diff --git a/components/aarre/src/aarrepkglist.pas b/components/aarre/src/aarrepkglist.pas index bbba72a148..704f2fbd4e 100644 --- a/components/aarre/src/aarrepkglist.pas +++ b/components/aarre/src/aarrepkglist.pas @@ -34,7 +34,7 @@ unit AarrePkgList; interface uses - Classes, SysUtils, Laz2_XMLCfg, laz2_DOM, LazLogger, laz2_XMLWrite; + Classes, SysUtils, Laz2_XMLCfg, laz2_DOM, LazLogger, FileProcs; type TAPackageType = ( @@ -121,11 +121,14 @@ type private FAuthor: String; FDescription: String; + FIncPath: string; FLicense: String; FLPKFilename: string; FName: string; FPackageType: TAPackageType; FDependencies: TAPkgDependencies; + FSourcesPath: string; + FUnitPath: string; FVersion: TAPkgVersion; procedure SetLPKFilename(AValue: string); procedure SetName(AValue: string); @@ -136,6 +139,9 @@ type procedure Load(XML: TXMLConfig; Path: string); virtual; procedure Save(XML: TXMLConfig; Path: string); virtual; procedure LoadLPK(LPKFilename: string); + procedure UpdateSourcesPath; + + // properties saved to packages.gz property Name: string read FName write SetName; property Version: TAPkgVersion read FVersion; property PackageType: TAPackageType read FPackageType write FPackageType; @@ -145,6 +151,11 @@ type property LPKFilename: string read FLPKFilename write SetLPKFilename; property Dependencies: TAPkgDependencies read FDependencies; + + // properties not saved in packages.gz + property UnitPath: string read FUnitPath write FUnitPath; + property IncPath: string read FIncPath write FIncPath; + property SourcesPath: string read FSourcesPath write FSourcesPath; end; { TAarrePkgList } @@ -386,12 +397,17 @@ begin Dependencies.Add(PkgDependency); end; + UnitPath:=xml.GetValue(Path+'CompilerOptions/SearchPaths/UnitPath/Value',''); + IncPath:=xml.GetValue(Path+'CompilerOptions/SearchPaths/IncludePath/Value',''); + DebugLn(['TLPackage.Load Name="',Name,'"', ' Type=',APackageTypeIdents[PackageType], ' Author="',Author,'"', ' Description="',Description,'"', ' License="',License,'"', - ' Version="',Version.AsString,'"' + ' Version="',Version.AsString,'"', + ' UnitPath="',UnitPath,'"', + ' IncPath="',IncPath,'"' ]); finally @@ -399,6 +415,43 @@ begin end; end; +procedure TAarrePkgListItem.UpdateSourcesPath; +var + Path: String; + p: Integer; + CurPath: String; + MacroPos: Integer; + NewPath: String; +begin + Path:=UnitPath+';'+IncPath; + NewPath:=''; + p:=1; + while p<=length(Path) do begin + CurPath:=TrimFilename(SetDirSeparators(GetNextDelimitedItem(Path,';',p))); + if CurPath='' then continue; + MacroPos:=1; + while (MacroPos keep only path without macros, e.g. lib + while (MacroPos>1) and (CurPath[MacroPos]<>PathDelim) do + dec(MacroPos); + Delete(CurPath,MacroPos,length(CurPath)); + end; + end; + inc(MacroPos); + end; + if FindPathInSearchPath(PChar(CurPath),length(CurPath), + PChar(NewPath),length(NewPath))=nil + then; + NewPath+=';'+CurPath; + end; +end; + { TAarrePkgList } function TAarrePkgList.GetItems(Index: integer): TAarrePkgListItem; @@ -464,7 +517,6 @@ begin xml:=TXMLConfig.Create(nil); try Save(XML,'aarre/'); - debugln(['TAarrePkgList.SaveToStream TTT1']); xml.WriteToStream(s); finally xml.Free;