]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/InfBuildData.py
BaseTools: Workspace - use built in OrderedDict instead of custom version.
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / InfBuildData.py
index ded8f610c9c190e0cd107830418452b2660408c2..a7ffd43a097284ecb0e228f1837d8c71ad9602ee 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create a database used by build tool\r
 #\r
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -17,6 +17,7 @@ from Common.DataType import *
 from Common.Misc import *\r
 from types import *\r
 from MetaFileParser import *\r
+from collections import OrderedDict\r
 \r
 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject\r
 ## Module build information from INF file\r
@@ -156,7 +157,7 @@ class InfBuildData(ModuleBuildClassObject):
         self._ModuleUnloadImageList = None\r
         self._ConstructorList       = None\r
         self._DestructorList        = None\r
-        self._Defs                  = None\r
+        self._Defs                  = OrderedDict()\r
         self._Binaries              = None\r
         self._Sources               = None\r
         self._LibraryClasses        = None\r
@@ -166,7 +167,7 @@ class InfBuildData(ModuleBuildClassObject):
         self._Ppis                  = None\r
         self._PpiComments           = None\r
         self._Guids                 = None\r
-        self._GuidsUsedByPcd        = sdict()\r
+        self._GuidsUsedByPcd        = OrderedDict()\r
         self._GuidComments          = None\r
         self._Includes              = None\r
         self._Packages              = None\r
@@ -246,8 +247,6 @@ class InfBuildData(ModuleBuildClassObject):
             # items defined _PROPERTY_ don't need additional processing\r
             if Name in self:\r
                 self[Name] = Value\r
-                if self._Defs is None:\r
-                    self._Defs = sdict()\r
                 self._Defs[Name] = Value\r
                 self._Macros[Name] = Value\r
             # some special items in [Defines] section need special treatment\r
@@ -255,7 +254,7 @@ class InfBuildData(ModuleBuildClassObject):
                 if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):\r
                     Name = 'UEFI_SPECIFICATION_VERSION'\r
                 if self._Specification is None:\r
-                    self._Specification = sdict()\r
+                    self._Specification = OrderedDict()\r
                 self._Specification[Name] = GetHexVerValue(Value)\r
                 if self._Specification[Name] is None:\r
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED,\r
@@ -307,8 +306,6 @@ class InfBuildData(ModuleBuildClassObject):
                                         File=self.MetaFile, Line=Record[-1])\r
                     self._CustomMakefile[TokenList[0]] = TokenList[1]\r
             else:\r
-                if self._Defs is None:\r
-                    self._Defs = sdict()\r
                 self._Defs[Name] = Value\r
                 self._Macros[Name] = Value\r
 \r
@@ -337,14 +334,14 @@ class InfBuildData(ModuleBuildClassObject):
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)\r
                 if self._ModuleType == SUP_MODULE_MM_STANDALONE:\r
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)\r
-            if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \\r
+            if 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \\r
                and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:\r
                 self._BuildType = 'UEFI_OPTIONROM'\r
                 if 'PCI_COMPRESS' in self._Defs:\r
                     if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):\r
                         EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile)\r
 \r
-            elif self._Defs and 'UEFI_HII_RESOURCE_SECTION' in self._Defs \\r
+            elif 'UEFI_HII_RESOURCE_SECTION' in self._Defs \\r
                and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':\r
                 self._BuildType = 'UEFI_HII'\r
             else:\r
@@ -398,7 +395,7 @@ class InfBuildData(ModuleBuildClassObject):
 #                                       File=self.MetaFile, Line=LineNo)\r
                     else:\r
                         if self._BuildOptions is None:\r
-                            self._BuildOptions = sdict()\r
+                            self._BuildOptions = OrderedDict()\r
 \r
                         if ToolList[0] in self._TOOL_CODE_:\r
                             Tool = self._TOOL_CODE_[ToolList[0]]\r
@@ -590,11 +587,8 @@ class InfBuildData(ModuleBuildClassObject):
 \r
     ## Retrieve definies other than above ones\r
     def _GetDefines(self):\r
-        if self._Defs is None:\r
-            if self._Header_ is None:\r
-                self._GetHeaderInfo()\r
-            if self._Defs is None:\r
-                self._Defs = sdict()\r
+        if len(self._Defs) == 0 and self._Header_ is None:\r
+            self._GetHeaderInfo()\r
         return self._Defs\r
 \r
     ## Retrieve binary files\r
@@ -688,7 +682,7 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve library classes employed by this module\r
     def _GetLibraryClassUses(self):\r
         if self._LibraryClasses is None:\r
-            self._LibraryClasses = sdict()\r
+            self._LibraryClasses = OrderedDict()\r
             RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 Lib = Record[0]\r
@@ -717,8 +711,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve protocols consumed/produced by this module\r
     def _GetProtocols(self):\r
         if self._Protocols is None:\r
-            self._Protocols = sdict()\r
-            self._ProtocolComments = sdict()\r
+            self._Protocols = OrderedDict()\r
+            self._ProtocolComments = OrderedDict()\r
             RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
@@ -742,8 +736,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve PPIs consumed/produced by this module\r
     def _GetPpis(self):\r
         if self._Ppis is None:\r
-            self._Ppis = sdict()\r
-            self._PpiComments = sdict()\r
+            self._Ppis = OrderedDict()\r
+            self._PpiComments = OrderedDict()\r
             RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
@@ -767,8 +761,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve GUIDs consumed/produced by this module\r
     def _GetGuids(self):\r
         if self._Guids is None:\r
-            self._Guids = sdict()\r
-            self._GuidComments = sdict()\r
+            self._Guids = OrderedDict()\r
+            self._GuidComments = OrderedDict()\r
             RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
@@ -869,8 +863,8 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve PCDs used in this module\r
     def _GetPcds(self):\r
         if self._Pcds is None:\r
-            self._Pcds = sdict()\r
-            self._PcdComments = sdict()\r
+            self._Pcds = OrderedDict()\r
+            self._PcdComments = OrderedDict()\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))\r
@@ -881,7 +875,7 @@ class InfBuildData(ModuleBuildClassObject):
     ## Retrieve build options specific to this module\r
     def _GetBuildOptions(self):\r
         if self._BuildOptions is None:\r
-            self._BuildOptions = sdict()\r
+            self._BuildOptions = OrderedDict()\r
             RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 ToolChainFamily = Record[0]\r
@@ -920,7 +914,7 @@ class InfBuildData(ModuleBuildClassObject):
                                         "'%s' module must specify the type of [Depex] section" % self.ModuleType,\r
                                         File=self.MetaFile)\r
 \r
-            Depex = sdict()\r
+            Depex = OrderedDict()\r
             for Record in RecordList:\r
                 DepexStr = ReplaceMacro(Record[0], self._Macros, False)\r
                 Arch = Record[3]\r
@@ -961,7 +955,7 @@ class InfBuildData(ModuleBuildClassObject):
         if self._DepexExpression is None:\r
             self._DepexExpression = tdict(False, 2)\r
             RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]\r
-            DepexExpression = sdict()\r
+            DepexExpression = OrderedDict()\r
             for Record in RecordList:\r
                 DepexStr = ReplaceMacro(Record[0], self._Macros, False)\r
                 Arch = Record[3]\r
@@ -979,7 +973,7 @@ class InfBuildData(ModuleBuildClassObject):
         return self._GuidsUsedByPcd\r
     ## Retrieve PCD for given type\r
     def _GetPcd(self, Type):\r
-        Pcds = sdict()\r
+        Pcds = OrderedDict()\r
         PcdDict = tdict(True, 4)\r
         PcdList = []\r
         RecordList = self._RawData[Type, self._Arch, self._Platform]\r