From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: bob.c.feng@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Wed, 04 Sep 2019 00:53:43 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 00:53:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="187541716" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga006.jf.intel.com with ESMTP; 04 Sep 2019 00:53:41 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Steven Shi Subject: [Patch 1/1] BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed Date: Wed, 4 Sep 2019 15:53:37 +0800 Message-Id: <20190904075337.19764-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2147 This patch is to sort the Pcd settings so that PcdTokenNumber will not change if the platform's Pcd settings are the same. Signed-off-by: Bob Feng Cc: Liming Gao Cc: Steven Shi --- BaseTools/Source/Python/AutoGen/PlatformAutoGen.py | 3 ++- BaseTools/Source/Python/Workspace/BuildClassObject.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py index 565424a95ead..a16918fd3178 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -437,11 +437,11 @@ class PlatformAutoGen(AutoGen): NoDatumTypePcdListString = "\n\t\t".join(NoDatumTypePcdList) EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error", File=self.MetaFile, ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n" % NoDatumTypePcdListString) - self._NonDynamicPcdList = self._NonDynaPcdList_ + self._NonDynamicPcdList = sorted(self._NonDynaPcdList_) self._DynamicPcdList = self._DynaPcdList_ def SortDynamicPcd(self): # # Sort dynamic PCD list to: @@ -700,10 +700,11 @@ class PlatformAutoGen(AutoGen): OtherPcdArray.add(Pcd) del self._DynamicPcdList[:] self._DynamicPcdList.extend(list(UnicodePcdArray)) self._DynamicPcdList.extend(list(HiiPcdArray)) self._DynamicPcdList.extend(list(OtherPcdArray)) + self._DynamicPcdList.sort() allskuset = [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName, Sku) in pcd.SkuInfoList.items()] for pcd in self._DynamicPcdList: if len(pcd.SkuInfoList) == 1: for (SkuName, SkuId) in allskuset: if isinstance(SkuId, str) and eval(SkuId) == 0 or SkuId == 0: diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 5d2bb733752a..db40e3b10c3c 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -12,10 +12,11 @@ import re from collections import OrderedDict from Common.Misc import CopyDict,ArrayIndex import copy import Common.EdkLogger as EdkLogger from Common.BuildToolError import OPTION_VALUE_INVALID +from Common.caching import cached_property StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') ## PcdClassObject # # This Class is used for PcdObject @@ -225,10 +226,19 @@ class PcdClassObject(object): # @retval truple() Key for hash table # def __hash__(self): return hash((self.TokenCName, self.TokenSpaceGuidCName)) + @cached_property + def _fullname(self): + return ".".join((self.TokenSpaceGuidCName,self.TokenCName)) + + def __lt__(self,pcd): + return self._fullname < pcd._fullname + def __gt__(self,pcd): + return self._fullname > pcd._fullname + def sharedcopy(self,new_pcd): new_pcd.TokenCName = self.TokenCName new_pcd.TokenSpaceGuidCName = self.TokenSpaceGuidCName new_pcd.TokenSpaceGuidValue = self.TokenSpaceGuidValue new_pcd.Type = self.Type -- 2.20.1.windows.1