Browse Source

Cleanup: TSetupFileLocationEntry contained a few things which Setup doesn't need and are only for the compiler. Keep those in a separate record and companion list.

Martijn Laan 4 months ago
parent
commit
00d335b7ef
2 changed files with 38 additions and 23 deletions
  1. 35 17
      Projects/Src/Compiler.SetupCompiler.pas
  2. 3 6
      Projects/Src/Shared.Struct.pas

+ 35 - 17
Projects/Src/Compiler.SetupCompiler.pas

@@ -87,6 +87,7 @@ type
     UninstallRunEntries: TList;
 
     FileLocationEntryFilenames: THashStringList;
+    FileLocationEntryExtraInfos: TList;
     WarningsList: THashStringList;
     ExpectedCustomMessageNames: TStringList;
     MissingMessagesWarning, MissingRunOnceIdsWarning, MissingRunOnceIds, NotRecognizedMessagesWarning, UsedUserAreasWarning: Boolean;
@@ -307,6 +308,14 @@ type
     Name, Command: String;
   end;
 
+  TFileLocationSign = (fsNoSetting, fsYes, fsOnce, fsCheck);
+  PFileLocationEntryExtraInfo = ^TFileLocationEntryExtraInfo;
+  TFileLocationEntryExtraInfo = packed record
+    Flags: set of (floVersionInfoNotValid, floIsUninstExe, floApplyTouchDateTime,
+      floSolidBreak);
+    Sign: TFileLocationSign;
+  end;
+
 var
   ZipInitialized, BzipInitialized, LZMAInitialized: Boolean;
   PreprocessorInitialized: Boolean;
@@ -362,6 +371,7 @@ begin
   RunEntries := TLowFragList.Create;
   UninstallRunEntries := TLowFragList.Create;
   FileLocationEntryFilenames := THashStringList.Create;
+  FileLocationEntryExtraInfos := TLowFragList.Create;
   WarningsList := THashStringList.Create;
   WarningsList.IgnoreDuplicates := True;
   ExpectedCustomMessageNames := TStringList.Create;
@@ -409,6 +419,7 @@ begin
   UsedUserAreas.Free;
   ExpectedCustomMessageNames.Free;
   WarningsList.Free;
+  FileLocationEntryExtraInfos.Free;
   FileLocationEntryFilenames.Free;
   UninstallRunEntries.Free;
   RunEntries.Free;
@@ -4517,7 +4528,7 @@ const
     'uninsnosharedfileprompt', 'createallsubdirs', '32bit', '64bit',
     'solidbreak', 'setntfscompression', 'unsetntfscompression',
     'sortfilesbyname', 'gacinstall', 'sign', 'signonce', 'signcheck');
-  SignFlags: array[TSetupFileLocationSign] of String = (
+  SignFlags: array[TFileLocationSign] of String = (
     '', 'sign', 'signonce', 'signcheck');
   AttribsFlags: array[0..3] of PChar = (
     'readonly', 'hidden', 'system', 'notcontentindexed');
@@ -4529,12 +4540,13 @@ var
   Values: array[TParam] of TParamValue;
   NewFileEntry, PrevFileEntry: PSetupFileEntry;
   NewFileLocationEntry: PSetupFileLocationEntry;
+  NewFileLocationEntryExtraInfo: PFileLocationEntryExtraInfo;
   VersionNumbers: TFileVersionNumbers;
   SourceWildcard, ADestDir, ADestName, AInstallFontName, AStrongAssemblyName: String;
   AExcludes: TStringList;
   ReadmeFile, ExternalFile, SourceIsWildcard, RecurseSubdirs,
     AllowUnsafeFiles, Touch, NoCompression, NoEncryption, SolidBreak: Boolean;
-  Sign: TSetupFileLocationSign;
+  Sign: TFileLocationSign;
 type
   PFileListRec = ^TFileListRec;
   TFileListRec = record
@@ -4763,8 +4775,8 @@ type
     end;
   end;
 
-  procedure ApplyNewSign(var Sign: TSetupFileLocationSign;
-    const NewSign: TSetupFileLocationSign; const ErrorMessage: String);
+  procedure ApplyNewSign(var Sign: TFileLocationSign;
+    const NewSign: TFileLocationSign; const ErrorMessage: String);
   begin
     if not (Sign in [fsNoSetting, NewSign]) then
       AbortCompileFmt(ErrorMessage,
@@ -4822,31 +4834,34 @@ type
           J := FileLocationEntryFilenames.CaseInsensitiveIndexOf(SourceFile);
           if J <> -1 then begin
             NewFileLocationEntry := FileLocationEntries[J];
+            NewFileLocationEntryExtraInfo := FileLocationEntryExtraInfos[J];
             NewFileEntry^.LocationEntry := J;
           end;
         end;
         if NewFileLocationEntry = nil then begin
           NewFileLocationEntry := AllocMem(SizeOf(TSetupFileLocationEntry));
+          NewFileLocationEntryExtraInfo := AllocMem(SizeOf(TFileLocationEntryExtraInfo));
           SetupHeader.CompressMethod := CompressMethod;
           FileLocationEntries.Add(NewFileLocationEntry);
+          FileLocationEntryExtraInfos.Add(NewFileLocationEntryExtraInfo);
           FileLocationEntryFilenames.Add(SourceFile);
           NewFileEntry^.LocationEntry := FileLocationEntries.Count-1;
           if NewFileEntry^.FileType = ftUninstExe then
-            Include(NewFileLocationEntry^.Flags, floIsUninstExe);
+            Include(NewFileLocationEntryExtraInfo^.Flags, floIsUninstExe);
           Inc6464(TotalBytesToCompress, FileListRec.Size);
           if SetupHeader.CompressMethod <> cmStored then
             Include(NewFileLocationEntry^.Flags, floChunkCompressed);
           if shEncryptionUsed in SetupHeader.Options then
             Include(NewFileLocationEntry^.Flags, floChunkEncrypted);
           if SolidBreak and UseSolidCompression then begin
-            Include(NewFileLocationEntry^.Flags, floSolidBreak);
+            Include(NewFileLocationEntryExtraInfo^.Flags, floSolidBreak);
             { If the entry matches multiple files, it should only break prior
               to compressing the first one }
             SolidBreak := False;
           end;
         end;
         if Touch then
-          Include(NewFileLocationEntry^.Flags, floApplyTouchDateTime);
+          Include(NewFileLocationEntryExtraInfo^.Flags, floApplyTouchDateTime);
         { Note: "nocompression"/"noencryption" on one file makes all merged
           copies uncompressed/unencrypted too }
         if NoCompression then
@@ -4854,7 +4869,7 @@ type
         if NoEncryption then
           Exclude(NewFileLocationEntry^.Flags, floChunkEncrypted);
         if Sign <> fsNoSetting then
-          ApplyNewSign(NewFileLocationEntry.Sign, Sign, SCompilerParamErrorBadCombo3);
+          ApplyNewSign(NewFileLocationEntryExtraInfo.Sign, Sign, SCompilerParamErrorBadCombo3);
       end
       else begin
         NewFileEntry^.SourceFilename := SourceFile;
@@ -4863,7 +4878,8 @@ type
 
       { Read version info }
       if not ExternalFile and not(foIgnoreVersion in NewFileEntry^.Options) and
-         (NewFileLocationEntry^.Flags * [floVersionInfoValid, floVersionInfoNotValid] = []) then begin
+         (NewFileLocationEntry^.Flags * [floVersionInfoValid] = []) and
+         (NewFileLocationEntryExtraInfo^.Flags * [floVersionInfoNotValid] = []) then begin
         AddStatus(Format(SCompilerStatusFilesVerInfo, [SourceFile]));
         if GetVersionNumbers(SourceFile, VersionNumbers) then begin
           NewFileLocationEntry^.FileVersionMS := VersionNumbers.MS;
@@ -4871,7 +4887,7 @@ type
           Include(NewFileLocationEntry^.Flags, floVersionInfoValid);
         end
         else
-          Include(NewFileLocationEntry^.Flags, floVersionInfoNotValid);
+          Include(NewFileLocationEntryExtraInfo^.Flags, floVersionInfoNotValid);
       end;
 
       { Safety checks }
@@ -6820,6 +6836,7 @@ var
     ChunkCompressed: Boolean;
     I: Integer;
     FL: PSetupFileLocationEntry;
+    FLExtraInfo: PFileLocationEntryExtraInfo;
     FT: TFileTime;
     SourceFile: TFile;
     SignatureAddress, SignatureSize: Cardinal;
@@ -6848,10 +6865,11 @@ var
 
       for I := 0 to FileLocationEntries.Count-1 do begin
         FL := FileLocationEntries[I];
+        FLExtraInfo := FileLocationEntryExtraInfos[I];
 
-        if FL.Sign <> fsNoSetting then begin
+        if FLExtraInfo.Sign <> fsNoSetting then begin
           var SignatureFound := False;
-          if FL.Sign in [fsOnce, fsCheck] then begin
+          if FLExtraInfo.Sign in [fsOnce, fsCheck] then begin
             { Check the file for a signature }
             SourceFile := TFile.Create(FileLocationEntryFilenames[I],
               fdOpenExisting, faRead, fsRead);
@@ -6866,13 +6884,13 @@ var
             end;
           end;
 
-          if (FL.Sign = fsYes) or ((FL.Sign = fsOnce) and not SignatureFound) then begin
+          if (FLExtraInfo.Sign = fsYes) or ((FLExtraInfo.Sign = fsOnce) and not SignatureFound) then begin
             AddStatus(Format(SCompilerStatusSigningSourceFile, [FileLocationEntryFilenames[I]]));
             Sign(FileLocationEntryFilenames[I]);
             CallIdleProc;
-          end else if FL.Sign = fsOnce then
+          end else if FLExtraInfo.Sign = fsOnce then
             AddStatus(Format(SCompilerStatusSourceFileAlreadySigned, [FileLocationEntryFilenames[I]]))
-          else if (FL.Sign = fsCheck) and not SignatureFound then
+          else if (FLExtraInfo.Sign = fsCheck) and not SignatureFound then
             AbortCompileFmt(SCompilerSourceFileNotSigned, [FileLocationEntryFilenames[I]]);
         end;
 
@@ -6896,7 +6914,7 @@ var
               - the compression or encryption status of this file is
                 different from the previous file(s) in the chunk }
             if not UseSolidCompression or
-               (floSolidBreak in FL.Flags) or
+               (floSolidBreak in FLExtraInfo.Flags) or
                (ChunkCompressed <> (floChunkCompressed in FL.Flags)) or
                (CH.ChunkEncrypted <> (floChunkEncrypted in FL.Flags)) then
               FinalizeChunk(CH, I-1);
@@ -6924,7 +6942,7 @@ var
           end
           else
             FileTimeToLocalFileTime(FT, FL.SourceTimeStamp);
-          if floApplyTouchDateTime in FL.Flags then
+          if floApplyTouchDateTime in FLExtraInfo.Flags then
             ApplyTouchDateTime(FL.SourceTimeStamp);
           if TimeStampRounding > 0 then
             Dec64(Integer64(FL.SourceTimeStamp), Mod64(Integer64(FL.SourceTimeStamp), TimeStampRounding * 10000000));

+ 3 - 6
Projects/Src/Shared.Struct.pas

@@ -33,7 +33,7 @@ const
     this file it's recommended you change SetupID. Any change will do (like
     changing the letters or numbers), as long as your format is
     unrecognizable by the standard Inno Setup. }
-  SetupID: TSetupID = 'Inno Setup Setup Data (6.4.2)';
+  SetupID: TSetupID = 'Inno Setup Setup Data (6.4.3)';
   UninstallLogID: array[Boolean] of TUninstallLogID =
     ('Inno Setup Uninstall Log (b)', 'Inno Setup Uninstall Log (b) 64-bit');
   MessagesHdrID: TMessagesHdrID = 'Inno Setup Messages (6.4.0) (u)';
@@ -247,7 +247,6 @@ const
   SetupFileLocationEntryStrings = 0;
   SetupFileLocationEntryAnsiStrings = 0;
 type
-  TSetupFileLocationSign = (fsNoSetting, fsYes, fsOnce, fsCheck);
   PSetupFileLocationEntry = ^TSetupFileLocationEntry;
   TSetupFileLocationEntry = packed record
     FirstSlice, LastSlice: Integer;
@@ -258,10 +257,8 @@ type
     SHA256Sum: TSHA256Digest;
     SourceTimeStamp: TFileTime;
     FileVersionMS, FileVersionLS: DWORD;
-    Flags: set of (floVersionInfoValid, floVersionInfoNotValid, floTimeStampInUTC,
-      floIsUninstExe, floCallInstructionOptimized, floApplyTouchDateTime,
-      floChunkEncrypted, floChunkCompressed, floSolidBreak);
-    Sign: TSetupFileLocationSign;
+    Flags: set of (floVersionInfoValid, floTimeStampInUTC, floCallInstructionOptimized,
+      floChunkEncrypted, floChunkCompressed);
   end;
 const
   SetupIconEntryStrings = 13;