]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools: Replace StandardError with Expression
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CompressSection.py
index 98532ed8e698d769106d8a57de24fa9f57585f8f..4ae14f27b3e132581349015e70bdf02dd183c7b2 100644 (file)
@@ -21,6 +21,7 @@ import subprocess
 import Common.LongFilePathOs as os\r
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
 from CommonDataClass.FdfClass import CompressSectionClassObject\r
+from Common.DataType import *\r
 \r
 ## generate compress section\r
 #\r
@@ -55,44 +56,41 @@ class CompressSection (CompressSectionClassObject) :
     #\r
     def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r
 \r
-        if FfsInf != None:\r
+        if FfsInf is not None:\r
             self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r
             self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
 \r
         SectFiles = tuple()\r
+        SectAlign = []\r
         Index = 0\r
         MaxAlign = None\r
         for Sect in self.SectionList:\r
             Index = Index + 1\r
             SecIndex = '%s.%d' %(SecNum, Index)\r
             ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r
-            if AlignValue != None:\r
-                if MaxAlign == None:\r
+            if AlignValue is not None:\r
+                if MaxAlign is None:\r
                     MaxAlign = AlignValue\r
                 if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r
                     MaxAlign = AlignValue\r
             if ReturnSectList != []:\r
-                if AlignValue == None:\r
+                if AlignValue is None:\r
                     AlignValue = "1"\r
                 for FileData in ReturnSectList:\r
                     SectFiles += (FileData,)\r
-\r
-        if MaxAlign != None:\r
-            if self.Alignment == None:\r
-                self.Alignment = MaxAlign\r
-            else:\r
-                if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment):\r
-                    self.Alignment = MaxAlign\r
+                    SectAlign.append(AlignValue)\r
 \r
         OutputFile = OutputPath + \\r
                      os.sep     + \\r
                      ModuleName + \\r
-                     'SEC'      + \\r
+                     SUP_MODULE_SEC      + \\r
                      SecNum     + \\r
                      Ffs.SectionSuffix['COMPRESS']\r
         OutputFile = os.path.normpath(OutputFile)\r
+        DummyFile = OutputFile + '.dummy'\r
+        GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)\r
 \r
-        GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],\r
                                              CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r
         OutputFileList = []\r
         OutputFileList.append(OutputFile)\r