Fixed the PCD type choosing issue when it's not found in DSC file.
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Dec 2007 16:46:45 +0000 (16:46 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Dec 2007 16:46:45 +0000 (16:46 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@905 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/EdkIIWorkspaceBuild.py
Source/Python/Common/InfClassObject.py

index 5f9eca7..e5192f5 100755 (executable)
@@ -1255,6 +1255,7 @@ class WorkspaceBuild(object):
     # @retval PcdClassObject An instance for PcdClassObject with all members filled\r
     #\r
     def FindPcd(self, Arch, ModuleName, Name, Guid, Type, PcdsSet):\r
+        NewType = ''\r
         DatumType = ''\r
         Value = ''\r
         Token = ''\r
@@ -1268,17 +1269,25 @@ class WorkspaceBuild(object):
         #\r
         # Second get information from platform database\r
         #\r
+        OwnerPlatform = ''\r
         for Dsc in self.Build[Arch].PlatformDatabase.keys():\r
             Pcds = self.Build[Arch].PlatformDatabase[Dsc].Pcds\r
             if (Name, Guid) in Pcds:\r
+                OwnerPlatform = Dsc\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
+                    if Type != '' and Type != Pcd.Type:\r
+                        ErrorMsg = "PCD %s.%s is declared as [%s] in module\n\t%s\n\n"\\r
+                                   "    But it's used as [%s] in platform\n\t%s"\\r
+                                   % (Guid, Name, Type, ModuleName, Pcd.Type, OwnerPlatform)\r
+                        EdkLogger.error("AutoGen", PARSER_ERROR, ErrorMsg)\r
+\r
+                    NewType = Pcd.Type\r
+                    if NewType.startswith("Dynamic"):\r
+                        if NewType.startswith("DynamicEx"):\r
+                            NewType = "DynamicEx"\r
                         else:\r
-                            Type = "Dynamic"\r
+                            NewType = "Dynamic"\r
                 if Pcd.DatumType != '' and Pcd.DatumType != None:\r
                     DatumType = Pcd.DatumType\r
                 if Pcd.TokenValue != '' and Pcd.TokenValue != None:\r
@@ -1322,41 +1331,63 @@ class WorkspaceBuild(object):
         #\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
+        Pcd = None\r
+        if NewType == '':\r
+            if Type != '':\r
+                PcdTypeList = [Type]\r
             else:\r
-                for PcdType in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:\r
+                PcdTypeList = ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]\r
+\r
+            for Dec in self.Build[Arch].PackageDatabase.keys():\r
+                Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
+                for PcdType in PcdTypeList:\r
                     if (Name, Guid, PcdType) in Pcds:\r
                         Pcd = Pcds[(Name, Guid, PcdType)]\r
+                        NewType = PcdType\r
+                        IsOverrided = True\r
+                        IsFoundInDec = True\r
+                        FoundInDecFile = Dec\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
+                break\r
+        else:\r
+            for Dec in self.Build[Arch].PackageDatabase.keys():\r
+                Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
+                if (Name, Guid, NewType) in Pcds:\r
+                    Pcd = Pcds[(Name, Guid, NewType)]\r
+                    IsOverrided = True\r
+                    IsFoundInDec = True\r
+                    FoundInDecFile = Dec\r
+                    break\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
+            if NewType != '':\r
+                SupportedPcdTypeList = []\r
+                OwnerPackage = ''\r
+                for Dec in self.Build[Arch].PackageDatabase.keys():\r
+                    Pcds = self.Build[Arch].PackageDatabase[Dec].Pcds\r
+                    for PcdType in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:\r
+                        if (Name, Guid, PcdType) in Pcds:\r
+                            SupportedPcdTypeList.append(PcdType)\r
+                            OwnerPackage = Dec\r
+                ErrorMsg = "Only [%s] is supported for Pcd '%s.%s' in package\n\t%s\n\n"\\r
+                           "    But [%s] is specified in platform\n\t%s"\\r
+                           % (", ".join(SupportedPcdTypeList), Guid, Name, OwnerPackage, NewType, OwnerPlatform)\r
+            else:\r
+                ErrorMsg = "Pcd '%s.%s [%s]' defined in module '%s' is not found in any package" % (Guid, Name, NewType, 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, 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
+            Value = Pcd.DefaultValue\r
+            Token = Pcd.TokenValue\r
+            self.UnFoundPcdInDsc[(Guid, Name, NewType, Arch)] = FoundInDecFile\r
+        DatumType = Pcd.DatumType\r
 \r
-        return PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided)\r
+        return PcdClassObject(Name, Guid, NewType, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided)\r
 \r
     ## Find Supportted Module List Of LibraryClass\r
     #\r
index e0eb371..d423fca 100755 (executable)
@@ -485,11 +485,11 @@ class Inf(InfObject):
                 MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC_EX, File), Arch)\r
             \r
             for Item in self.Contents[Arch].Pcd:\r
-                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC, File), Arch)\r
-                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC_EX, File), Arch)\r
-                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FEATURE_FLAG, File), Arch)\r
-                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FIXED_AT_BUILD, File), Arch)\r
-                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_PATCHABLE_IN_MODULE, File), Arch)\r
+                MergeArches(Pcds, self.GetPcdOfInf(Item, "", File), Arch)\r
+                #MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC_EX, File), Arch)\r
+                #MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FEATURE_FLAG, File), Arch)\r
+                #MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FIXED_AT_BUILD, File), Arch)\r
+                #MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_PATCHABLE_IN_MODULE, File), Arch)\r
                 \r
         for Key in Pcds.keys():\r
             Pcd = PcdClass()\r