]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/WorkspaceCommon.py
BaseTools: Remove equality operator with None
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / WorkspaceCommon.py
index 60acc914e9d262f6ab15c960ed854ed3a9272f6c..abe34cf9a071ec60cda6b030310c78b1871ebd50 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Common routines used by workspace\r
 #\r
-# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -14,6 +14,8 @@
 from Common.Misc import sdict\r
 from Common.DataType import SUP_MODULE_USER_DEFINED\r
 from BuildClassObject import LibraryClassObject\r
+import Common.GlobalData as GlobalData\r
+from Workspace.BuildClassObject import StructurePcd\r
 \r
 ## Get all packages from platform for specified arch, target and toolchain\r
 #\r
@@ -41,14 +43,28 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
 #  @param Target: Current target\r
 #  @param Toolchain: Current toolchain\r
 #  @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):\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
     DecPcds = {}\r
+    GuidDict = {}\r
     for Pkg in PkgList:\r
+        Guids = Pkg.Guids\r
+        GuidDict.update(Guids)\r
         for Pcd in Pkg.Pcds:\r
-            DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]\r
-    return DecPcds\r
+            PcdCName = Pcd[0]\r
+            PcdTokenName = Pcd[1]\r
+            if GlobalData.MixedPcd:\r
+                for PcdItem in GlobalData.MixedPcd.keys():\r
+                    if (PcdCName, PcdTokenName) in GlobalData.MixedPcd[PcdItem]:\r
+                        PcdCName = PcdItem[0]\r
+                        break\r
+            if (PcdCName, PcdTokenName) not in DecPcds.keys():\r
+                DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]\r
+    return DecPcds, GuidDict\r
 \r
 ## Get all dependent libraries for a module\r
 #\r
@@ -102,16 +118,16 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
                     LibraryPath = PlatformModule.LibraryClasses[LibraryClassName]\r
                 else:\r
                     LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType]\r
-                if LibraryPath == None or LibraryPath == "":\r
+                if LibraryPath is None or LibraryPath == "":\r
                     LibraryPath = M.LibraryClasses[LibraryClassName]\r
-                    if LibraryPath == None or LibraryPath == "":\r
+                    if LibraryPath is None or LibraryPath == "":\r
                         return []\r
 \r
                 LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain]\r
                 # for those forced library instance (NULL library), add a fake library class\r
                 if LibraryClassName.startswith("NULL"):\r
                     LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))\r
-                elif LibraryModule.LibraryClass == None \\r
+                elif LibraryModule.LibraryClass is None \\r
                      or len(LibraryModule.LibraryClass) == 0 \\r
                      or (ModuleType != 'USER_DEFINED'\r
                          and ModuleType not in LibraryModule.LibraryClass[0].SupModList):\r
@@ -123,7 +139,7 @@ def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, To
             else:\r
                 LibraryModule = LibraryInstance[LibraryClassName]\r
 \r
-            if LibraryModule == None:\r
+            if LibraryModule is None:\r
                 continue\r
 \r
             if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:\r
@@ -223,12 +239,12 @@ def _ResolveLibraryReference(Module, Platform):
         M = LibraryConsumerList.pop()\r
         for LibraryName in M.Libraries:\r
             Library = Platform.LibraryClasses[LibraryName, ':dummy:']\r
-            if Library == None:\r
+            if Library is None:\r
                 for Key in Platform.LibraryClasses.data.keys():\r
                     if LibraryName.upper() == Key.upper():\r
                         Library = Platform.LibraryClasses[Key, ':dummy:']\r
                         break\r
-                if Library == None:\r
+                if Library is None:\r
                     continue\r
 \r
             if Library not in LibraryList:\r