* basic work to load installed versions from fpunits.conf

git-svn-id: trunk@10182 -
This commit is contained in:
peter 2008-02-03 15:16:13 +00:00
parent 66315c591e
commit 7ab46e8507
4 changed files with 119 additions and 65 deletions

View File

@ -12,7 +12,7 @@
<MainUnit Value="0"/> <MainUnit Value="0"/>
<IconPath Value=".\"/> <IconPath Value=".\"/>
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="7"/> <ActiveEditorIndexAtStart Value="4"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -28,17 +28,17 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<CommandLineParams Value="build hash"/> <CommandLineParams Value="avail"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<Units Count="38"> <Units Count="39">
<Unit0> <Unit0>
<Filename Value="fppkg.pp"/> <Filename Value="fppkg.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fppkg"/> <UnitName Value="fppkg"/>
<CursorPos X="1" Y="246"/> <CursorPos X="1" Y="317"/>
<TopLine Value="228"/> <TopLine Value="293"/>
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<UsageCount Value="86"/> <UsageCount Value="86"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -75,8 +75,8 @@
<Filename Value="fprepos.pp"/> <Filename Value="fprepos.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fprepos"/> <UnitName Value="fprepos"/>
<CursorPos X="1" Y="187"/> <CursorPos X="3" Y="167"/>
<TopLine Value="163"/> <TopLine Value="168"/>
<EditorIndex Value="8"/> <EditorIndex Value="8"/>
<UsageCount Value="86"/> <UsageCount Value="86"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -205,8 +205,8 @@
<Unit22> <Unit22>
<Filename Value="pkgrepos.pp"/> <Filename Value="pkgrepos.pp"/>
<UnitName Value="pkgrepos"/> <UnitName Value="pkgrepos"/>
<CursorPos X="17" Y="108"/> <CursorPos X="57" Y="242"/>
<TopLine Value="108"/> <TopLine Value="210"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="32"/> <UsageCount Value="32"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -276,7 +276,7 @@
<Unit32> <Unit32>
<Filename Value="pkglnet.pp"/> <Filename Value="pkglnet.pp"/>
<UnitName Value="pkglnet"/> <UnitName Value="pkglnet"/>
<CursorPos X="45" Y="32"/> <CursorPos X="71" Y="10"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="9"/> <EditorIndex Value="9"/>
<UsageCount Value="17"/> <UsageCount Value="17"/>
@ -321,76 +321,47 @@
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit37> </Unit37>
<Unit38>
<Filename Value="../../../proj/lazarus/lcl/interfaces/gtk/gtkproc.pp"/>
<UnitName Value="GTKProc"/>
<CursorPos X="11" Y="674"/>
<TopLine Value="655"/>
<UsageCount Value="10"/>
</Unit38>
</Units> </Units>
<JumpHistory Count="17" HistoryIndex="16"> <JumpHistory Count="8" HistoryIndex="7">
<Position1> <Position1>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="128" Column="17" TopLine="111"/> <Caret Line="108" Column="17" TopLine="108"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="47" Column="32" TopLine="28"/> <Caret Line="177" Column="16" TopLine="173"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="pkgfpmake.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="213" Column="18" TopLine="188"/> <Caret Line="212" Column="77" TopLine="193"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="51" Column="54" TopLine="32"/> <Caret Line="222" Column="33" TopLine="196"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="76" Column="25" TopLine="57"/> <Caret Line="210" Column="1" TopLine="183"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="110" Column="56" TopLine="91"/> <Caret Line="218" Column="29" TopLine="203"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="60" Column="31" TopLine="49"/> <Caret Line="26" Column="28" TopLine="7"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="pkghandler.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="160" Column="16" TopLine="134"/> <Caret Line="229" Column="1" TopLine="208"/>
</Position8> </Position8>
<Position9>
<Filename Value="pkghandler.pp"/>
<Caret Line="44" Column="36" TopLine="24"/>
</Position9>
<Position10>
<Filename Value="pkghandler.pp"/>
<Caret Line="213" Column="46" TopLine="194"/>
</Position10>
<Position11>
<Filename Value="pkgfpmake.pp"/>
<Caret Line="236" Column="12" TopLine="199"/>
</Position11>
<Position12>
<Filename Value="pkgfpmake.pp"/>
<Caret Line="200" Column="20" TopLine="181"/>
</Position12>
<Position13>
<Filename Value="fppkg.pp"/>
<Caret Line="317" Column="24" TopLine="280"/>
</Position13>
<Position14>
<Filename Value="pkgglobals.pp"/>
<Caret Line="159" Column="52" TopLine="147"/>
</Position14>
<Position15>
<Filename Value="fppkg.pp"/>
<Caret Line="74" Column="30" TopLine="55"/>
</Position15>
<Position16>
<Filename Value="fppkg.pp"/>
<Caret Line="78" Column="32" TopLine="59"/>
</Position16>
<Position17>
<Filename Value="fppkg.pp"/>
<Caret Line="245" Column="9" TopLine="224"/>
</Position17>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -310,8 +310,7 @@ begin
begin begin
if FileExists(ParaPackages[i]) then if FileExists(ParaPackages[i]) then
begin begin
ActionPackage:=TFPPackage.Create(nil); ActionPackage:=CurrentRepository.AddPackage(ChangeFileExt(ExtractFileName(ParaPackages[i]),''));
ActionPackage.Name:=ChangeFileExt(ExtractFileName(ParaPackages[i]),'');
ActionPackage.FileName:=ExpandFileName(ParaPackages[i]); ActionPackage.FileName:=ExpandFileName(ParaPackages[i]);
ActionPackage.IsLocalPackage:=true; ActionPackage.IsLocalPackage:=true;
end end

View File

@ -19,6 +19,7 @@ interface
uses Classes, Sysutils, Inifiles, fprepos; uses Classes, Sysutils, Inifiles, fprepos;
Const Const
UnitConfigFileName = 'fpunits.conf';
ManifestFileName = 'manifest.xml'; ManifestFileName = 'manifest.xml';
MirrorsFileName = 'mirrors.xml'; MirrorsFileName = 'mirrors.xml';
PackagesFileName = 'packages.xml'; PackagesFileName = 'packages.xml';

View File

@ -165,15 +165,94 @@ begin
end; end;
procedure LoadLocalStatus(ACompilerOptions:TCompilerOptions);
procedure LoadUnitConfigFromFile(APackage:TFPPackage;const AFileName: String);
Var
L,L2 : TStrings;
Line : String;
I,P,PC : Integer;
VOS : TOS;
VCPU : TCPU;
V : String;
F : TFileStream;
begin
F:=TFileStream.Create(AFileName,fmOpenRead);
L:=TStringList.Create;
Try
L.LoadFromStream(F);
// Fix lines.
For I:=L.Count-1 downto 0 do
begin
Line:=L[I];
P:=Pos('=',Line);
PC:=Pos(';',Line); // Comment line.
If (P=0) or ((PC<>0) and (PC<P)) then
L.Delete(I)
else
L[i]:=Trim(System.Copy(Line,1,P-1)+'='+Trim(System.Copy(Line,P+1,Length(Line)-P)));
end;
{$warning TODO Maybe check also CPU-OS}
{$warning TODO Add date to check recompile}
V:=L.Values['version'];
writeln(AFileName, ' ',V);
APackage.InstalledVersion.AsString:=V;
Finally
L.Free;
F.Free;
end;
end;
function CheckUnitDir(const AUnitDir:string):boolean;
var
SR : TSearchRec;
P : TFPPackage;
UD,UF : String;
begin
Result:=false;
if FindFirst(IncludeTrailingPathDelimiter(AUnitDir)+AllFiles,faDirectory,SR)=0 then
begin
Log(vlDebug,SLogLoadingStatusFile,[AUnitDir]);
repeat
if (SR.Attr and faDirectory)=faDirectory then
begin
P:=CurrentRepository.FindPackage(SR.Name);
if not assigned(P) then
begin
P:=CurrentRepository.AddPackage(SR.Name);
P.IsLocalPackage:=true;
end;
UD:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(AUnitDir)+SR.Name);
UF:=UD+UnitConfigFileName;
if FileExists(UF) then
begin
LoadUnitConfigFromFile(P,UF);
end;
end;
until FindNext(SR)<>0;
end;
end;
begin
if ACompilerOptions.LocalUnitDir<>'' then
CheckUnitDir(ACompilerOptions.LocalUnitDir);
// if ACompilerOptions.GlobalUnitDir<>'' then
// CheckUnitDir(ACompilerOptions.GlobalUnitDir);
end;
procedure LoadLocalStatus; procedure LoadLocalStatus;
var var
S : String; S : String;
begin begin
LoadLocalStatus(CompilerOptions);
{
S:=GlobalOptions.LocalVersionsFile(GlobalOptions.CompilerConfig); S:=GlobalOptions.LocalVersionsFile(GlobalOptions.CompilerConfig);
Log(vlDebug,SLogLoadingStatusFile,[S]); Log(vlDebug,SLogLoadingStatusFile,[S]);
CurrentRepository.ClearStatus; CurrentRepository.ClearStatus;
if FileExists(S) then if FileExists(S) then
CurrentRepository.LoadStatusFromFile(S); CurrentRepository.LoadStatusFromFile(S);
}
end; end;
@ -194,11 +273,15 @@ var
P : TFPPackage; P : TFPPackage;
ReqVer : TFPVersion; ReqVer : TFPVersion;
begin begin
{
S:=GlobalOptions.LocalVersionsFile(GlobalOptions.FPMakeCompilerConfig); S:=GlobalOptions.LocalVersionsFile(GlobalOptions.FPMakeCompilerConfig);
Log(vlDebug,SLogLoadingStatusFile,[S]); Log(vlDebug,SLogLoadingStatusFile,[S]);
CurrentRepository.ClearStatus; CurrentRepository.ClearStatus;
if FileExists(S) then if FileExists(S) then
CurrentRepository.LoadStatusFromFile(S); CurrentRepository.LoadStatusFromFile(S);
}
LoadLocalStatus(FPMakeCompilerOptions);
// Check for fpmkunit dependencies // Check for fpmkunit dependencies
for i:=1 to FPMKUnitDepCount do for i:=1 to FPMKUnitDepCount do
begin begin