Browse Source

* Add a .source- or src-suffix to source-archives
* Expand the prefix in the getter, not setter. This way the original value
stays available.
* The not-expanded prefix is used as prefix in source-archives
* PACKAGEVERSION and PACKAGEDIRECTORY macro's are added to the dictionary
* Use the zipprefix also for source-archives
* Allow usage of dictionary-macro's while creating source-archives

git-svn-id: trunk@28966 -

joost 10 years ago
parent
commit
684400b8e4
1 changed files with 41 additions and 17 deletions
  1. 41 17
      packages/fpmkunit/src/fpmkunit.pp

+ 41 - 17
packages/fpmkunit/src/fpmkunit.pp

@@ -917,6 +917,7 @@ Type
     function GetDocInstallDir: String;
     function GetDocInstallDir: String;
     function GetExamplesInstallDir: String;
     function GetExamplesInstallDir: String;
     function GetOptions: TStrings;
     function GetOptions: TStrings;
+    function GetPrefix: String;
     function GetUnitInstallDir: String;
     function GetUnitInstallDir: String;
     procedure SetLocalUnitDir(const AValue: String);
     procedure SetLocalUnitDir(const AValue: String);
     procedure SetGlobalUnitDir(const AValue: String);
     procedure SetGlobalUnitDir(const AValue: String);
@@ -971,7 +972,7 @@ Type
     // paths etc.
     // paths etc.
     Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocalUnitDir;
     Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocalUnitDir;
     Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlobalUnitDir;
     Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlobalUnitDir;
-    Property Prefix : String Read FPrefix Write SetPrefix;
+    Property Prefix : String Read GetPrefix Write SetPrefix;
     Property ZipPrefix : String Read FZipPrefix Write SetZipPrefix;
     Property ZipPrefix : String Read FZipPrefix Write SetZipPrefix;
     Property BaseInstallDir : String Read GetBaseInstallDir Write SetBaseInstallDir;
     Property BaseInstallDir : String Read GetBaseInstallDir Write SetBaseInstallDir;
     Property UnitInstallDir : String Read GetUnitInstallDir Write SetUnitInstallDir;
     Property UnitInstallDir : String Read GetUnitInstallDir Write SetUnitInstallDir;
@@ -1023,9 +1024,6 @@ Type
     FVerbose : boolean;
     FVerbose : boolean;
     FProgressMax : integer;
     FProgressMax : integer;
     FProgressCount : integer;
     FProgressCount : integer;
-{$ifdef HAS_UNIT_ZIPPER}
-    FZipFile: TZipper;
-{$endif HAS_UNIT_ZIPPER}
     FExternalPackages : TPackages;
     FExternalPackages : TPackages;
     // Events
     // Events
     FOnLog: TLogEvent;
     FOnLog: TLogEvent;
@@ -2137,6 +2135,13 @@ begin
     watcom: result := 'wat';
     watcom: result := 'wat';
     os2:    result := 'os2';
     os2:    result := 'os2';
     emx:    result := 'emx';
     emx:    result := 'emx';
+    osNone:
+      begin
+        if Defaults.BuildOS in AllLimit83fsOses then
+          result := 'src'
+        else
+          result := '.source'
+      end
   else
   else
     result := '.' + MakeTargetString(CPU, OS);
     result := '.' + MakeTargetString(CPU, OS);
   end;
   end;
@@ -3786,6 +3791,16 @@ begin
 end;
 end;
 
 
 
 
+function TCustomDefaults.GetPrefix: String;
+begin
+  // Use ExpandFileName to support ~/ expansion
+  if FPrefix<>'' then
+    Result:=IncludeTrailingPathDelimiter(ExpandFileName(FPrefix))
+  else
+    Result:='';
+end;
+
+
 function TCustomDefaults.GetUnitInstallDir: String;
 function TCustomDefaults.GetUnitInstallDir: String;
 begin
 begin
   result := FixPath(GlobalDictionary.ReplaceStrings(FUnitInstallDir), False);
   result := FixPath(GlobalDictionary.ReplaceStrings(FUnitInstallDir), False);
@@ -3892,11 +3907,7 @@ end;
 procedure TCustomDefaults.SetPrefix(const AValue: String);
 procedure TCustomDefaults.SetPrefix(const AValue: String);
 begin
 begin
   if FPrefix=AValue then exit;
   if FPrefix=AValue then exit;
-  // Use ExpandFileName to support ~/ expansion
-  if AValue<>'' then
-    FPrefix:=IncludeTrailingPathDelimiter(ExpandFileName(AValue))
-  else
-    FPrefix:='';
+  FPrefix:=AValue;
   GlobalDictionary.AddVariable('prefix',Prefix);
   GlobalDictionary.AddVariable('prefix',Prefix);
   GlobalDictionary.AddVariable('bininstalldir',BinInstallDir);
   GlobalDictionary.AddVariable('bininstalldir',BinInstallDir);
   BaseInstallDir:='';
   BaseInstallDir:='';
@@ -5386,6 +5397,8 @@ procedure TBuildEngine.AddPackageMacrosToDictionary(const APackage: TPackage; AD
 begin
 begin
   APackage.Dictionary.AddVariable('UNITSOUTPUTDIR',AddPathPrefix(APackage,APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS)));
   APackage.Dictionary.AddVariable('UNITSOUTPUTDIR',AddPathPrefix(APackage,APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS)));
   APackage.Dictionary.AddVariable('BINOUTPUTDIR',AddPathPrefix(APackage,APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS)));
   APackage.Dictionary.AddVariable('BINOUTPUTDIR',AddPathPrefix(APackage,APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS)));
+  APackage.Dictionary.AddVariable('PACKAGEVERSION',APackage.Version);
+  APackage.Dictionary.AddVariable('PACKAGEDIRECTORY',APackage.Directory);
 end;
 end;
 
 
 Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS;DoChangeDir:boolean=true; WarnIfNotFound:boolean=true);
 Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS;DoChangeDir:boolean=true; WarnIfNotFound:boolean=true);
@@ -6736,13 +6749,17 @@ Var
   i: integer;
   i: integer;
   ICPU : TCPU;
   ICPU : TCPU;
   IOS  : TOS;
   IOS  : TOS;
+{$ifdef HAS_UNIT_ZIPPER}
+  ZipFile: TZipper;
+{$endif HAS_UNIT_ZIPPER}
 begin
 begin
-  A:=FStartDir+ APackage.FileName + ZipExt;
+  A:=Defaults.ZipPrefix + APackage.FileName + MakeZipSuffix(cpuNone, osNone) + ZipExt;
   Log(vlInfo,SInfoArchivingPackage,[APackage.Name,A]);
   Log(vlInfo,SInfoArchivingPackage,[APackage.Name,A]);
   try
   try
     If (APackage.Directory<>'') then
     If (APackage.Directory<>'') then
       EnterDir(APackage.Directory);
       EnterDir(APackage.Directory);
     DoBeforeArchive(Apackage);
     DoBeforeArchive(Apackage);
+    AddPackageMacrosToDictionary(APackage, APackage.Dictionary);
     L:=TStringList.Create;
     L:=TStringList.Create;
     L.Sorted:=true;
     L.Sorted:=true;
     L.Duplicates:=dupIgnore;
     L.Duplicates:=dupIgnore;
@@ -6770,19 +6787,26 @@ begin
 {$ifdef HAS_UNIT_ZIPPER}
 {$ifdef HAS_UNIT_ZIPPER}
       if not Assigned(ArchiveFilesProc) then
       if not Assigned(ArchiveFilesProc) then
         begin
         begin
-          FZipFile := TZipper.Create;
-          FZipFile.ZipFiles(A, L);
+          ZipFile := TZipper.Create;
+          try
+            ZipFile.FileName:=A;
+            A := APackage.Dictionary.ReplaceStrings(Defaults.FPrefix);
+            if A <> '' then
+              A:=IncludeTrailingPathDelimiter(A);
+            for i := 0 to L.Count-1 do
+              begin
+                ZipFile.Entries.AddFileEntry(L[i], A+L[i]);
+              end;
+            ZipFile.ZipAllFiles;
+          finally
+            ZipFile.Free;
+          end;
         end
         end
       else
       else
 {$endif HAS_UNIT_ZIPPER}
 {$endif HAS_UNIT_ZIPPER}
         CmdArchiveFiles(L,A);
         CmdArchiveFiles(L,A);
     Finally
     Finally
       L.Free;
       L.Free;
-
-{$ifdef HAS_UNIT_ZIPPER}
-      if not Assigned(ArchiveFilesProc) then
-        FreeAndNil(FZipFile);
-{$endif HAS_UNIT_ZIPPER}
     end;
     end;
     DoAfterArchive(Apackage);
     DoAfterArchive(Apackage);
   Finally
   Finally