Browse Source

* Use fpmkunit in the fppkg package, to avoid double code.
This also adds (among others) iphonesim support to fppkg

git-svn-id: trunk@21959 -

joost 13 years ago
parent
commit
160c2fec65

+ 1 - 0
packages/fppkg/fpmake.pp

@@ -33,6 +33,7 @@ begin
     P.Dependencies.Add('fcl-xml');
     P.Dependencies.Add('fcl-xml');
     P.Dependencies.Add('fcl-process');
     P.Dependencies.Add('fcl-process');
     P.Dependencies.Add('paszlib');
     P.Dependencies.Add('paszlib');
+    P.Dependencies.Add('fpmkunit');
 
 
     P.Dependencies.Add('univint',[MacOSX,iphonesim]);
     P.Dependencies.Add('univint',[MacOSX,iphonesim]);
     P.Dependencies.Add('fcl-net', TargetsWithfpWeb);
     P.Dependencies.Add('fcl-net', TargetsWithfpWeb);

+ 5 - 238
packages/fppkg/src/fprepos.pp

@@ -19,57 +19,15 @@ interface
 uses
 uses
   classes,sysutils,
   classes,sysutils,
   contnrs,
   contnrs,
+  fpmkunit,
   streamcoll;
   streamcoll;
 
 
 Const
 Const
   StreamVersion   : Integer = 1;
   StreamVersion   : Integer = 1;
   StreamSignature = $FEEF;
   StreamSignature = $FEEF;
 
 
-Type
-  // Keep syncronized with fpmkunit.pp
-  TCpu=(cpuNone,
-    i386,m68k,powerpc,sparc,x86_64,arm,powerpc64
-  );
-  TCPUS = Set of TCPU;
-
-  // Keep syncronized with fpmkunit.pp
-  TOS=(osNone,
-    linux,go32v2,win32,os2,freebsd,beos,netbsd,
-    amiga,atari, solaris, qnx, netware, openbsd,wdosx,
-    palmos,macos,darwin,emx,watcom,morphos,netwlibc,
-    win64,wince,gba,nds,embedded,symbian,haiku
-  );
-  TOSes = Set of TOS;
-
-const
-  AllOSes = [Low(TOS)..High(TOS)];
-  AllCPUs = [Low(TCPU)..High(TCPU)];
 
 
 type
 type
-  { TFPVersion }
-
-  TFPVersion = Class(TPersistent)
-  private
-    FMajor,
-    FMinor,
-    FMicro,
-    FBuild    : Word;
-    function GetAsString: String;
-    function GetEmpty: Boolean;
-    procedure SetAsString(const AValue: String);
-  Public
-   Procedure Clear;
-   Procedure Assign(Source : TPersistent); override;
-   Property AsString : String Read GetAsString Write SetAsString;
-   Function CompareVersion(AVersion : TFPVersion) : Integer;
-   Function SameVersion(AVersion : TFPVersion) : Boolean;
-   Property Empty : Boolean Read GetEmpty;
-  Published
-   Property Major : Word Read FMajor Write FMajor;
-   Property Minor : Word Read FMinor Write FMinor;
-   Property Micro : Word Read FMicro Write FMicro;
-   Property Build : Word Read FBuild Write FBuild;
-  end;
 
 
   { TFPDependency }
   { TFPDependency }
 
 
@@ -87,11 +45,11 @@ type
     Procedure LoadFromStream(Stream : TStream; Streamversion : Integer); override;
     Procedure LoadFromStream(Stream : TStream; Streamversion : Integer); override;
     Procedure SaveToStream(Stream : TStream); override;
     Procedure SaveToStream(Stream : TStream); override;
     Procedure Assign(Source : TPersistent); override;
     Procedure Assign(Source : TPersistent); override;
+    Property OSes : TOSes Read FOSes Write FOses;
+    Property CPUs : TCPUs Read FCPUs Write FCPUs;
   Published
   Published
     Property PackageName : String Read FPackageName Write FPackageName;
     Property PackageName : String Read FPackageName Write FPackageName;
     Property MinVersion : TFPVersion Read FMinVersion Write SetMinVersion;
     Property MinVersion : TFPVersion Read FMinVersion Write SetMinVersion;
-    Property OSes : TOSes Read FOSes Write FOses;
-    Property CPUs : TCPUs Read FCPUs Write FCPUs;
     Property RequireChecksum : Cardinal Read FRequireChecksum Write FRequireChecksum;
     Property RequireChecksum : Cardinal Read FRequireChecksum Write FRequireChecksum;
   end;
   end;
 
 
@@ -153,6 +111,8 @@ type
     Property InstalledLocally : boolean read FInstalledLocally write FInstalledLocally;
     Property InstalledLocally : boolean read FInstalledLocally write FInstalledLocally;
     Property UnusedVersion : TFPVersion Read FUnusedVersion Write SetUnusedVersion;
     Property UnusedVersion : TFPVersion Read FUnusedVersion Write SetUnusedVersion;
     Property RecompileBroken : boolean read FRecompileBroken write FRecompileBroken;
     Property RecompileBroken : boolean read FRecompileBroken write FRecompileBroken;
+    Property OSes : TOSes Read FOSes Write FOses;
+    Property CPUs : TCPUs Read FCPUs Write FCPUs;
   Published
   Published
     Property Name : String Read FName Write SetName;
     Property Name : String Read FName Write SetName;
     Property Author : String Read FAuthor Write FAuthor;
     Property Author : String Read FAuthor Write FAuthor;
@@ -166,8 +126,6 @@ type
     Property DownloadURL : String Read FDownloadURL Write FDownloadURL;
     Property DownloadURL : String Read FDownloadURL Write FDownloadURL;
     Property FileName : String Read GetFileName Write FFileName;
     Property FileName : String Read GetFileName Write FFileName;
     Property Email : String Read FEmail Write FEmail;
     Property Email : String Read FEmail Write FEmail;
-    Property OSes : TOSes Read FOSes Write FOses;
-    Property CPUs : TCPUs Read FCPUs Write FCPUs;
     Property Checksum : Cardinal Read FChecksum Write FChecksum;
     Property Checksum : Cardinal Read FChecksum Write FChecksum;
     Property IsFPMakeAddIn : boolean read FIsFPMakeAddIn write FIsFPMakeAddIn;
     Property IsFPMakeAddIn : boolean read FIsFPMakeAddIn write FIsFPMakeAddIn;
     // These properties are used to re-compile the package, when it's dependencies are changed.
     // These properties are used to re-compile the package, when it's dependencies are changed.
@@ -285,14 +243,6 @@ Const
   // Max level of dependency searching before we decide it's a circular dependency.
   // Max level of dependency searching before we decide it's a circular dependency.
   DefaultMaxDependencyLevel = 15;
   DefaultMaxDependencyLevel = 15;
 
 
-Function OSToString(OS: TOS) : String;
-Function OSesToString(OSes: TOSes) : String;
-Function CPUToString(CPU: TCPU) : String;
-Function CPUSToString(CPUS: TCPUS) : String;
-Function StringToOS(S : String) : TOS;
-Function OSesToString(S : String) : TOSes;
-Function StringToCPU(S : String) : TCPU;
-Function StringToCPUS(S : String) : TCPUS;
 Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
 Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
 Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
 Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
 
 
@@ -331,64 +281,6 @@ ResourceString
   SErrMirrorNotFound       = 'Mirror "%s" not found.';
   SErrMirrorNotFound       = 'Mirror "%s" not found.';
 
 
 
 
-Function OSToString(OS: TOS) : String;
-begin
-  Result:=LowerCase(GetenumName(TypeInfo(TOS),Ord(OS)));
-end;
-
-
-Function OSesToString(OSes: TOSes) : String;
-begin
-  Result:=LowerCase(SetToString(PtypeInfo(TypeInfo(TOSes)),Integer(OSes),False));
-end;
-
-
-Function CPUToString(CPU: TCPU) : String;
-begin
-  Result:=LowerCase(GetenumName(TypeInfo(TCPU),Ord(CPU)));
-end;
-
-
-Function CPUSToString(CPUS: TCPUS) : String;
-begin
-  Result:=LowerCase(SetToString(PTypeInfo(TypeInfo(TCPUS)),Integer(CPUS),False));
-end;
-
-
-Function StringToOS(S : String) : TOS;
-Var
-  I : Integer;
-begin
-  I:=GetEnumValue(TypeInfo(TOS),S);
-  if (I=-1) then
-    Raise EPackage.CreateFmt(SErrInvalidOS,[S]);
-  Result:=TOS(I);
-end;
-
-
-Function OSesToString(S : String) : TOSes;
-begin
-  Result:=TOSes(StringToSet(PTypeInfo(TypeInfo(TOSes)),S));
-end;
-
-
-Function StringToCPU(S : String) : TCPU;
-Var
-  I : Integer;
-begin
-  I:=GetEnumValue(TypeInfo(TCPU),S);
-  if (I=-1) then
-    Raise EPackage.CreateFmt(SErrInvalidCPU,[S]);
-  Result:=TCPU(I);
-end;
-
-
-Function StringToCPUS(S : String) : TCPUS;
-begin
-  Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));
-end;
-
-
 Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
 Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
 begin
 begin
   Result:=CPUToString(CPU)+'-'+OSToString(OS);
   Result:=CPUToString(CPU)+'-'+OSToString(OS);
@@ -407,131 +299,6 @@ begin
 end;
 end;
 
 
 
 
-{ TFPVersion }
-
-function TFPVersion.GetAsString: String;
-begin
-  if Empty then
-    Result:='<none>'
-  else
-    Result:=Format('%d.%d.%d-%d',[Major,Minor,Micro,Build]);
-end;
-
-
-function TFPVersion.GetEmpty: Boolean;
-begin
-  Result:=(Major=0) and (Minor=0) and (Micro=0) and (Build=0);
-end;
-
-
-procedure TFPVersion.SetAsString(const AValue: String);
-
-  Function NextDigit(sep : Char; NonNumerisIsSep : boolean; var V : string; aDefault : integer = 0) : integer;
-  Var
-    P : Integer;
-    i : Integer;
-  begin
-    P:=Pos(Sep,V);
-    If (P=0) then
-      P:=Length(V)+1;
-    If NonNumerisIsSep then
-      for i := 1 to P-1 do
-        if not (V[i] in ['0','1','2','3','4','5','6','7','8','9']) then
-          begin
-            P := i;
-            Break;
-          end;
-    Result:=StrToIntDef(Copy(V,1,P-1),-1);
-    If Result<>-1 then
-      Delete(V,1,P)
-    else
-      Result:=aDefault;
-  end;
-
-Var
-  V : String;
-  b : integer;
-begin
-  Clear;
-  // Special support for empty version string
-  if (AValue='') or (AValue='<none>') then
-    exit;
-  V:=AValue;
-  // Supported version-format is x.y.z-b
-  // x,y,z and b are all optional and are set to 0 if they are not provided
-  // except for b which has a default of 1.
-  // x and y must be numeric. z or b may contain a non-numeric suffix which
-  // will be stripped. If there is any non-numeric character in z or b and
-  // there is no value supplied for b, build will be set to 0
-  // examples:
-  // 2          -> 2.0.0-1
-  // 2.2        -> 2.2.0-1
-  // 2.2.4      -> 2.2.4-1
-  // 2.2.4-0    -> 2.2.4-0
-  // 2.2.4rc1   -> 2.2.4-0
-  // 2.2.4-0rc1 -> 2.2.4-0
-  // 2.2.4-2rc1 -> 2.2.4-2
-  Major:=NextDigit('.',False,V);
-  Minor:=NextDigit('.',False,V);
-  Micro:=NextDigit('-',True,V);
-  b := NextDigit(#0,True,V,-1);
-  if b<0 then
-    if V <> '' then
-      Build := 0
-    else
-      Build := 1
-  else
-    Build := b;
-end;
-
-
-procedure TFPVersion.Clear;
-begin
-  Micro:=0;
-  Major:=0;
-  Minor:=0;
-  Build:=0;
-end;
-
-
-procedure TFPVersion.Assign(Source: TPersistent);
-Var
-  V : TFPVersion;
-begin
-  if Source is TFPVersion then
-    begin
-      V:=Source as TFPVersion;
-      Major:=V.Major;
-      Minor:=V.Minor;
-      Micro:=V.Micro;
-      Build:=V.Build;
-    end
-  else
-    inherited Assign(Source);
-end;
-
-
-function TFPVersion.CompareVersion(AVersion: TFPVersion): Integer;
-begin
-  Result:=Major-AVersion.Major;
-  If (Result=0) then
-    begin
-      Result:=Minor-AVersion.Minor;
-      if (Result=0) then
-        begin
-          Result:=Micro-AVersion.Micro;
-          If (Result=0) then
-            Result:=Build-AVersion.Build;
-        end;
-    end;
-end;
-
-
-function TFPVersion.SameVersion(AVersion: TFPVersion): Boolean;
-begin
-  Result:=CompareVersion(AVersion)=0;
-end;
-
 { TFPPackage }
 { TFPPackage }
 
 
 procedure TFPPackage.SetVersion(const AValue: TFPVersion);
 procedure TFPPackage.SetVersion(const AValue: TFPVersion);

+ 1 - 1
packages/fppkg/src/fpxmlrep.pp

@@ -17,7 +17,7 @@ unit fpxmlrep;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, dom, fprepos;
+  Classes, SysUtils, dom, fprepos, fpmkunit;
 
 
 Type
 Type
 
 

+ 1 - 1
packages/fppkg/src/pkgfpmake.pp

@@ -6,7 +6,7 @@ interface
 
 
 uses
 uses
   Classes,SysUtils,DateUtils,
   Classes,SysUtils,DateUtils,
-  pkghandler;
+  pkghandler, fpmkunit;
 
 
 implementation
 implementation
 
 

+ 1 - 0
packages/fppkg/src/pkgglobals.pp

@@ -10,6 +10,7 @@ uses
 {$endif}
 {$endif}
   SysUtils,
   SysUtils,
   Classes,
   Classes,
+  fpmkunit,
   fprepos;
   fprepos;
 
 
 Const
 Const

+ 1 - 1
packages/fppkg/src/pkgoptions.pp

@@ -16,7 +16,7 @@ unit pkgoptions;
 
 
 interface
 interface
 
 
-uses Classes, Sysutils, Inifiles, fprepos, fpTemplate, pkgglobals;
+uses Classes, Sysutils, Inifiles, fprepos, fpTemplate, pkgglobals, fpmkunit;
 
 
 Const
 Const
   UnitConfigFileName   = 'fpunits.cfg';
   UnitConfigFileName   = 'fpunits.cfg';

+ 2 - 1
packages/fppkg/src/pkgrepos.pp

@@ -6,7 +6,8 @@ interface
 
 
 uses
 uses
   SysUtils,Classes,
   SysUtils,Classes,
-  fprepos,pkgoptions;
+  fprepos,pkgoptions,
+  fpmkunit;
 
 
 function GetRemoteRepositoryURL(const AFileName:string):string;
 function GetRemoteRepositoryURL(const AFileName:string):string;
 
 

+ 3 - 2
utils/fppkg/fppkg.pp

@@ -9,7 +9,7 @@ program fppkg;
 uses
 uses
   // General
   // General
 {$ifdef unix}
 {$ifdef unix}
-  baseunix,
+  baseunix, cthreads,
 {$endif}
 {$endif}
   Classes, SysUtils, TypInfo, custapp,
   Classes, SysUtils, TypInfo, custapp,
   // Repository handler objects
   // Repository handler objects
@@ -17,7 +17,8 @@ uses
   pkgmessages, pkgglobals, pkgoptions, pkgrepos,
   pkgmessages, pkgglobals, pkgoptions, pkgrepos,
   // Package Handler components
   // Package Handler components
   pkghandler,pkgmkconv, pkgdownload,
   pkghandler,pkgmkconv, pkgdownload,
-  pkgfpmake, pkgcommands
+  pkgfpmake, pkgcommands,
+  fpmkunit
   // Downloaders
   // Downloaders
 {$if defined(unix) or defined(windows)}
 {$if defined(unix) or defined(windows)}
   ,pkgwget
   ,pkgwget