BaseTools: Enhance tool to generate EFI_HII_IIBT_DUPLICATE image block

When *.IDF file contains multiple definitions of image which point to the
same image, current build tool generates multiple image blocks which
contain the same image content.
This patch enhance tool to generate EFI_HII_IIBT_DUPLICATE image blocks
for non-first images for such case, to save the HII package size.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=145
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yonghong Zhu 2016-10-17 17:43:45 +08:00
parent 09bd67f095
commit 6d034a2add
1 changed files with 14 additions and 0 deletions

View File

@ -1639,6 +1639,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
PaletteBuffer = pack('x')
BufferStr = ''
PaletteStr = ''
FileDict = {}
for Idf in ImageFiles.ImageFilesDict:
if ImageFiles.ImageFilesDict[Idf]:
for FileObj in ImageFiles.ImageFilesDict[Idf]:
@ -1663,6 +1664,19 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
else:
Line = DEFINE_STR + ' ' + ID + ' ' * (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n'
if File not in FileDict:
FileDict[File] = Index
else:
DuplicateBlock = pack('B', EFI_HII_IIBT_DUPLICATE)
DuplicateBlock += pack('H', FileDict[File])
ImageBuffer += DuplicateBlock
BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
TempBufferList = AscToHexList(DuplicateBlock)
BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')
StringH.Append(Line)
Index += 1
continue
TmpFile = open(File.Path, 'rb')
Buffer = TmpFile.read()
TmpFile.close()