]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: Report more clear error message when PCD type mismatch
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 1e6511cdb5d2eeaddabd862c99c09bf09f2b6a72..cf58abf25184bd917ea144aa15861edae079532a 100644 (file)
@@ -423,6 +423,7 @@ class WorkspaceAutoGen(AutoGen):
                                 PcdInPlatform = Platform.Pcds[key]\r
                                 if PcdInPlatform.Type:\r
                                     BuildData.Pcds[key].Type = PcdInPlatform.Type\r
+                                    BuildData.Pcds[key].Pending = False\r
 \r
                             if BuildData.MetaFile in Platform.Modules:\r
                                 PlatformModule = Platform.Modules[str(BuildData.MetaFile)]\r
@@ -430,6 +431,23 @@ class WorkspaceAutoGen(AutoGen):
                                     PcdInPlatform = PlatformModule.Pcds[key]\r
                                     if PcdInPlatform.Type:\r
                                         BuildData.Pcds[key].Type = PcdInPlatform.Type\r
+                                        BuildData.Pcds[key].Pending = False\r
+                            else:\r
+                                #Pcd used in Library, Pcd Type from reference module if Pcd Type is Pending\r
+                                if BuildData.Pcds[key].Pending:\r
+                                    MGen = ModuleAutoGen(self, BuildData.MetaFile, Target, Toolchain, Arch, self.MetaFile)\r
+                                    if MGen and MGen.IsLibrary:\r
+                                        if MGen in PGen.LibraryAutoGenList:\r
+                                            ReferenceModules = MGen._ReferenceModules\r
+                                            for ReferenceModule in ReferenceModules:\r
+                                                if ReferenceModule.MetaFile in Platform.Modules:\r
+                                                    RefPlatformModule = Platform.Modules[str(ReferenceModule.MetaFile)]\r
+                                                    if key in RefPlatformModule.Pcds:\r
+                                                        PcdInReferenceModule = RefPlatformModule.Pcds[key]\r
+                                                        if PcdInReferenceModule.Type:\r
+                                                            BuildData.Pcds[key].Type = PcdInReferenceModule.Type\r
+                                                            BuildData.Pcds[key].Pending = False\r
+                                                            break\r
 \r
                         if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:\r
                             if BuildData.IsBinaryModule:\r
@@ -2318,7 +2336,7 @@ class PlatformAutoGen(AutoGen):
     #   @param  ToPcd       The PCD to be overrided\r
     #   @param  FromPcd     The PCD overrideing from\r
     #\r
-    def _OverridePcd(self, ToPcd, FromPcd, Module=""):\r
+    def _OverridePcd(self, ToPcd, FromPcd, Module="", Msg="", Library=""):\r
         #\r
         # in case there's PCDs coming from FDF file, which have no type given.\r
         # at this point, ToPcd.Type has the type found from dependent\r
@@ -2338,10 +2356,12 @@ class PlatformAutoGen(AutoGen):
                     ToPcd.Type = FromPcd.Type\r
             elif ToPcd.Type and FromPcd.Type \\r
                 and ToPcd.Type != FromPcd.Type:\r
+                if Library:\r
+                    Module = str(Module) + " 's library file (" + str(Library) + ")"\r
                 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",\r
-                                ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\\r
+                                ExtraData="%s.%s is used as [%s] in module %s, but as [%s] in %s."\\r
                                           % (ToPcd.TokenSpaceGuidCName, TokenCName,\r
-                                             ToPcd.Type, Module, FromPcd.Type),\r
+                                             ToPcd.Type, Module, FromPcd.Type, Msg),\r
                                           File=self.MetaFile)\r
 \r
             if FromPcd.MaxDatumSize:\r
@@ -2402,7 +2422,7 @@ class PlatformAutoGen(AutoGen):
     #\r
     #   @retval PCD_list    The list PCDs with settings from platform\r
     #\r
-    def ApplyPcdSetting(self, Module, Pcds):\r
+    def ApplyPcdSetting(self, Module, Pcds, Library=""):\r
         # for each PCD in module\r
         for Name, Guid in Pcds:\r
             PcdInModule = Pcds[Name, Guid]\r
@@ -2412,7 +2432,7 @@ class PlatformAutoGen(AutoGen):
             else:\r
                 PcdInPlatform = None\r
             # then override the settings if any\r
-            self._OverridePcd(PcdInModule, PcdInPlatform, Module)\r
+            self._OverridePcd(PcdInModule, PcdInPlatform, Module, Msg="DSC PCD sections", Library=Library)\r
             # resolve the VariableGuid value\r
             for SkuId in PcdInModule.SkuInfoList:\r
                 Sku = PcdInModule.SkuInfoList[SkuId]\r
@@ -2444,7 +2464,7 @@ class PlatformAutoGen(AutoGen):
                             Flag = True\r
                             break\r
                 if Flag:\r
-                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)\r
+                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module, Msg="DSC Components Module scoped PCD section", Library=Library)\r
         # use PCD value to calculate the MaxDatumSize when it is not specified\r
         for Name, Guid in Pcds:\r
             Pcd = Pcds[Name, Guid]\r
@@ -3657,15 +3677,17 @@ class ModuleAutoGen(AutoGen):
             Pcds = OrderedDict()\r
             if not self.IsLibrary:\r
                 # get PCDs from dependent libraries\r
+                self._LibraryPcdList = []\r
                 for Library in self.DependentLibraryList:\r
+                    PcdsInLibrary = OrderedDict()\r
                     self.UpdateComments(self._PcdComments, Library.PcdComments)\r
                     for Key in Library.Pcds:\r
                         # skip duplicated PCDs\r
                         if Key in self.Module.Pcds or Key in Pcds:\r
                             continue\r
                         Pcds[Key] = copy.copy(Library.Pcds[Key])\r
-                # apply PCD settings from platform\r
-                self._LibraryPcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, Pcds)\r
+                        PcdsInLibrary[Key] = Pcds[Key]\r
+                    self._LibraryPcdList.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, PcdsInLibrary, Library=Library))\r
             else:\r
                 self._LibraryPcdList = []\r
         return self._LibraryPcdList\r