From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 563D72116821C for ; Fri, 19 Oct 2018 05:01:00 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 05:01:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="82765604" Received: from bfeng1-mobl1.ccr.corp.intel.com ([10.239.196.39]) by orsmga008.jf.intel.com with ESMTP; 19 Oct 2018 05:00:59 -0700 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Fri, 19 Oct 2018 20:00:09 +0800 Message-Id: <20181019120009.21856-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Subject: [Patch] BaseTool: Filter out unused structure pcds X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 12:01:01 -0000 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 Cc: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e481ea4f64..31bce16d15 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -274,10 +274,11 @@ class DscBuildData(PlatformBuildClassObject): self._RFCLanguages = None self._ISOLanguages = None self._VpdToolGuid = None self._MacroDict = None self.DefaultStores = None + self.UsedStructurePcd = None ## handle Override Path of Module def _HandleOverridePath(self): RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] for Record in RecordList: @@ -1476,10 +1477,11 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList} 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(): for skuid in SkuIds: if skuid in stru_pcd.SkuOverrideValues: @@ -1571,10 +1573,27 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] 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 # # @param Type PCD type # -- 2.18.0.windows.1