]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/UPT: Fix an issue of adding Event twice
authorHess Chen <hesheng.chen@intel.com>
Tue, 7 Mar 2017 08:01:25 +0000 (16:01 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 9 Mar 2017 07:07:06 +0000 (15:07 +0800)
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>
BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py

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