* check for all fpmkunit dependencies with version check

git-svn-id: trunk@9306 -
This commit is contained in:
peter 2007-11-20 22:23:41 +00:00
parent b72cb5f4b8
commit 0852ce56a9
4 changed files with 62 additions and 61 deletions

View File

@ -139,13 +139,12 @@ Procedure TFPMakeCompiler.CompileFPMake;
const
TempBuildDir = 'build-fpmake';
Var
i : Integer;
OOptions,
DepDir,
DepDir2,
FPMakeBin,
FPMakeSrc : string;
NeedFPMKUnitSource,
DoBootStrap,
HaveFpmake : boolean;
begin
SetCurrentDir(PackageBuildPath);
@ -166,49 +165,26 @@ begin
if Not HaveFPMake then
Error(SErrMissingFPMake);
OOptions:='-n';
// Add FPMKUnit unit dir, if not installed we use the internal fpmkunit source
if HasFPMKUnitInstalled then
for i:=1 to FPMKUnitDepCount do
begin
if CheckUnitDir('fpmkunit',DepDir) then
OOptions:=OOptions+' -Fu'+DepDir
if FPMKUnitDepAvailable[i] then
begin
if CheckUnitDir(FPMKUnitDeps[i].package,DepDir) then
OOptions:=OOptions+' -Fu'+DepDir
else
Error(SErrMissingInstallPackage,[FPMKUnitDeps[i].package]);
end
else
Error(SErrMissingInstallPackage,['fpmkunit']);
end
else
begin
NeedFPMKUnitSource:=true;
OOptions:=OOptions+' -Fu'+TempBuildDir;
end;
// Add PaszLib and Hash units dir, when internal fpmkunit is used we
// can suppress the use by NO_UNIT_ZIPPER
if not CheckUnitDir('hash',DepDir) then
begin
if NeedFPMKUnitSource then
DepDir:=''
else
Error(SErrMissingInstallPackage,['hash']);
end;
if not CheckUnitDir('paszlib',DepDir2) then
begin
if NeedFPMKUnitSource then
DepDir2:=''
else
Error(SErrMissingInstallPackage,['paszlib']);
end;
if (DepDir<>'') and (DepDir2<>'') then
OOptions:=OOptions+' -Fu'+DepDir+' -Fu'+DepDir2
else
OOptions:=OOptions+' -dNO_UNIT_ZIPPER';
// Add Process unit dir, when internal fpmkunit is used we
// can suppress the use by NO_UNIT_PROCESS
if CheckUnitDir('fcl-process',DepDir) then
OOptions:=OOptions+' -Fu'+DepDir
else
begin
if NeedFPMKUnitSource then
OOptions:=OOptions+' -dNO_UNIT_PROCESS'
else
Error(SErrMissingInstallPackage,['fcl-process']);
begin
// If fpmkunit is not installed, we use the internal fpmkunit source
if FPMKUnitDeps[i].package='fpmkunit' then
begin
NeedFPMKUnitSource:=true;
OOptions:=OOptions+' -Fu'+TempBuildDir;
end;
if FPMKUnitDeps[i].undef<>'' then
OOptions:=OOptions+' -d'+FPMKUnitDeps[i].undef;
end;
end;
// Add RTL unit dir
if not CheckUnitDir('rtl',DepDir) then

View File

@ -17,9 +17,30 @@ Const
AllFiles='*.*';
{$endif unix}
Type
TFPMKUnitDep=record
package : string[12];
reqver : string[8];
undef : string[16];
end;
Const
// Dependencies for compiling the fpmkunit unit
RequiredFPMKUnitVersion = '2.2.0';
FPMKUnitDeps : array[0..4] of string[11] = ('rtl','hash','paszlib','fcl-process','fpmkunit');
FPMKUnitDepCount=4;
FPMKUnitDeps : array[1..4] of TFPMKUnitDep = (
(package: 'hash';
reqver : '2.0.0';
undef : 'NO_UNIT_ZIPPER'),
(package: 'paszlib';
reqver : '2.2.0';
undef : 'NO_UNIT_ZIPPER'),
(package: 'fcl-process';
reqver : '2.0.0';
undef : 'NO_UNIT_PROCESS'),
(package: 'fpmkunit';
reqver : '2.2.0';
undef : '')
);
Type
TVerbosity = (vError,vWarning,vInfo,vCommands,vDebug);
@ -48,7 +69,7 @@ function IsSuperUser:boolean;
var
Verbosity : TVerbosities;
HasFPMKUnitInstalled : boolean;
FPMKUnitDepAvailable : array[1..FPMKUnitDepCount] of boolean;
Implementation

View File

@ -62,8 +62,8 @@ Resourcestring
SLogLoadingPackagesFile = 'Loading available packages from "%s"';
SLogLoadingStatusFile = 'Loading local status from "%s"';
SLogSavingStatusFile = 'Saving local status to "%s"';
SLogPackageFPMKUnitVersion = 'Checking for fpmkunit %s, installed %s, available %s';
SLogPackageFPMKUnitTooOld = 'Minimum fpmkunit version not installed, using internal fpmkunit';
SLogFPMKUnitDepVersion = 'Checking for %s %s, installed %s, available %s';
SLogFPMKUnitDepTooOld = 'Minimum version of %s is not installed, using internal fpmkunit with limited functionality';
SDbgFound = 'Found';
SDbgNotFound = 'Not Found';

View File

@ -90,30 +90,34 @@ end;
procedure LoadFPMakeLocalStatus;
var
i : Integer;
S : String;
P : TFPPackage;
ReqVer : TFPVersion;
begin
HasFPMKUnitInstalled:=false;
S:=GlobalOptions.LocalVersionsFile(GlobalOptions.FPMakeCompilerConfig);
Log(vDebug,SLogLoadingStatusFile,[S]);
CurrentRepository.ClearStatus;
if FileExists(S) then
CurrentRepository.LoadStatusFromFile(S);
// Check for fpmkunit package
P:=CurrentRepository.PackageByName('fpmkunit');
if P<>nil then
// Check for fpmkunit dependencies
for i:=1 to FPMKUnitDepCount do
begin
ReqVer:=TFPVersion.Create;
ReqVer.AsString:=RequiredFPMKUnitVersion;
Log(vDebug,SLogPackageFPMKUnitVersion,[ReqVer.AsString,P.InstalledVersion.AsString,P.Version.AsString]);
if ReqVer.CompareVersion(P.InstalledVersion)<=0 then
HasFPMKUnitInstalled:=true
FPMKUnitDepAvailable[i]:=false;
P:=CurrentRepository.PackageByName(FPMKUnitDeps[i].package);
if P<>nil then
begin
ReqVer:=TFPVersion.Create;
ReqVer.AsString:=FPMKUnitDeps[i].ReqVer;
Log(vDebug,SLogFPMKUnitDepVersion,[P.Name,ReqVer.AsString,P.InstalledVersion.AsString,P.Version.AsString]);
if ReqVer.CompareVersion(P.InstalledVersion)<=0 then
FPMKUnitDepAvailable[i]:=true
else
Log(vDebug,SLogFPMKUnitDepTooOld,[FPMKUnitDeps[i].package]);
end
else
Log(vDebug,SLogPackageFPMKUnitTooOld);
end
else
Log(vDebug,SLogPackageFPMKUnitTooOld);
Log(vDebug,SLogFPMKUnitDepTooOld,[FPMKUnitDeps[i].package]);
end;
end;