diff options
author | Feng, Bob C <bob.c.feng@intel.com> | 2018-11-01 22:57:08 +0800 |
---|---|---|
committer | BobCF <bob.c.feng@intel.com> | 2018-12-07 10:03:02 +0800 |
commit | 34e733f2000cfad7645651fac9ab79a237b95481 (patch) | |
tree | b83ddd7831a57137fe2377b4f94090da59256a70 /BaseTools | |
parent | 72a1d77694d51914c0dd6aa97dbfa58634b0a4a5 (diff) | |
download | edk2-34e733f2000cfad7645651fac9ab79a237b95481.zip edk2-34e733f2000cfad7645651fac9ab79a237b95481.tar.gz edk2-34e733f2000cfad7645651fac9ab79a237b95481.tar.bz2 |
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>
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/Python/Workspace/DscBuildData.py | 22 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/InfBuildData.py | 9 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 5 |
3 files changed, 35 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 080e314..28da5ea 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -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
#
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 44d44d2..d10cfea 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -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):
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 3bb287b..c41922f 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -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
|