]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Report more clear error message when PCD type mismatch
authorYunhua Feng <yunhuax.feng@intel.com>
Wed, 16 May 2018 05:59:59 +0000 (13:59 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 22 May 2018 11:35:28 +0000 (19:35 +0800)
Error message is not clear when PCD type defined in driver's Library
is different with PCD type defined in DSC components or PCD type
defined in DSC PCD section.

Case as below:
DSC:
[PcdsFixedAtBuild]
PcdToken.PcdCName | "A"
[Components]
 TestPkg/TestDriver.inf {
  <PcdsPatchableInModule>
    PcdToken.PcdCName | "B"
 }
Library:
[Pcd]
 PcdToken.PcdCName

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py

index 14d5a94afae2f4166e3adcba01d074f49ce4ece1..cf58abf25184bd917ea144aa15861edae079532a 100644 (file)
@@ -2336,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
@@ -2356,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
@@ -2420,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
@@ -2430,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
@@ -2462,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
@@ -3675,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