diff options
author | Liming Gao <liming.gao@intel.com> | 2013-11-18 07:41:21 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-11-18 07:41:21 +0000 |
commit | e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d (patch) | |
tree | 04e3ec271347360a5e9da898f1dccbce3d94681f /BaseTools/Source/Python/Common/Misc.py | |
parent | fddbbc661eeff8e9f94942fa2d47fb637404a040 (diff) | |
download | edk2-e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d.tar.gz edk2-e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d.tar.bz2 edk2-e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d.zip |
Sync BaseTool trunk (version r2610) into EDKII BaseTools.
Signed-off-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Common/Misc.py')
-rw-r--r-- | BaseTools/Source/Python/Common/Misc.py | 81 |
1 files changed, 64 insertions, 17 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index afdfb93ad6..960581581a 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -31,6 +31,7 @@ from Common import GlobalData as GlobalData from DataType import * from BuildToolError import * from CommonDataClass.DataClass import * +from Parsing import GetSplitValueList ## Regular expression used to find out place holders in string template gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE) @@ -1248,8 +1249,13 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): Size = Type = '' if len(FieldList) > 1: Type = FieldList[1] + else: + Type = DataType if len(FieldList) > 2: Size = FieldList[2] + else: + if Type == 'VOID*': + Size = str(len(Value)) if DataType == 'VOID*': IsValid = (len(FieldList) <= 3) else: @@ -1322,25 +1328,13 @@ def AnalyzePcdData(Setting): # # @retval ValueList: A List contaian VariableName, VariableGuid, VariableOffset, DefaultValue. # -def AnalyzeHiiPcdData(Setting): - ValueList = ['', '', '', ''] - - ValueRe = re.compile(r'^\s*L?\".*\|.*\"') - PtrValue = ValueRe.findall(Setting) - - ValueUpdateFlag = False - - if len(PtrValue) >= 1: - Setting = re.sub(ValueRe, '', Setting) - ValueUpdateFlag = True +def AnalyzeHiiPcdData(Setting): + ValueList = ['', '', '', ''] - TokenList = Setting.split(TAB_VALUE_SPLIT) + TokenList = GetSplitValueList(Setting) ValueList[0:len(TokenList)] = TokenList - - if ValueUpdateFlag: - ValueList[0] = PtrValue[0] - - return ValueList + + return ValueList ## AnalyzeVpdPcdData # @@ -1679,7 +1673,60 @@ class PeImageClass(): for index in range(len(ByteList) - 1, -1, -1): Value = (Value << 8) | int(ByteList[index]) return Value + + +class SkuClass(): + + DEFAULT = 0 + SINGLE = 1 + MULTIPLE =2 + + def __init__(self,SkuIdentifier='', SkuIds={}): + + self.AvailableSkuIds = sdict() + self.SkuIdSet = [] + + if SkuIdentifier == '' or SkuIdentifier is None: + self.SkuIdSet = ['DEFAULT'] + elif SkuIdentifier == 'ALL': + self.SkuIdSet = SkuIds.keys() + else: + r = SkuIdentifier.split('|') + self.SkuIdSet=[r[k].strip() for k in range(len(r))] + if len(self.SkuIdSet) == 2 and 'DEFAULT' in self.SkuIdSet and SkuIdentifier != 'ALL': + self.SkuIdSet.remove('DEFAULT') + + for each in self.SkuIdSet: + if each in SkuIds: + self.AvailableSkuIds[each] = SkuIds[each] + else: + EdkLogger.error("build", PARAMETER_INVALID, + ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]" + % (each, " ".join(SkuIds.keys()))) + def __SkuUsageType(self): + + if len(self.SkuIdSet) == 1: + if self.SkuIdSet[0] == 'DEFAULT': + return SkuClass.DEFAULT + else: + return SkuClass.SINGLE + else: + return SkuClass.MULTIPLE + + def __GetAvailableSkuIds(self): + return self.AvailableSkuIds + + def __GetSystemSkuID(self): + if self.__SkuUsageType() == SkuClass.SINGLE: + return self.SkuIdSet[0] + else: + return 'DEFAULT' + + SystemSkuId = property(__GetSystemSkuID) + AvailableSkuIdSet = property(__GetAvailableSkuIds) + SkuUsageType = property(__SkuUsageType) + ## # # This acts like the main() function for the script, unless it is 'import'ed into another |