mirror of https://github.com/acidanthera/audk.git
BaseTool: Filter out unused structure pcds
V2: Fixed the issue that V1 adds new check to the Pcds in the platform unused library INF files. It breaks the existing platform. V1? The current code handle all the structure pcds even if there is no module or library use them. This patch is going to filter out the unused structure pcds. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
72a1d77694
commit
34e733f200
|
@ -1493,6 +1493,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
else:
|
||||
str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
|
||||
S_pcd_set[Pcd] = str_pcd_obj_str
|
||||
self.FilterStrcturePcd(S_pcd_set)
|
||||
if S_pcd_set:
|
||||
GlobalData.gStructurePcd[self.Arch] = S_pcd_set
|
||||
for stru_pcd in S_pcd_set.values():
|
||||
|
@ -1588,6 +1589,27 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
|
||||
map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
|
||||
return Pcds
|
||||
@cached_property
|
||||
def PlatformUsedPcds(self):
|
||||
FdfInfList = []
|
||||
if GlobalData.gFdfParser:
|
||||
FdfInfList = GlobalData.gFdfParser.Profile.InfList
|
||||
FdfModuleList = [PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) for Inf in FdfInfList]
|
||||
AllModulePcds = set()
|
||||
ModuleSet = set(self._Modules.keys() + FdfModuleList)
|
||||
for ModuleFile in ModuleSet:
|
||||
ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]
|
||||
AllModulePcds = AllModulePcds | ModuleData.PcdsName
|
||||
for ModuleFile in self.LibraryInstances:
|
||||
ModuleData = self._Bdb.CreateBuildObject(ModuleFile, self._Arch, self._Target, self._Toolchain)
|
||||
AllModulePcds = AllModulePcds | ModuleData.PcdsName
|
||||
return AllModulePcds
|
||||
|
||||
#Filter the StrucutrePcd that is not used by any module in dsc file and fdf file.
|
||||
def FilterStrcturePcd(self, S_pcd_set):
|
||||
UnusedStruPcds = set(S_pcd_set.keys()) - self.PlatformUsedPcds
|
||||
for (Token, TokenSpaceGuid) in UnusedStruPcds:
|
||||
del S_pcd_set[(Token, TokenSpaceGuid)]
|
||||
|
||||
## Retrieve non-dynamic PCD settings
|
||||
#
|
||||
|
|
|
@ -792,6 +792,15 @@ class InfBuildData(ModuleBuildClassObject):
|
|||
RetVal.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
|
||||
return RetVal
|
||||
|
||||
@cached_property
|
||||
def PcdsName(self):
|
||||
PcdsName = set()
|
||||
for Type in (MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODULE,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX):
|
||||
RecordList = self._RawData[Type, self._Arch, self._Platform]
|
||||
for TokenSpaceGuid, PcdCName, _, _, _, _, _ in RecordList:
|
||||
PcdsName.add((PcdCName, TokenSpaceGuid))
|
||||
return PcdsName
|
||||
|
||||
## Retrieve build options specific to this module
|
||||
@cached_property
|
||||
def BuildOptions(self):
|
||||
|
|
|
@ -106,6 +106,10 @@ class WorkspaceDatabase(object):
|
|||
return self._CACHE_[Key]
|
||||
|
||||
# check file type
|
||||
BuildObject = self.CreateBuildObject(FilePath, Arch, Target, Toolchain)
|
||||
self._CACHE_[Key] = BuildObject
|
||||
return BuildObject
|
||||
def CreateBuildObject(self,FilePath, Arch, Target, Toolchain):
|
||||
Ext = FilePath.Type
|
||||
if Ext not in self._FILE_TYPE_:
|
||||
return None
|
||||
|
@ -131,7 +135,6 @@ class WorkspaceDatabase(object):
|
|||
Target,
|
||||
Toolchain
|
||||
)
|
||||
self._CACHE_[Key] = BuildObject
|
||||
return BuildObject
|
||||
|
||||
# placeholder for file format conversion
|
||||
|
|
Loading…
Reference in New Issue