Browse Source

* Added TPackage.IsFPMakeAddIn, when this flag is set, the package can be
needed when compiling fpmake.pp files.
* Pass -dCOMPILED_BY_FPPKG to the compiler when compiling fpmake files. This
is used to show better error-messages when a fpmake-addin is missing
* FPMKUnitDeps is not a constant anymore, but a variable, so that extra
dependencies for the fpmake.pp files can be added. (The add-ins)
* Added TFPMKUnitDep.Def, so that it canbe detected is an AddIn is available

git-svn-id: trunk@16462 -

joost 14 years ago
parent
commit
94e9d5ebb8

+ 2 - 0
utils/fppkg/fprepos.pp

@@ -114,6 +114,7 @@ type
     FDescription: String;
     FEmail: String;
     FInstalledLocally: boolean;
+    FIsFPMakeAddIn: boolean;
     FLicense: String;
     FName: String;
     FHomepageURL: String;
@@ -155,6 +156,7 @@ type
     Property OSes : TOSes Read FOSes Write FOses;
     Property CPUs : TCPUs Read FCPUs Write FCPUs;
     Property Checksum : Cardinal Read FChecksum Write FChecksum;
+    Property IsFPMakeAddIn : boolean read FIsFPMakeAddIn write FIsFPMakeAddIn;
     // Manual package from commandline not in official repository
     Property LocalFileName : String Read FLocalFileName Write FLocalFileName;
   end;

+ 5 - 2
utils/fppkg/pkgfpmake.pp

@@ -189,14 +189,17 @@ begin
       if Not HaveFPMake then
         Error(SErrMissingFPMake);
       AddOption('-n');
-      for i:=1 to FPMKUnitDepCount do
+      AddOption('-dCOMPILED_BY_FPPKG');
+      for i:=0 to high(FPMKUnitDeps) do
         begin
-          if FPMKUnitDepAvailable[i] then
+          if FPMKUnitDeps[i].available then
             begin
               if CheckUnitDir(FPMKUnitDeps[i].package,DepDir) then
                 AddOption(maybequoted('-Fu'+DepDir))
               else
                 Error(SErrMissingInstallPackage,[FPMKUnitDeps[i].package]);
+              if FPMKUnitDeps[i].def<>'' then
+                AddOption('-d'+FPMKUnitDeps[i].def);
             end
           else
             begin

+ 8 - 6
utils/fppkg/pkgglobals.pp

@@ -23,9 +23,11 @@ Const
 
 Type
   TFPMKUnitDep=record
-    package : string[12];
-    reqver  : string[8];
-    undef   : string[16];
+    package  : string[12];
+    reqver   : string[8];
+    undef    : string[32];
+    def      : string[32];
+    available: boolean;
   end;
 
 Const
@@ -33,8 +35,8 @@ Const
   CurrentDirPackageName='<currentdir>';
 
   // Dependencies for compiling the fpmkunit unit
-  FPMKUnitDepCount=4;
-  FPMKUnitDeps : array[1..4] of TFPMKUnitDep = (
+  FPMKUnitDepDefaultCount=4;
+  FPMKUnitDepsDefaults : array[0..FPMKUnitDepDefaultCount-1] of TFPMKUnitDep = (
     (package: 'hash';
      reqver : '2.2.2';
      undef  : 'NO_UNIT_ZIPPER'),
@@ -82,7 +84,7 @@ function IsSuperUser:boolean;
 
 var
   LogLevels : TLogLevels;
-  FPMKUnitDepAvailable : array[1..FPMKUnitDepCount] of boolean;
+  FPMKUnitDeps : array of TFPMKUnitDep;
 
 
 Implementation

+ 1 - 0
utils/fppkg/pkgmessages.pp

@@ -71,6 +71,7 @@ Resourcestring
   SLogLoadingPackagesFile    = 'Loading available packages from "%s"';
   SLogLoadingMirrorsFile     = 'Loading available mirrors from "%s"';
   SLogFindInstalledPackages  = 'Finding installed packages in "%s"';
+  SLogFoundFPMakeAddin       = 'Found FPMake-AddIn "%s"';
   SLogSavingStatusFile       = 'Saving local status to "%s"';
   SLogFPMKUnitDepVersion     = 'Checking for %s %s, installed %s, available %s';
   SLogFPMKUnitDepTooOld      = 'Minimum version of %s is not installed, using internal fpmkunit with limited functionality';

+ 6 - 0
utils/fppkg/pkgoptions.pp

@@ -276,6 +276,8 @@ end;
 
 
 Procedure TGlobalOptions.InitGlobalDefaults;
+var
+  i: Integer;
 begin
   FConfigVersion:=CurrentConfigVersion;
   // Retrieve Local fppkg directory
@@ -314,6 +316,10 @@ begin
   FInstallGlobal:=False;
   FRecoveryMode:=False;
   FAllowBroken:=False;
+
+  SetLength(FPMKUnitDeps,FPMKUnitDepDefaultCount);
+  for i := 0 to FPMKUnitDepDefaultCount-1 do
+    FPMKUnitDeps[i]:=FPMKUnitDepsDefaults[i];
 end;
 
 

+ 17 - 5
utils/fppkg/pkgrepos.pp

@@ -215,6 +215,7 @@ begin
     // Read fpunits.conf
     V:=L.Values['version'];
     APackage.Version.AsString:=V;
+    APackage.IsFPMakeAddIn:=Upcase(L.Values['FPMakeAddIn'])='Y';
     V:=L.Values['checksum'];
     if V<>'' then
       APackage.Checksum:=StrToInt(V)
@@ -286,6 +287,15 @@ procedure FindInstalledPackages(ACompilerOptions:TCompilerOptions;showdups:boole
     end;
   end;
 
+  Procedure AddFPMakeAddIn(APackage: TFPPackage);
+  begin
+    Log(vlDebug,SLogFoundFPMakeAddin,[APackage.Name]);
+    setlength(FPMKUnitDeps,length(FPMKUnitDeps)+1);
+    FPMKUnitDeps[high(FPMKUnitDeps)].package:=APackage.Name;
+    FPMKUnitDeps[high(FPMKUnitDeps)].reqver:=APackage.Version.AsString;
+    FPMKUnitDeps[high(FPMKUnitDeps)].def:='HAS_PACKAGE_'+APackage.Name;
+  end;
+
   function CheckUnitDir(const AUnitDir:string; const Local: boolean):boolean;
   var
     SR : TSearchRec;
@@ -305,7 +315,9 @@ procedure FindInstalledPackages(ACompilerOptions:TCompilerOptions;showdups:boole
               if FileExistsLog(UF) then
                 begin
                   P:=AddInstalledPackage(SR.Name,UF,Local);
-                  LoadUnitConfigFromFile(P,UF)
+                  LoadUnitConfigFromFile(P,UF);
+                  if P.IsFPMakeAddIn then
+                    AddFPMakeAddIn(P);
                 end
               else
                 begin
@@ -390,14 +402,14 @@ var
   ReqVer : TFPVersion;
 begin
   // Reset availability
-  for i:=1 to FPMKUnitDepCount do
-    FPMKUnitDepAvailable[i]:=false;
+  for i:=0 to high(FPMKUnitDeps) do
+    FPMKUnitDeps[i].available:=false;
   // Not version check needed in Recovery mode, we always need to use
   // the internal bootstrap procedure
   if GlobalOptions.RecoveryMode then
     exit;
   // Check for fpmkunit dependencies
-  for i:=1 to FPMKUnitDepCount do
+  for i:=0 to high(FPMKUnitDeps) do
     begin
       P:=InstalledRepository.FindPackage(FPMKUnitDeps[i].package);
       if P<>nil then
@@ -411,7 +423,7 @@ begin
           ReqVer.AsString:=FPMKUnitDeps[i].ReqVer;
           Log(vlDebug,SLogFPMKUnitDepVersion,[P.Name,ReqVer.AsString,P.Version.AsString,AvailVerStr]);
           if ReqVer.CompareVersion(P.Version)<=0 then
-            FPMKUnitDepAvailable[i]:=true
+            FPMKUnitDeps[i].available:=true
           else
             Log(vlDebug,SLogFPMKUnitDepTooOld,[FPMKUnitDeps[i].package]);
         end