summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorBobCF <bob.c.feng@intel.com>2018-09-25 13:20:46 +0800
committerLiming Gao <liming.gao@intel.com>2018-09-26 22:50:36 +0800
commit57ee97c01ca0e81d146600a00885719b84bf1581 (patch)
tree678a1b4e02cfda40bcb6659236f784f9b7e98e76 /BaseTools
parentf27e800a99866543a4bfc36088bcbb7b81f33a99 (diff)
downloadedk2-57ee97c01ca0e81d146600a00885719b84bf1581.tar.gz
edk2-57ee97c01ca0e81d146600a00885719b84bf1581.tar.bz2
edk2-57ee97c01ca0e81d146600a00885719b84bf1581.zip
BaseTool: Replace dict with OrderedDict.
Replace dict with OrderedDict for PCD so that the pcd list has same order. 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/GenFds/FdfParser.py7
-rw-r--r--BaseTools/Source/Python/Workspace/BuildClassObject.py16
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py27
3 files changed, 30 insertions, 20 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 1f7d59bb51..63687e98bb 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -64,6 +64,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from .Capsule import EFI_CERT_TYPE_PKCS7_GUID
from .Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
from Common.RangeExpression import RangeExpression
+from collections import OrderedDict
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
@@ -227,8 +228,8 @@ class FileProfile :
EdkLogger.error("FdfParser", FILE_OPEN_FAILURE, ExtraData=FileName)
self.FileName = FileName
- self.PcdDict = {}
- self.PcdLocalDict = {}
+ self.PcdDict = OrderedDict()
+ self.PcdLocalDict = OrderedDict()
self.InfList = []
self.InfDict = {'ArchTBD':[]}
# ECC will use this Dict and List information
@@ -274,7 +275,7 @@ class FdfParser:
# Key: [section name, UI name, arch]
# Value: {MACRO_NAME : MACRO_VALUE}
self.__MacroDict = tdict(True, 3)
- self.__PcdDict = {}
+ self.__PcdDict = OrderedDict()
self.__WipeOffArea = []
if GenFdsGlobalVariable.WorkSpaceDir == '':
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index e93ff1dd32..57ba73c498 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -13,7 +13,11 @@
from collections import OrderedDict, namedtuple
from Common.DataType import *
-
+import collections
+import re
+from collections import OrderedDict
+StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$')
+ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]")
## PcdClassObject
#
# This Class is used for PcdObject
@@ -41,7 +45,7 @@ from Common.DataType import *
# @var Phase: To store value for Phase, default is "DXE"
#
class PcdClassObject(object):
- def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None, validateranges = [], validlists = [], expressions = [], IsDsc = False, UserDefinedDefaultStoresFlag = False):
+ def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = None, IsOverrided = False, GuidValue = None, validateranges = None, validlists = None, expressions = None, IsDsc = False, UserDefinedDefaultStoresFlag = False):
self.TokenCName = Name
self.TokenSpaceGuidCName = Guid
self.TokenSpaceGuidValue = GuidValue
@@ -51,15 +55,15 @@ class PcdClassObject(object):
self.TokenValue = Token
self.MaxDatumSize = MaxDatumSize
self.MaxSizeUserSet = None
- self.SkuInfoList = SkuInfoList
+ self.SkuInfoList = SkuInfoList if SkuInfoList is not None else OrderedDict()
self.Phase = "DXE"
self.Pending = False
self.IsOverrided = IsOverrided
self.IsFromBinaryInf = False
self.IsFromDsc = False
- self.validateranges = validateranges
- self.validlists = validlists
- self.expressions = expressions
+ self.validateranges = validateranges if validateranges is not None else []
+ self.validlists = validlists if validlists is not None else []
+ self.expressions = expressions if expressions is not None else []
self.DscDefaultValue = None
self.DscRawValue = {}
if IsDsc:
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index ac0f0bee47..ca782aef23 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1287,12 +1287,17 @@ class DscBuildData(PlatformBuildClassObject):
if len(commpcds[0]) == 5:
return True
return False
-
+ NoFiledValues = OrderedDict()
if CheckStructureInComm(GlobalData.BuildOptionPcd):
- StructurePcdInCom = {(item[0], item[1], item[2] ):(item[3], item[4]) for item in GlobalData.BuildOptionPcd } if GlobalData.BuildOptionPcd else {}
- NoFiledValues = {(item[0], item[1]):StructurePcdInCom[item] for item in StructurePcdInCom if not item[2]}
+ StructurePcdInCom = OrderedDict()
+ for item in GlobalData.BuildOptionPcd:
+ StructurePcdInCom[(item[0], item[1], item[2] )] = (item[3], item[4])
+ for item in StructurePcdInCom:
+ if not item[2]:
+ NoFiledValues[(item[0], item[1])] = StructurePcdInCom[item]
else:
- NoFiledValues = {(item[0], item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}
+ for item in GlobalData.BuildOptionPcd:
+ NoFiledValues[(item[0], item[1])] = [item[2]]
for Guid, Name in NoFiledValues:
if (Name, Guid) in AllPcds:
Pcd = AllPcds.get((Name, Guid))
@@ -2219,7 +2224,7 @@ class DscBuildData(PlatformBuildClassObject):
'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +='
IncSearchList = []
- PlatformInc = {}
+ PlatformInc = OrderedDict()
for Cache in self._Bdb._CACHE_.values():
if Cache.MetaFile.Ext.lower() != '.dec':
continue
@@ -2249,7 +2254,7 @@ class DscBuildData(PlatformBuildClassObject):
CC_FLAGS = LinuxCFLAGS
if sys.platform == "win32":
CC_FLAGS = WindowsCFLAGS
- BuildOptions = {}
+ BuildOptions = OrderedDict()
for Options in self.BuildOptions:
if Options[2] != EDKII_NAME:
continue
@@ -2264,7 +2269,7 @@ class DscBuildData(PlatformBuildClassObject):
if Tag == "*" or Tag == self._Toolchain:
if Arch == "*" or Arch == self.Arch:
if Tool not in BuildOptions:
- BuildOptions[Tool] = {}
+ BuildOptions[Tool] = OrderedDict()
if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='):
BuildOptions[Tool][Attr] = self.BuildOptions[Options]
else:
@@ -2469,7 +2474,7 @@ class DscBuildData(PlatformBuildClassObject):
PcdValue,
'',
MaxDatumSize,
- {SkuName : SkuInfo},
+ OrderedDict({SkuName : SkuInfo}),
False,
None,
IsDsc=True)
@@ -2526,7 +2531,7 @@ class DscBuildData(PlatformBuildClassObject):
return False
def CompletePcdValues(self, PcdSet):
- Pcds = {}
+ Pcds = OrderedDict()
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
SkuIds = {skuname:skuid for skuname, skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname != TAB_COMMON}
DefaultStores = set(storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict)
@@ -2664,7 +2669,7 @@ class DscBuildData(PlatformBuildClassObject):
DefaultValue,
'',
'',
- {SkuName : SkuInfo},
+ OrderedDict({SkuName : SkuInfo}),
False,
None,
pcdDecObject.validateranges,
@@ -2808,7 +2813,7 @@ class DscBuildData(PlatformBuildClassObject):
InitialValue,
'',
MaxDatumSize,
- {SkuName : SkuInfo},
+ OrderedDict({SkuName : SkuInfo}),
False,
None,
IsDsc=True)