diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-04-01 15:20:51 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2016-04-05 13:24:04 +0800 |
commit | cfaaf99bdd412139ca7b9724e678429b2f2fb45f (patch) | |
tree | eb4e91a94a1978774da18d159d872fd69b1838c7 /BaseTools/Source/Python/GenFds/FfsFileStatement.py | |
parent | 15f69ddfc9506dc597b771f8514161c1289a0216 (diff) | |
download | edk2-cfaaf99bdd412139ca7b9724e678429b2f2fb45f.tar.gz edk2-cfaaf99bdd412139ca7b9724e678429b2f2fb45f.tar.bz2 edk2-cfaaf99bdd412139ca7b9724e678429b2f2fb45f.zip |
BaseTools/GenFds: Fix the bug for wrong alignment generate for RAW file
When do the multiple raw file support feature, it cause the regression
that the raw file section alignment value was wrongly overridden by the
single raw file. this patch: 1) fix the wrong overridden bug. 2) remove
the duplicate code for combine multiple raw file into one.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsFileStatement.py')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsFileStatement.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index 506789e979..690826bcb9 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -45,6 +45,7 @@ class FileStatement (FileStatementClassObject) : self.CurrentLineContent = None
self.FileName = None
self.InfFileName = None
+ self.SubAlignment = None
## GenFfs() method
#
@@ -94,8 +95,10 @@ class FileStatement (FileStatementClassObject) : elif self.FileName != None:
if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':
- if isinstance(self.FileName, list) and isinstance(self.Alignment, list) and len(self.FileName) == len(self.Alignment):
+ if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):
FileContent = ''
+ MaxAlignIndex = 0
+ MaxAlignValue = 1
for Index, File in enumerate(self.FileName):
try:
f = open(File, 'r+b')
@@ -103,9 +106,12 @@ class FileStatement (FileStatementClassObject) : GenFdsGlobalVariable.ErrorLogger("Error opening RAW file %s." % (File))
Content = f.read()
f.close()
- AlignValue = self.Alignment[Index]
- if AlignValue == None:
- AlignValue = 1
+ AlignValue = 1
+ if self.SubAlignment[Index] != None:
+ AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])
+ if AlignValue > MaxAlignValue:
+ MaxAlignIndex = Index
+ MaxAlignValue = AlignValue
FileContent += Content
if len(FileContent) % AlignValue != 0:
Size = AlignValue - len(FileContent) % AlignValue
@@ -116,10 +122,14 @@ class FileStatement (FileStatementClassObject) : OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')
SaveFileOnChange(OutputRAWFile, FileContent, True)
self.FileName = OutputRAWFile
- if max(self.Alignment):
- self.Alignment = str(max(self.Alignment))
- else:
- self.Alignment = None
+ self.SubAlignment = self.SubAlignment[MaxAlignIndex]
+
+ if self.Alignment and self.SubAlignment:
+ if GenFdsGlobalVariable.GetAlignment (self.Alignment) < GenFdsGlobalVariable.GetAlignment (self.SubAlignment):
+ self.Alignment = self.SubAlignment
+ elif self.SubAlignment:
+ self.Alignment = self.SubAlignment
+
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
#Replace $(SAPCE) with real space
self.FileName = self.FileName.replace('$(SPACE)', ' ')
|