BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed

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 <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Feng, Bob C 2019-09-04 15:53:37 +08:00
parent 373298ca0d
commit 000ab98574
2 changed files with 12 additions and 1 deletions

View File

@ -441,7 +441,7 @@ class PlatformAutoGen(AutoGen):
File=self.MetaFile, File=self.MetaFile,
ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n" ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"
% NoDatumTypePcdListString) % NoDatumTypePcdListString)
self._NonDynamicPcdList = self._NonDynaPcdList_ self._NonDynamicPcdList = sorted(self._NonDynaPcdList_)
self._DynamicPcdList = self._DynaPcdList_ self._DynamicPcdList = self._DynaPcdList_
def SortDynamicPcd(self): def SortDynamicPcd(self):
@ -704,6 +704,7 @@ class PlatformAutoGen(AutoGen):
self._DynamicPcdList.extend(list(UnicodePcdArray)) self._DynamicPcdList.extend(list(UnicodePcdArray))
self._DynamicPcdList.extend(list(HiiPcdArray)) self._DynamicPcdList.extend(list(HiiPcdArray))
self._DynamicPcdList.extend(list(OtherPcdArray)) self._DynamicPcdList.extend(list(OtherPcdArray))
self._DynamicPcdList.sort()
allskuset = [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName, Sku) in pcd.SkuInfoList.items()] allskuset = [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName, Sku) in pcd.SkuInfoList.items()]
for pcd in self._DynamicPcdList: for pcd in self._DynamicPcdList:
if len(pcd.SkuInfoList) == 1: if len(pcd.SkuInfoList) == 1:

View File

@ -14,6 +14,7 @@ from Common.Misc import CopyDict,ArrayIndex
import copy import copy
import Common.EdkLogger as EdkLogger import Common.EdkLogger as EdkLogger
from Common.BuildToolError import OPTION_VALUE_INVALID from Common.BuildToolError import OPTION_VALUE_INVALID
from Common.caching import cached_property
StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$')
## PcdClassObject ## PcdClassObject
@ -227,6 +228,15 @@ class PcdClassObject(object):
def __hash__(self): def __hash__(self):
return hash((self.TokenCName, self.TokenSpaceGuidCName)) 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): def sharedcopy(self,new_pcd):
new_pcd.TokenCName = self.TokenCName new_pcd.TokenCName = self.TokenCName
new_pcd.TokenSpaceGuidCName = self.TokenSpaceGuidCName new_pcd.TokenSpaceGuidCName = self.TokenSpaceGuidCName