]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/WorkspaceCommon.py
BaseTools: Various typo
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / WorkspaceCommon.py
index 713c1ddbddc990313d7b631c5e65ba4d8501d71a..b79280bc2e839c754eb5a83a69c9997212f93a50 100644 (file)
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import absolute_import\r
 from collections import OrderedDict, defaultdict\r
 from Common.DataType import SUP_MODULE_USER_DEFINED\r
-from BuildClassObject import LibraryClassObject\r
+from .BuildClassObject import LibraryClassObject\r
 import Common.GlobalData as GlobalData\r
 from Workspace.BuildClassObject import StructurePcd\r
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE\r
 from Common.BuildToolError import OPTION_MISSING\r
 from Common.BuildToolError import BUILD_ERROR\r
 \r
-class OrderedListDict(OrderedDict, defaultdict):\r
+class OrderedListDict(OrderedDict):\r
     def __init__(self, *args, **kwargs):\r
         super(OrderedListDict, self).__init__(*args, **kwargs)\r
         self.default_factory = list\r
 \r
+    def __missing__(self, key):\r
+        self[key] = Value = self.default_factory()\r
+        return Value\r
+\r
 ## Get all packages from platform for specified arch, target and toolchain\r
 #\r
 #  @param Platform: DscBuildData instance\r
@@ -53,7 +58,7 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
 #  @retval: A dictionary contains instances of PcdClassObject with key (PcdCName, TokenSpaceGuid)\r
 #  @retval: A dictionary contains real GUIDs of TokenSpaceGuid\r
 #\r
-def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPkgs):\r
+def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, additionalPkgs):\r
     PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain)\r
     PkgList = set(PkgList)\r
     PkgList |= additionalPkgs\r
@@ -85,10 +90,7 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPk
 #  @retval: List of dependent libraries which are InfBuildData instances\r
 #\r
 def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):\r
-    if Module.AutoGenVersion >= 0x00010005:\r
-        return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain)\r
-    else:\r
-        return _ResolveLibraryReference(Module, Platform)\r
+    return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain)\r
 \r
 def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain, FileName = '', EdkLogger = None):\r
     ModuleType = Module.ModuleType\r
@@ -123,13 +125,10 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
         for LibraryClassName in M.LibraryClasses:\r
             if LibraryClassName not in LibraryInstance:\r
                 # override library instance for this module\r
-                if LibraryClassName in Platform.Modules[str(Module)].LibraryClasses:\r
-                    LibraryPath = Platform.Modules[str(Module)].LibraryClasses[LibraryClassName]\r
-                else:\r
-                    LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType]\r
-                if LibraryPath is None or LibraryPath == "":\r
-                    LibraryPath = M.LibraryClasses[LibraryClassName]\r
-                    if LibraryPath is None or LibraryPath == "":\r
+                LibraryPath = Platform.Modules[str(Module)].LibraryClasses.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleType])\r
+                if LibraryPath is None:\r
+                    LibraryPath = M.LibraryClasses.get(LibraryClassName)\r
+                    if LibraryPath is None:\r
                         if FileName:\r
                             EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
                                             "Instance of library class [%s] is not found" % LibraryClassName,\r
@@ -248,32 +247,8 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
             SortedLibraryList.append(Item)\r
 \r
     #\r
-    # Build the list of constructor and destructir names\r
+    # Build the list of constructor and destructor names\r
     # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order\r
     #\r
     SortedLibraryList.reverse()\r
     return SortedLibraryList\r
-\r
-def _ResolveLibraryReference(Module, Platform):\r
-    LibraryConsumerList = [Module]\r
-\r
-    # "CompilerStub" is a must for Edk modules\r
-    if Module.Libraries:\r
-        Module.Libraries.append("CompilerStub")\r
-    LibraryList = []\r
-    while len(LibraryConsumerList) > 0:\r
-        M = LibraryConsumerList.pop()\r
-        for LibraryName in M.Libraries:\r
-            Library = Platform.LibraryClasses[LibraryName, ':dummy:']\r
-            if Library is None:\r
-                for Key in Platform.LibraryClasses.data:\r
-                    if LibraryName.upper() == Key.upper():\r
-                        Library = Platform.LibraryClasses[Key, ':dummy:']\r
-                        break\r
-                if Library is None:\r
-                    continue\r
-\r
-            if Library not in LibraryList:\r
-                LibraryList.append(Library)\r
-                LibraryConsumerList.append(Library)\r
-    return LibraryList\r