Fixed an issue which the value of PCD from FDF file is not correct.
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 4 Jan 2008 08:00:02 +0000 (08:00 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 4 Jan 2008 08:00:02 +0000 (08:00 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@943 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/EdkIIWorkspaceBuild.py

index 2f6fa1d..3820fb3 100755 (executable)
@@ -518,7 +518,7 @@ class WorkspaceBuild(object):
     #\r
     # Go through each arch to get all items in DscDatabase to PlatformDatabase\r
     #\r
     #\r
     # Go through each arch to get all items in DscDatabase to PlatformDatabase\r
     #\r
-    def GenPlatformDatabase(self):\r
+    def GenPlatformDatabase(self, PcdsSet={}):\r
         for Dsc in self.DscDatabase.keys():\r
             Platform = self.DscDatabase[Dsc].Platform\r
 \r
         for Dsc in self.DscDatabase.keys():\r
             Platform = self.DscDatabase[Dsc].Platform\r
 \r
@@ -589,6 +589,27 @@ class WorkspaceBuild(object):
                         SkuInfoList = Item.SkuInfoList\r
                         Pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
 \r
                         SkuInfoList = Item.SkuInfoList\r
                         Pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
 \r
+                for (Name, Guid) in PcdsSet:\r
+                    Value = PcdsSet[Name, Guid]\r
+                    for PcdType in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:\r
+                        for Dec in self.Build[Arch].PackageDatabase:\r
+                            Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
+                            if (Name, Guid, PcdType) in Pcds:\r
+                                Pcd = Pcds[(Name, Guid, PcdType)]\r
+                                Type = PcdType\r
+                                DatumType = Pcd.DatumType\r
+                                Token = Pcd.TokenValue\r
+                                MaxDatumSize = Pcd.MaxDatumSize\r
+                                SkuInfoList = Pcd.SkuInfoList\r
+                                Pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
+                                break\r
+                        else:\r
+                            # nothing found\r
+                            continue\r
+                        # found in one package, find next PCD\r
+                        break\r
+                    else:\r
+                        EdkLogger.error("AutoGen", PARSER_ERROR, "PCD is not found in any package", ExtraData="%s.%s" % (Guid, Name))\r
                 #\r
                 # Add to database\r
                 #\r
                 #\r
                 # Add to database\r
                 #\r
@@ -674,7 +695,7 @@ class WorkspaceBuild(object):
     #\r
     # Go through each arch to get all items in InfDatabase to ModuleDatabase\r
     #    \r
     #\r
     # Go through each arch to get all items in InfDatabase to ModuleDatabase\r
     #    \r
-    def GenModuleDatabase(self, PcdsSet = {}, InfList = []):\r
+    def GenModuleDatabase(self, InfList = []):\r
         for Inf in self.InfDatabase.keys():\r
             Module = self.InfDatabase[Inf].Module\r
 \r
         for Inf in self.InfDatabase.keys():\r
             Module = self.InfDatabase[Inf].Module\r
 \r
@@ -840,7 +861,7 @@ class WorkspaceBuild(object):
                         Name = Item.CName\r
                         Guid = Item.TokenSpaceGuidCName\r
                         Type = Item.ItemType\r
                         Name = Item.CName\r
                         Guid = Item.TokenSpaceGuidCName\r
                         Type = Item.ItemType\r
-                        Pb.Pcds[(Name, Guid)] = self.FindPcd(Arch, Inf, Name, Guid, Type, PcdsSet)\r
+                        Pb.Pcds[(Name, Guid)] = self.FindPcd(Arch, Inf, Name, Guid, Type)\r
 \r
                 #\r
                 # Add to database\r
 \r
                 #\r
                 # Add to database\r
@@ -1048,7 +1069,7 @@ class WorkspaceBuild(object):
             for Key in L.Pcds:\r
                 if Key not in Module.Pcds:\r
                     LibPcd = L.Pcds[Key]\r
             for Key in L.Pcds:\r
                 if Key not in Module.Pcds:\r
                     LibPcd = L.Pcds[Key]\r
-                    Module.Pcds[Key] = self.FindPcd(Arch, str(Module), LibPcd.TokenCName, LibPcd.TokenSpaceGuidCName, LibPcd.Type, [])\r
+                    Module.Pcds[Key] = self.FindPcd(Arch, str(Module), LibPcd.TokenCName, LibPcd.TokenSpaceGuidCName, LibPcd.Type)\r
             #\r
             # Merge GUIDs from library instance\r
             #\r
             #\r
             # Merge GUIDs from library instance\r
             #\r
@@ -1085,9 +1106,9 @@ class WorkspaceBuild(object):
         #\r
         # Generate PlatformDatabase, PackageDatabase and ModuleDatabase\r
         #\r
         #\r
         # Generate PlatformDatabase, PackageDatabase and ModuleDatabase\r
         #\r
-        self.GenPlatformDatabase()\r
         self.GenPackageDatabase()\r
         self.GenPackageDatabase()\r
-        self.GenModuleDatabase(PcdsSet, InfList)\r
+        self.GenPlatformDatabase(PcdsSet)\r
+        self.GenModuleDatabase(InfList)\r
         \r
         #\r
         # Update Libraries Of Platform\r
         \r
         #\r
         # Update Libraries Of Platform\r
@@ -1295,11 +1316,10 @@ class WorkspaceBuild(object):
     # @param Name:        Name of Pcd\r
     # @param Guid:        Guid of Pcd\r
     # @param Type:        Type of Pcd\r
     # @param Name:        Name of Pcd\r
     # @param Guid:        Guid of Pcd\r
     # @param Type:        Type of Pcd\r
-    # @param PcdsSet:     A PcdSet get from Fdf parse result\r
     #\r
     # @retval PcdClassObject An instance for PcdClassObject with all members filled\r
     #\r
     #\r
     # @retval PcdClassObject An instance for PcdClassObject with all members filled\r
     #\r
-    def FindPcd(self, Arch, ModuleName, Name, Guid, Type, PcdsSet):\r
+    def FindPcd(self, Arch, ModuleName, Name, Guid, Type):\r
         NewType = ''\r
         DatumType = ''\r
         Value = ''\r
         NewType = ''\r
         DatumType = ''\r
         Value = ''\r
@@ -1368,14 +1388,6 @@ class WorkspaceBuild(object):
                                 IsOverrided = True\r
                                 break\r
 \r
                                 IsOverrided = True\r
                                 break\r
 \r
-        #\r
-        # Last get information from PcdsSet defined by FDF\r
-        #\r
-        if (Name, Guid) in PcdsSet:\r
-            Value = PcdsSet[(Name, Guid)]\r
-            IsFoundInDsc = True\r
-            IsOverrided = True\r
-\r
         #\r
         # First get information from package database\r
         #\r
         #\r
         # First get information from package database\r
         #\r