BaseTools: Report more clear error message when PCD type mismatch

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>
This commit is contained in:
Yunhua Feng 2018-05-16 13:59:59 +08:00 committed by Yonghong Zhu
parent 5a444dfd7c
commit a253d217ee
1 changed files with 12 additions and 8 deletions

View File

@ -2336,7 +2336,7 @@ class PlatformAutoGen(AutoGen):
# @param ToPcd The PCD to be overrided # @param ToPcd The PCD to be overrided
# @param FromPcd The PCD overrideing from # @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. # 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 # at this point, ToPcd.Type has the type found from dependent
@ -2356,10 +2356,12 @@ class PlatformAutoGen(AutoGen):
ToPcd.Type = FromPcd.Type ToPcd.Type = FromPcd.Type
elif ToPcd.Type and FromPcd.Type \ elif ToPcd.Type and FromPcd.Type \
and ToPcd.Type != 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", 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.TokenSpaceGuidCName, TokenCName,
ToPcd.Type, Module, FromPcd.Type), ToPcd.Type, Module, FromPcd.Type, Msg),
File=self.MetaFile) File=self.MetaFile)
if FromPcd.MaxDatumSize: if FromPcd.MaxDatumSize:
@ -2420,7 +2422,7 @@ class PlatformAutoGen(AutoGen):
# #
# @retval PCD_list The list PCDs with settings from platform # @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 each PCD in module
for Name, Guid in Pcds: for Name, Guid in Pcds:
PcdInModule = Pcds[Name, Guid] PcdInModule = Pcds[Name, Guid]
@ -2430,7 +2432,7 @@ class PlatformAutoGen(AutoGen):
else: else:
PcdInPlatform = None PcdInPlatform = None
# then override the settings if any # 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 # resolve the VariableGuid value
for SkuId in PcdInModule.SkuInfoList: for SkuId in PcdInModule.SkuInfoList:
Sku = PcdInModule.SkuInfoList[SkuId] Sku = PcdInModule.SkuInfoList[SkuId]
@ -2462,7 +2464,7 @@ class PlatformAutoGen(AutoGen):
Flag = True Flag = True
break break
if Flag: 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 # use PCD value to calculate the MaxDatumSize when it is not specified
for Name, Guid in Pcds: for Name, Guid in Pcds:
Pcd = Pcds[Name, Guid] Pcd = Pcds[Name, Guid]
@ -3675,15 +3677,17 @@ class ModuleAutoGen(AutoGen):
Pcds = OrderedDict() Pcds = OrderedDict()
if not self.IsLibrary: if not self.IsLibrary:
# get PCDs from dependent libraries # get PCDs from dependent libraries
self._LibraryPcdList = []
for Library in self.DependentLibraryList: for Library in self.DependentLibraryList:
PcdsInLibrary = OrderedDict()
self.UpdateComments(self._PcdComments, Library.PcdComments) self.UpdateComments(self._PcdComments, Library.PcdComments)
for Key in Library.Pcds: for Key in Library.Pcds:
# skip duplicated PCDs # skip duplicated PCDs
if Key in self.Module.Pcds or Key in Pcds: if Key in self.Module.Pcds or Key in Pcds:
continue continue
Pcds[Key] = copy.copy(Library.Pcds[Key]) Pcds[Key] = copy.copy(Library.Pcds[Key])
# apply PCD settings from platform PcdsInLibrary[Key] = Pcds[Key]
self._LibraryPcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, Pcds) self._LibraryPcdList.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, PcdsInLibrary, Library=Library))
else: else:
self._LibraryPcdList = [] self._LibraryPcdList = []
return self._LibraryPcdList return self._LibraryPcdList