]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CompressSection.py
index 7e126678a2d5950cc4a645a933da59c9d2e4cd83..08ab48669f4546ee0a9c07eaf5ba1936f42eddbd 100644 (file)
@@ -1,9 +1,9 @@
 ## @file\r
 # process compress section generation\r
 #\r
-#  Copyright (c) 2007, Intel Corporation\r
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
-#  All rights reserved. This program and the accompanying materials\r
+#  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 #  http://opensource.org/licenses/bsd-license.php\r
@@ -18,7 +18,7 @@
 from Ffs import Ffs\r
 import Section\r
 import subprocess\r
-import os\r
+import Common.LongFilePathOs as os\r
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
 from CommonDataClass.FdfClass import CompressSectionClassObject\r
 \r
@@ -53,22 +53,31 @@ class CompressSection (CompressSectionClassObject) :
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (Generated file name, section alignment)\r
     #\r
-    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):\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)\r
+            ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\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 is None:\r
+                    AlignValue = "1"\r
                 for FileData in ReturnSectList:\r
-                   SectFiles += (FileData,)\r
-\r
+                    SectFiles += (FileData,)\r
+                    SectAlign.append(AlignValue)\r
 \r
         OutputFile = OutputPath + \\r
                      os.sep     + \\r
@@ -77,9 +86,11 @@ class CompressSection (CompressSectionClassObject) :
                      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
-                                             CompressionType=self.CompTypeDict[self.CompType])\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],\r
+                                             CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r
         OutputFileList = []\r
         OutputFileList.append(OutputFile)\r
         return OutputFileList, self.Alignment\r