* [Patch 1/1] BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed
@ 2019-09-04 7:53 Bob Feng
2019-09-09 6:46 ` [edk2-devel] " Liming Gao
0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2019-09-04 7:53 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao, Steven Shi
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [Patch 1/1] BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed
2019-09-04 7:53 [Patch 1/1] BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed Bob Feng
@ 2019-09-09 6:46 ` Liming Gao
0 siblings, 0 replies; 2+ messages in thread
From: Liming Gao @ 2019-09-09 6:46 UTC (permalink / raw)
To: devel@edk2.groups.io, Feng, Bob C; +Cc: Shi, Steven
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>Bob Feng
>Sent: Wednesday, September 04, 2019 3:54 PM
>To: devel@edk2.groups.io
>Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
><liming.gao@intel.com>; Shi, Steven <steven.shi@intel.com>
>Subject: [edk2-devel] [Patch 1/1] 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>
>---
> 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
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-09 6:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-04 7:53 [Patch 1/1] BaseTools: Sort Pcd settings to make PcdTokenNumber be fixed Bob Feng
2019-09-09 6:46 ` [edk2-devel] " Liming Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox