public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Report more clear error message when PCD type mismatch
@ 2018-05-20 12:57 Yonghong Zhu
  2018-05-22  5:17 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-05-20 12:57 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yunhua Feng, Liming Gao

From: Yunhua Feng <yunhuax.feng@intel.com>

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 1715101..584971e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2330,11 +2330,11 @@ class PlatformAutoGen(AutoGen):
     ## Override PCD setting (type, value, ...)
     #
     #   @param  ToPcd       The PCD to be overrided
     #   @param  FromPcd     The PCD overrideing from
     #
-    def _OverridePcd(self, ToPcd, FromPcd, Module=""):
+    def _OverridePcd(self, ToPcd, FromPcd, Module="", Msg="", Library=""):
         #
         # in case there's PCDs coming from FDF file, which have no type given.
         # at this point, ToPcd.Type has the type found from dependent
         # package
         #
@@ -2350,14 +2350,16 @@ class PlatformAutoGen(AutoGen):
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
                 if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
             elif ToPcd.Type and FromPcd.Type \
                 and ToPcd.Type != FromPcd.Type:
+                if Library:
+                    Module = str(Module) + " 's library file (" + str(Library) + ")"
                 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",
-                                ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\
+                                ExtraData="%s.%s is used as [%s] in module %s, but as [%s] in %s."\
                                           % (ToPcd.TokenSpaceGuidCName, TokenCName,
-                                             ToPcd.Type, Module, FromPcd.Type),
+                                             ToPcd.Type, Module, FromPcd.Type, Msg),
                                           File=self.MetaFile)
 
             if FromPcd.MaxDatumSize:
                 ToPcd.MaxDatumSize = FromPcd.MaxDatumSize
                 ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize
@@ -2414,21 +2416,21 @@ class PlatformAutoGen(AutoGen):
     #
     #   @param  Module  The module from which the PCD setting will be overrided
     #
     #   @retval PCD_list    The list PCDs with settings from platform
     #
-    def ApplyPcdSetting(self, Module, Pcds):
+    def ApplyPcdSetting(self, Module, Pcds, Library=""):
         # for each PCD in module
         for Name, Guid in Pcds:
             PcdInModule = Pcds[Name, Guid]
             # find out the PCD setting in platform
             if (Name, Guid) in self.Platform.Pcds:
                 PcdInPlatform = self.Platform.Pcds[Name, Guid]
             else:
                 PcdInPlatform = None
             # then override the settings if any
-            self._OverridePcd(PcdInModule, PcdInPlatform, Module)
+            self._OverridePcd(PcdInModule, PcdInPlatform, Module, Msg="DSC PCD sections", Library=Library)
             # resolve the VariableGuid value
             for SkuId in PcdInModule.SkuInfoList:
                 Sku = PcdInModule.SkuInfoList[SkuId]
                 if Sku.VariableGuid == '': continue
                 Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)
@@ -2456,11 +2458,11 @@ class PlatformAutoGen(AutoGen):
                         if PcdItem in Pcds:
                             ToPcd = Pcds[PcdItem]
                             Flag = True
                             break
                 if Flag:
-                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
+                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module, Msg="DSC Components Module scoped PCD section", Library=Library)
         # use PCD value to calculate the MaxDatumSize when it is not specified
         for Name, Guid in Pcds:
             Pcd = Pcds[Name, Guid]
             if Pcd.DatumType == TAB_VOID and not Pcd.MaxDatumSize:
                 Pcd.MaxSizeUserSet = None
@@ -3669,19 +3671,21 @@ class ModuleAutoGen(AutoGen):
     def _GetLibraryPcdList(self):
         if self._LibraryPcdList is None:
             Pcds = OrderedDict()
             if not self.IsLibrary:
                 # get PCDs from dependent libraries
+                self._LibraryPcdList = []
                 for Library in self.DependentLibraryList:
+                    PcdsInLibrary = OrderedDict()
                     self.UpdateComments(self._PcdComments, Library.PcdComments)
                     for Key in Library.Pcds:
                         # skip duplicated PCDs
                         if Key in self.Module.Pcds or Key in Pcds:
                             continue
                         Pcds[Key] = copy.copy(Library.Pcds[Key])
-                # apply PCD settings from platform
-                self._LibraryPcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, Pcds)
+                        PcdsInLibrary[Key] = Pcds[Key]
+                    self._LibraryPcdList.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, PcdsInLibrary, Library=Library))
             else:
                 self._LibraryPcdList = []
         return self._LibraryPcdList
 
     ## Get the GUID value mapping
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: Report more clear error message when PCD type mismatch
  2018-05-20 12:57 [Patch] BaseTools: Report more clear error message when PCD type mismatch Yonghong Zhu
@ 2018-05-22  5:17 ` Zhu, Yonghong
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-05-22  5:17 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org
  Cc: Feng, YunhuaX, Gao, Liming, Zhu, Yonghong

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
Sent: Sunday, May 20, 2018 8:58 PM
To: edk2-devel@lists.01.org
Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [edk2] [Patch] BaseTools: Report more clear error message when PCD type mismatch

From: Yunhua Feng <yunhuax.feng@intel.com>

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 1715101..584971e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2330,11 +2330,11 @@ class PlatformAutoGen(AutoGen):
     ## Override PCD setting (type, value, ...)
     #
     #   @param  ToPcd       The PCD to be overrided
     #   @param  FromPcd     The PCD overrideing from
     #
-    def _OverridePcd(self, ToPcd, FromPcd, Module=""):
+    def _OverridePcd(self, ToPcd, FromPcd, Module="", Msg="", Library=""):
         #
         # in case there's PCDs coming from FDF file, which have no type given.
         # at this point, ToPcd.Type has the type found from dependent
         # package
         #
@@ -2350,14 +2350,16 @@ class PlatformAutoGen(AutoGen):
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
                 if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:
                     ToPcd.Type = FromPcd.Type
             elif ToPcd.Type and FromPcd.Type \
                 and ToPcd.Type != FromPcd.Type:
+                if Library:
+                    Module = str(Module) + " 's library file (" + str(Library) + ")"
                 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",
-                                ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\
+                                ExtraData="%s.%s is used as [%s] in 
+ module %s, but as [%s] in %s."\
                                           % (ToPcd.TokenSpaceGuidCName, TokenCName,
-                                             ToPcd.Type, Module, FromPcd.Type),
+                                             ToPcd.Type, Module, 
+ FromPcd.Type, Msg),
                                           File=self.MetaFile)
 
             if FromPcd.MaxDatumSize:
                 ToPcd.MaxDatumSize = FromPcd.MaxDatumSize
                 ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize @@ -2414,21 +2416,21 @@ class PlatformAutoGen(AutoGen):
     #
     #   @param  Module  The module from which the PCD setting will be overrided
     #
     #   @retval PCD_list    The list PCDs with settings from platform
     #
-    def ApplyPcdSetting(self, Module, Pcds):
+    def ApplyPcdSetting(self, Module, Pcds, Library=""):
         # for each PCD in module
         for Name, Guid in Pcds:
             PcdInModule = Pcds[Name, Guid]
             # find out the PCD setting in platform
             if (Name, Guid) in self.Platform.Pcds:
                 PcdInPlatform = self.Platform.Pcds[Name, Guid]
             else:
                 PcdInPlatform = None
             # then override the settings if any
-            self._OverridePcd(PcdInModule, PcdInPlatform, Module)
+            self._OverridePcd(PcdInModule, PcdInPlatform, Module, 
+ Msg="DSC PCD sections", Library=Library)
             # resolve the VariableGuid value
             for SkuId in PcdInModule.SkuInfoList:
                 Sku = PcdInModule.SkuInfoList[SkuId]
                 if Sku.VariableGuid == '': continue
                 Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path) @@ -2456,11 +2458,11 @@ class PlatformAutoGen(AutoGen):
                         if PcdItem in Pcds:
                             ToPcd = Pcds[PcdItem]
                             Flag = True
                             break
                 if Flag:
-                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
+                    self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], 
+ Module, Msg="DSC Components Module scoped PCD section", 
+ Library=Library)
         # use PCD value to calculate the MaxDatumSize when it is not specified
         for Name, Guid in Pcds:
             Pcd = Pcds[Name, Guid]
             if Pcd.DatumType == TAB_VOID and not Pcd.MaxDatumSize:
                 Pcd.MaxSizeUserSet = None @@ -3669,19 +3671,21 @@ class ModuleAutoGen(AutoGen):
     def _GetLibraryPcdList(self):
         if self._LibraryPcdList is None:
             Pcds = OrderedDict()
             if not self.IsLibrary:
                 # get PCDs from dependent libraries
+                self._LibraryPcdList = []
                 for Library in self.DependentLibraryList:
+                    PcdsInLibrary = OrderedDict()
                     self.UpdateComments(self._PcdComments, Library.PcdComments)
                     for Key in Library.Pcds:
                         # skip duplicated PCDs
                         if Key in self.Module.Pcds or Key in Pcds:
                             continue
                         Pcds[Key] = copy.copy(Library.Pcds[Key])
-                # apply PCD settings from platform
-                self._LibraryPcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, Pcds)
+                        PcdsInLibrary[Key] = Pcds[Key]
+                    
+ self._LibraryPcdList.extend(self.PlatformInfo.ApplyPcdSetting(self.Mod
+ ule, PcdsInLibrary, Library=Library))
             else:
                 self._LibraryPcdList = []
         return self._LibraryPcdList
 
     ## Get the GUID value mapping
--
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-22  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-20 12:57 [Patch] BaseTools: Report more clear error message when PCD type mismatch Yonghong Zhu
2018-05-22  5:17 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox