summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobCF <bob.c.feng@intel.com>2018-10-19 20:00:09 +0800
committerLiming Gao <liming.gao@intel.com>2018-10-25 08:15:14 +0800
commit51d17bb7b0da0d9c9e91c226f1982d7020f43795 (patch)
tree8afe3daad177321e680bdc6bba4cc277fa6c1979
parent951fb2d4e557c5bb0ad1b55c6610f004ee5be56b (diff)
downloadedk2-51d17bb7b0da0d9c9e91c226f1982d7020f43795.tar.gz
edk2-51d17bb7b0da0d9c9e91c226f1982d7020f43795.tar.bz2
edk2-51d17bb7b0da0d9c9e91c226f1982d7020f43795.zip
BaseTool: Filter out unused structure pcds
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>
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 22c756b7a6..d87496f25f 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -276,6 +276,7 @@ class DscBuildData(PlatformBuildClassObject):
self._VpdToolGuid = None
self._MacroDict = None
self.DefaultStores = None
+ self.UsedStructurePcd = None
## handle Override Path of Module
def _HandleOverridePath(self):
@@ -1457,6 +1458,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():
@@ -1552,6 +1554,23 @@ class DscBuildData(PlatformBuildClassObject):
map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])
return Pcds
+ #Filter the StrucutrePcd that is not used by any module in dsc file and fdf file.
+ def FilterStrcturePcd(self, S_pcd_set):
+ if not self.UsedStructurePcd:
+ 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() + self.LibraryInstances + FdfModuleList)
+ for ModuleFile in ModuleSet:
+ ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]
+ AllModulePcds = AllModulePcds | set(ModuleData.Pcds.keys())
+
+ self.UsedStructurePcd = AllModulePcds
+ UnusedStruPcds = set(S_pcd_set.keys()) - self.UsedStructurePcd
+ for (Token, TokenSpaceGuid) in UnusedStruPcds:
+ del S_pcd_set[(Token, TokenSpaceGuid)]
## Retrieve non-dynamic PCD settings
#