Fixed the PCD type choosing error if it is not defined in DSC file
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Dec 2007 06:56:52 +0000 (06:56 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Dec 2007 06:56:52 +0000 (06:56 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@903 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/EdkIIWorkspaceBuild.py

index 5ece22d..5f9eca7 100755 (executable)
@@ -647,7 +647,7 @@ class WorkspaceBuild(object):
                         Token = Item.Token\r
                         MaxDatumSize = Item.MaxDatumSize\r
                         SkuInfoList = Item.SkuInfoList\r
-                        Pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
+                        Pb.Pcds[(Name, Guid, Type)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
 \r
                 #\r
                 # Add to database\r
@@ -1064,12 +1064,13 @@ class WorkspaceBuild(object):
             WrnMessage = '**** WARNING ****\n'\r
             WrnMessage += 'The following Pcds were not defined in the DSC file: %s\n' % self.DscFileName\r
             WrnMessage += 'The default values were obtained from the DEC file that declares the PCD and the PCD default value\n'\r
-            for (Guid, Name, Arch) in self.UnFoundPcdInDsc:\r
-                Dec = self.UnFoundPcdInDsc[(Guid, Name, Arch)]\r
+            for (Guid, Name, Type, Arch) in self.UnFoundPcdInDsc:\r
+                Dec = self.UnFoundPcdInDsc[(Guid, Name, Type, Arch)]\r
                 Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
-                if (Name, Guid) in Pcds:\r
-                    PcdItemTypeUsed = Pcds[(Name, Guid)].Type\r
-                    DefaultValue = Pcds[(Name, Guid)].DefaultValue\r
+                if (Name, Guid, Type) in Pcds:\r
+                    Pcd = Pcds[(Name, Guid, Type)]\r
+                    PcdItemTypeUsed = Pcd.Type\r
+                    DefaultValue = Pcd.DefaultValue\r
                     WrnMessage += '%s.%s: Defined in file %s, PcdItemType is Pcds%s, DefaultValue is %s\n' % (Guid, Name, Dec, PcdItemTypeUsed, DefaultValue)\r
             EdkLogger.info(WrnMessage)\r
         \r
@@ -1264,43 +1265,29 @@ class WorkspaceBuild(object):
         IsFoundInDec = False\r
         FoundInDecFile = ''\r
         \r
-        #\r
-        # First get information from package database\r
-        #\r
-        for Dec in self.Build[Arch].PackageDatabase.keys():\r
-            Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
-            if (Name, Guid) in Pcds:\r
-                Type = Pcds[(Name, Guid)].Type\r
-                DatumType = Pcds[(Name, Guid)].DatumType\r
-                Value = Pcds[(Name, Guid)].DefaultValue\r
-                Token = Pcds[(Name, Guid)].TokenValue\r
-                \r
-                IsOverrided = True\r
-                IsFoundInDec = True\r
-                FoundInDecFile = Dec\r
-                break\r
-\r
-        if not IsFoundInDec:\r
-            ErrorMsg = "Pcd '%s.%s' defined in module '%s' is not found in any package" % (Guid, Name, ModuleName)\r
-            EdkLogger.error("AutoGen", PARSER_ERROR, ErrorMsg)\r
-\r
         #\r
         # Second get information from platform database\r
         #\r
         for Dsc in self.Build[Arch].PlatformDatabase.keys():\r
             Pcds = self.Build[Arch].PlatformDatabase[Dsc].Pcds\r
             if (Name, Guid) in Pcds:\r
-                if Pcds[(Name, Guid)].Type != '' and Pcds[(Name, Guid)].Type != None:\r
-                    Type = Pcds[(Name, Guid)].Type\r
-                if Pcds[(Name, Guid)].DatumType != '' and Pcds[(Name, Guid)].DatumType != None:\r
-                    DatumType = Pcds[(Name, Guid)].DatumType\r
-                if Pcds[(Name, Guid)].TokenValue != '' and Pcds[(Name, Guid)].TokenValue != None:\r
-                    Token = Pcds[(Name, Guid)].TokenValue\r
-                if Pcds[(Name, Guid)].DefaultValue != '' and Pcds[(Name, Guid)].DefaultValue != None:\r
-                    Value = Pcds[(Name, Guid)].DefaultValue\r
-                if Pcds[(Name, Guid)].MaxDatumSize != '' and Pcds[(Name, Guid)].MaxDatumSize != None:\r
-                    MaxDatumSize = Pcds[(Name, Guid)].MaxDatumSize\r
-                SkuInfoList =  Pcds[(Name, Guid)].SkuInfoList\r
+                Pcd = Pcds[(Name, Guid)]\r
+                if Pcd.Type != '' and Pcd.Type != None:\r
+                    Type = Pcd.Type\r
+                    if Type.startswith("Dynamic"):\r
+                        if Type.startswith("DynamicEx"):\r
+                            Type = "DynamicEx"\r
+                        else:\r
+                            Type = "Dynamic"\r
+                if Pcd.DatumType != '' and Pcd.DatumType != None:\r
+                    DatumType = Pcd.DatumType\r
+                if Pcd.TokenValue != '' and Pcd.TokenValue != None:\r
+                    Token = Pcd.TokenValue\r
+                if Pcd.DefaultValue != '' and Pcd.DefaultValue != None:\r
+                    Value = Pcd.DefaultValue\r
+                if Pcd.MaxDatumSize != '' and Pcd.MaxDatumSize != None:\r
+                    MaxDatumSize = Pcd.MaxDatumSize\r
+                SkuInfoList =  Pcd.SkuInfoList\r
                 \r
                 IsOverrided = True\r
                 IsFoundInDsc = True\r
@@ -1332,11 +1319,40 @@ class WorkspaceBuild(object):
             IsFoundInDsc = True\r
             IsOverrided = True\r
 \r
+        #\r
+        # First get information from package database\r
+        #\r
+        for Dec in self.Build[Arch].PackageDatabase.keys():\r
+            Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
+            if (Name, Guid, Type) in Pcds:\r
+                Pcd = Pcds[(Name, Guid, Type)]\r
+            else:\r
+                for PcdType in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:\r
+                    if (Name, Guid, PcdType) in Pcds:\r
+                        Pcd = Pcds[(Name, Guid, PcdType)]\r
+                        break\r
+                else:\r
+                    continue\r
+\r
+            DatumType = Pcd.DatumType\r
+            if not IsFoundInDsc:\r
+                Value = Pcd.DefaultValue\r
+                Token = Pcd.TokenValue\r
+            IsOverrided = True\r
+            IsFoundInDec = True\r
+            FoundInDecFile = Dec\r
+            break\r
+\r
+\r
+        if not IsFoundInDec:\r
+            ErrorMsg = "Pcd '%s.%s [%s]' defined in module '%s' is not found in any package" % (Guid, Name, Type, ModuleName)\r
+            EdkLogger.error("AutoGen", PARSER_ERROR, ErrorMsg)\r
+\r
         #\r
         # Not found in any platform and fdf\r
         #\r
         if not IsFoundInDsc:\r
-            self.UnFoundPcdInDsc[(Guid, Name, Arch)] = FoundInDecFile\r
+            self.UnFoundPcdInDsc[(Guid, Name, Type, Arch)] = FoundInDecFile\r
             #ErrorMsg = "Pcd '%s.%s' defined in module '%s' is not found in any platform" % (Guid, Name, ModuleName)\r
             #EdkLogger.error("AutoGen", PARSER_ERROR, ErrorMsg)\r
 \r