]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FfsFileStatement.py
BaseTools: Update FMP Capsule support to follow FDF spec
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsFileStatement.py
index 506789e97981f33d734e8058672fedb0455ab6c2..690826bcb999b672739cea3fdf13188f1b5b11ce 100644 (file)
@@ -45,6 +45,7 @@ class FileStatement (FileStatementClassObject) :
         self.CurrentLineContent = None\r
         self.FileName = None\r
         self.InfFileName = None\r
+        self.SubAlignment = None\r
 \r
     ## GenFfs() method\r
     #\r
@@ -94,8 +95,10 @@ class FileStatement (FileStatementClassObject) :
 \r
         elif self.FileName != None:\r
             if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':\r
-                if isinstance(self.FileName, list) and isinstance(self.Alignment, list) and len(self.FileName) == len(self.Alignment):\r
+                if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):\r
                     FileContent = ''\r
+                    MaxAlignIndex = 0\r
+                    MaxAlignValue = 1\r
                     for Index, File in enumerate(self.FileName):\r
                         try:\r
                             f = open(File, 'r+b')\r
@@ -103,9 +106,12 @@ class FileStatement (FileStatementClassObject) :
                             GenFdsGlobalVariable.ErrorLogger("Error opening RAW file %s." % (File))\r
                         Content = f.read()\r
                         f.close()\r
-                        AlignValue = self.Alignment[Index]\r
-                        if AlignValue == None:\r
-                            AlignValue = 1\r
+                        AlignValue = 1\r
+                        if self.SubAlignment[Index] != None:\r
+                            AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])\r
+                        if AlignValue > MaxAlignValue:\r
+                            MaxAlignIndex = Index\r
+                            MaxAlignValue = AlignValue\r
                         FileContent += Content\r
                         if len(FileContent) % AlignValue != 0:\r
                             Size = AlignValue - len(FileContent) % AlignValue\r
@@ -116,10 +122,14 @@ class FileStatement (FileStatementClassObject) :
                         OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')\r
                         SaveFileOnChange(OutputRAWFile, FileContent, True)\r
                         self.FileName = OutputRAWFile\r
-                        if max(self.Alignment):\r
-                            self.Alignment = str(max(self.Alignment))\r
-                        else:\r
-                            self.Alignment = None\r
+                        self.SubAlignment = self.SubAlignment[MaxAlignIndex]\r
+\r
+                if self.Alignment and self.SubAlignment:\r
+                    if GenFdsGlobalVariable.GetAlignment (self.Alignment) < GenFdsGlobalVariable.GetAlignment (self.SubAlignment):\r
+                        self.Alignment = self.SubAlignment\r
+                elif self.SubAlignment:\r
+                    self.Alignment = self.SubAlignment\r
+\r
             self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
             #Replace $(SAPCE) with real space\r
             self.FileName = self.FileName.replace('$(SPACE)', ' ')\r