]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py
BaseTools: Various typo
[mirror_edk2.git] / BaseTools / Source / Python / UPT / PomAdapter / InfPomAlignmentMisc.py
index 7369d64672fbf188ec1bdfb768f36717472c1f8a..68f281b5217a6486c67afacf0408d156010a248e 100644 (file)
@@ -1,11 +1,11 @@
 ## @file InfPomAlignmentMisc.py\r
 # This file contained the routines for InfPomAlignment\r
 #\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, 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
-# distribution. The full text of the license may be found at \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
+# distribution. The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
 #\r
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
@@ -24,6 +24,10 @@ from Library import DataType as DT
 from Library.Misc import ConvertArchList\r
 from Object.POM.ModuleObject import BinaryFileObject\r
 from Object.POM import CommonObject\r
+from Library.StringUtils import FORMAT_INVALID\r
+from Library.Misc import CheckGuidRegFormat\r
+from Logger import StringTable as ST\r
+\r
 \r
 ## GenModuleHeaderUserExt\r
 #\r
@@ -41,7 +45,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
     CustomMakefile = DefineObj.GetCustomMakefile()\r
     UefiHiiResourceSection = DefineObj.GetUefiHiiResourceSection()\r
 \r
-    if EdkReleaseVersion != None:\r
+    if EdkReleaseVersion is not None:\r
         Name = DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION\r
         Value = EdkReleaseVersion.GetValue()\r
         Statement = _GenInfDefineStateMent(EdkReleaseVersion.Comments.GetHeaderComments(),\r
@@ -50,7 +54,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            EdkReleaseVersion.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if Shadow != None:\r
+    if Shadow is not None:\r
         Name = DT.TAB_INF_DEFINES_SHADOW\r
         Value = Shadow.GetValue()\r
         Statement = _GenInfDefineStateMent(Shadow.Comments.GetHeaderComments(),\r
@@ -59,7 +63,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            Shadow.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if DpxSource != None:\r
+    if DpxSource is not None:\r
         Name = DT.TAB_INF_DEFINES_DPX_SOURCE\r
         for DpxSourceItem in DpxSource:\r
             Value = DpxSourceItem[0]\r
@@ -69,7 +73,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                                DpxSourceItem[1].GetTailComments())\r
             DefinesDictNew[Statement] = ArchString\r
 \r
-    if PciVendorId != None:\r
+    if PciVendorId is not None:\r
         Name = DT.TAB_INF_DEFINES_PCI_VENDOR_ID\r
         Value = PciVendorId.GetValue()\r
         Statement = _GenInfDefineStateMent(PciVendorId.Comments.GetHeaderComments(),\r
@@ -78,7 +82,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            PciVendorId.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if PciDeviceId != None:\r
+    if PciDeviceId is not None:\r
         Name = DT.TAB_INF_DEFINES_PCI_DEVICE_ID\r
         Value = PciDeviceId.GetValue()\r
         Statement = _GenInfDefineStateMent(PciDeviceId.Comments.GetHeaderComments(),\r
@@ -87,7 +91,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            PciDeviceId.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if PciClassCode != None:\r
+    if PciClassCode is not None:\r
         Name = DT.TAB_INF_DEFINES_PCI_CLASS_CODE\r
         Value = PciClassCode.GetValue()\r
         Statement = _GenInfDefineStateMent(PciClassCode.Comments.GetHeaderComments(),\r
@@ -96,7 +100,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            PciClassCode.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if PciRevision != None:\r
+    if PciRevision is not None:\r
         Name = DT.TAB_INF_DEFINES_PCI_REVISION\r
         Value = PciRevision.GetValue()\r
         Statement = _GenInfDefineStateMent(PciRevision.Comments.GetHeaderComments(),\r
@@ -105,7 +109,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
                                            PciRevision.Comments.GetTailComments())\r
         DefinesDictNew[Statement] = ArchString\r
 \r
-    if PciCompress != None:\r
+    if PciCompress is not None:\r
         Name = DT.TAB_INF_DEFINES_PCI_COMPRESS\r
         Value = PciCompress.GetValue()\r
         Statement = _GenInfDefineStateMent(PciCompress.Comments.GetHeaderComments(),\r
@@ -134,7 +138,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
 \r
             DefinesDictNew[Statement] = ArchString\r
 \r
-    if UefiHiiResourceSection != None:\r
+    if UefiHiiResourceSection is not None:\r
         Name = DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION\r
         Value = UefiHiiResourceSection.GetValue()\r
         HeaderComment = UefiHiiResourceSection.Comments.GetHeaderComments()\r
@@ -151,10 +155,10 @@ def GenModuleHeaderUserExt(DefineObj, ArchString):
 ## Generate the define statement that will be put into userextension\r
 #  Not support comments.\r
 #\r
-# @param HeaderComment: the original header comment (# not remvoed)\r
+# @param HeaderComment: the original header comment (# not removed)\r
 # @param Name: the definition keyword, should not be empty or none\r
 # @param Value: the definition keyword value\r
-# @param TailComment: the original Tail comment (# not remvoed)\r
+# @param TailComment: the original Tail comment (# not removed)\r
 #\r
 # @return: the regenerated define statement\r
 #\r
@@ -167,7 +171,8 @@ def _GenInfDefineStateMent(HeaderComment, Name, Value, TailComment):
 ## GenBinaryData\r
 #\r
 #\r
-def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, SupArchList, BinaryModule):\r
+def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, \\r
+                  SupArchList, BinaryModule, DecObjList=None):\r
     if BinaryModule:\r
         pass\r
     OriSupArchList = SupArchList\r
@@ -179,17 +184,17 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
         else:\r
             TagName = ''\r
             Family = ''\r
+\r
         FFE = ItemObj.GetFeatureFlagExp()\r
 \r
         #\r
         # If have architecturie specified, then use the specified architecturie;\r
         # If the section tag does not have an architecture modifier or the modifier is "common" (case in-sensitive),\r
-        # and the VALID_ARCHITECTURES comment exists, the list from the VALID_ARCHITECTURES comment \r
+        # and the VALID_ARCHITECTURES comment exists, the list from the VALID_ARCHITECTURES comment\r
         # can be used for the attribute.\r
         # If both not have VALID_ARCHITECTURE comment and no architecturie specified, then keep it empty.\r
-        #        \r
-        SupArchList = ConvertArchList(ItemObj.GetSupArchList())\r
-        SupArchList.sort()\r
+        #\r
+        SupArchList = sorted(ConvertArchList(ItemObj.GetSupArchList()))\r
         if len(SupArchList) == 1 and SupArchList[0] == 'COMMON':\r
             if not (len(OriSupArchList) == 1 or OriSupArchList[0] == 'COMMON'):\r
                 SupArchList = OriSupArchList\r
@@ -200,6 +205,41 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
         FileNameObj.SetFileType(ItemObj.GetType())\r
         FileNameObj.SetFilename(ItemObj.GetFileName())\r
         FileNameObj.SetFeatureFlag(FFE)\r
+        #\r
+        # Get GUID value of the GUID CName in the DEC file\r
+        #\r
+        if ItemObj.GetType() == DT.SUBTYPE_GUID_BINARY_FILE_TYPE:\r
+            if not CheckGuidRegFormat(ItemObj.GetGuidValue()):\r
+                if not DecObjList:\r
+                    if DT.TAB_HORIZON_LINE_SPLIT in ItemObj.GetGuidValue() or \\r
+                        DT.TAB_COMMA_SPLIT in ItemObj.GetGuidValue():\r
+                        Logger.Error("\nMkPkg",\r
+                                 FORMAT_INVALID,\r
+                                 ST.ERR_DECPARSE_DEFINE_PKGGUID,\r
+                                 ExtraData=ItemObj.GetGuidValue(),\r
+                                 RaiseError=True)\r
+                    else:\r
+                        Logger.Error("\nMkPkg",\r
+                                     FORMAT_INVALID,\r
+                                     ST.ERR_UNI_SUBGUID_VALUE_DEFINE_DEC_NOT_FOUND % \\r
+                                     (ItemObj.GetGuidValue()),\r
+                                     RaiseError=True)\r
+                else:\r
+                    for DecObj in DecObjList:\r
+                        for GuidObj in DecObj.GetGuidList():\r
+                            if GuidObj.GetCName() == ItemObj.GetGuidValue():\r
+                                FileNameObj.SetGuidValue(GuidObj.GetGuid())\r
+                                break\r
+\r
+                    if not FileNameObj.GetGuidValue():\r
+                        Logger.Error("\nMkPkg",\r
+                                         FORMAT_INVALID,\r
+                                         ST.ERR_DECPARSE_CGUID_NOT_FOUND % \\r
+                                         (ItemObj.GetGuidValue()),\r
+                                         RaiseError=True)\r
+            else:\r
+                FileNameObj.SetGuidValue(ItemObj.GetGuidValue().strip())\r
+\r
         FileNameObj.SetSupArchList(SupArchList)\r
         FileNameList = [FileNameObj]\r
 \r