BaseTools/UPT: Fix an issue of adding Event twice

Fix the issue of after installing a package the Event information is duplicated. The tool checks if the EVENT information existing in UserExtension or not. If already existing in UserExtension the tool will not add additional information.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Hess Chen 2017-03-07 16:01:25 +08:00 committed by Yonghong Zhu
parent 4ae8b492b9
commit e0e1cfcbbb
1 changed files with 12 additions and 6 deletions

View File

@ -2,7 +2,7 @@
# #
# This file contained the logical of transfer package object to INF files. # This file contained the logical of transfer package object to INF files.
# #
# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials are licensed and made available # This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this # under the terms and conditions of the BSD License which accompanies this
@ -169,15 +169,16 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
Content += GenGuidSections(ModuleObject.GetGuidList()) Content += GenGuidSections(ModuleObject.GetGuidList())
Content += GenBinaries(ModuleObject) Content += GenBinaries(ModuleObject)
Content += GenDepex(ModuleObject) Content += GenDepex(ModuleObject)
Content += GenUserExtensions(ModuleObject) __UserExtensionsContent = GenUserExtensions(ModuleObject)
Content += __UserExtensionsContent
if ModuleObject.GetEventList() or ModuleObject.GetBootModeList() or ModuleObject.GetHobList(): if ModuleObject.GetEventList() or ModuleObject.GetBootModeList() or ModuleObject.GetHobList():
Content += '\n' Content += '\n'
# #
# generate [Event], [BootMode], [Hob] section # generate [Event], [BootMode], [Hob] section
# #
Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event') Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event', __UserExtensionsContent)
Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode') Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode', __UserExtensionsContent)
Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob') Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob', __UserExtensionsContent)
SaveFileOnChange(ContainerFile, Content, False) SaveFileOnChange(ContainerFile, Content, False)
if DistHeader.ReadOnly: if DistHeader.ReadOnly:
os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
@ -979,7 +980,7 @@ def GenAsBuiltPcdExSections(ModuleObject):
## GenSpecialSections ## GenSpecialSections
# generate special sections for Event/BootMode/Hob # generate special sections for Event/BootMode/Hob
# #
def GenSpecialSections(ObjectList, SectionName): def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
# #
# generate section # generate section
# #
@ -1002,6 +1003,11 @@ def GenSpecialSections(ObjectList, SectionName):
else: else:
assert(SectionName) assert(SectionName)
Usage = Obj.GetUsage() Usage = Obj.GetUsage()
# If the content already in UserExtensionsContent then ignore
if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
return ''
Statement = ' ' + Type + ' ## ' + Usage Statement = ' ' + Type + ' ## ' + Usage
if CommentStr in ['#\n', '#\n#\n']: if CommentStr in ['#\n', '#\n#\n']:
CommentStr = '#\n#\n#\n' CommentStr = '#\n#\n#\n'