summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2019-01-11 02:39:47 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-01-21 18:03:32 +0800
commit2b95556c06c445f7cbc02a9c92ce5481d760bddb (patch)
treea6c6653d215cfd78396ee94d1b1bc4f71bd01616
parent12ba816e61a8dc400b10433a6548e52d62e2cba8 (diff)
downloadedk2-2b95556c06c445f7cbc02a9c92ce5481d760bddb.tar.gz
edk2-2b95556c06c445f7cbc02a9c92ce5481d760bddb.tar.bz2
edk2-2b95556c06c445f7cbc02a9c92ce5481d760bddb.zip
BaseTools/DscBuildData: move function
Move IsFieldValuieAnArray from Common.Misc to this file. There were no other consumers of the function. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-rw-r--r--BaseTools/Source/Python/Common/Misc.py18
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py50
2 files changed, 34 insertions, 34 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index ae66afd26f..4c6660b844 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1,7 +1,7 @@
## @file
# Common routines used by all tools
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -1149,22 +1149,6 @@ class tdict:
keys |= self.data[Key].GetKeys(KeyIndex - 1)
return keys
-def IsFieldValueAnArray (Value):
- Value = Value.strip()
- if Value.startswith(TAB_GUID) and Value.endswith(')'):
- return True
- if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:
- return True
- if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
- return True
- if Value[0] == '{' and Value[-1] == '}':
- return True
- if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
- return True
- if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
- return True
- return False
-
def AnalyzePcdExpression(Setting):
RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
Setting = Setting.replace('\\\\', RanStr).strip()
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 9881dbe556..0dad04212e 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1,7 +1,7 @@
## @file
# This file is used to create a database used by build tool
#
-# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -44,6 +44,22 @@ from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, P
from collections import OrderedDict, defaultdict
from .BuildClassObject import ArrayIndex
+def _IsFieldValueAnArray (Value):
+ Value = Value.strip()
+ if Value.startswith(TAB_GUID) and Value.endswith(')'):
+ return True
+ if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:
+ return True
+ if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
+ return True
+ if Value[0] == '{' and Value[-1] == '}':
+ return True
+ if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
+ return True
+ if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
+ return True
+ return False
+
PcdValueInitName = 'PcdValueInit'
PcdMainCHeader = '''
@@ -1107,7 +1123,7 @@ class DscBuildData(PlatformBuildClassObject):
IsArray = False
TokenCName += '.' + FieldName
if PcdValue.startswith('H'):
- if FieldName and IsFieldValueAnArray(PcdValue[1:]):
+ if FieldName and _IsFieldValueAnArray(PcdValue[1:]):
PcdDatumType = TAB_VOID
IsArray = True
if FieldName and not IsArray:
@@ -1118,7 +1134,7 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
- if FieldName and IsFieldValueAnArray(PcdValue):
+ if FieldName and _IsFieldValueAnArray(PcdValue):
PcdDatumType = TAB_VOID
IsArray = True
if FieldName and not IsArray:
@@ -1130,7 +1146,7 @@ class DscBuildData(PlatformBuildClassObject):
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith('L'):
PcdValue = 'L"' + PcdValue[1:] + '"'
- if FieldName and IsFieldValueAnArray(PcdValue):
+ if FieldName and _IsFieldValueAnArray(PcdValue):
PcdDatumType = TAB_VOID
IsArray = True
if FieldName and not IsArray:
@@ -1159,7 +1175,7 @@ class DscBuildData(PlatformBuildClassObject):
Num = int(PcdValue, Base)
except:
PcdValue = '"' + PcdValue + '"'
- if IsFieldValueAnArray(PcdValue):
+ if _IsFieldValueAnArray(PcdValue):
PcdDatumType = TAB_VOID
IsArray = True
if not IsArray:
@@ -1764,7 +1780,7 @@ class DscBuildData(PlatformBuildClassObject):
continue
for FieldName in FieldList:
FieldName = "." + FieldName
- IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
try:
Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1795,7 +1811,7 @@ class DscBuildData(PlatformBuildClassObject):
continue
for FieldName in FieldList:
FieldName = "." + FieldName
- IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
try:
Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1819,7 +1835,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + "// From fdf \n"
for FieldName in Pcd.PcdFieldValueFromFdf:
FieldName = "." + FieldName
- IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
+ IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0])
if IsArray and not (Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].endswith('}')):
try:
Value = ValueExpressionEx(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1843,7 +1859,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + "// From Command Line \n"
for FieldName in Pcd.PcdFieldValueFromComm:
FieldName = "." + FieldName
- IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
+ IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0])
if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')):
try:
Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True)
@@ -1945,7 +1961,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' UINT32 FieldSize;\n'
CApp = CApp + ' CHAR8 *Value;\n'
DefaultValueFromDec = Pcd.DefaultValueFromDec
- IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec)
+ IsArray = _IsFieldValueAnArray(Pcd.DefaultValueFromDec)
if IsArray:
try:
DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True)
@@ -1970,7 +1986,7 @@ class DscBuildData(PlatformBuildClassObject):
if not FieldList:
continue
for FieldName in FieldList:
- IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
try:
FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2034,7 +2050,7 @@ class DscBuildData(PlatformBuildClassObject):
pcddefaultvalue = self.GetPcdDscRawDefaultValue(Pcd, SkuName, DefaultStoreName)
if pcddefaultvalue:
FieldList = pcddefaultvalue
- IsArray = IsFieldValueAnArray(FieldList)
+ IsArray = _IsFieldValueAnArray(FieldList)
if IsArray:
if "{CODE(" not in FieldList:
try:
@@ -2085,7 +2101,7 @@ class DscBuildData(PlatformBuildClassObject):
if (SkuName, DefaultStoreName) == (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName, DefaultStoreName) not in Pcd.ValueChain )):
for FieldName in FieldList:
indicator = self.GetIndicator(index, FieldName,Pcd)
- IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
try:
FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2134,7 +2150,7 @@ class DscBuildData(PlatformBuildClassObject):
if not FieldList:
continue
if pcddefaultvalue and FieldList == pcddefaultvalue:
- IsArray = IsFieldValueAnArray(FieldList)
+ IsArray = _IsFieldValueAnArray(FieldList)
if IsArray:
try:
FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True)
@@ -2153,7 +2169,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
continue
for FieldName in FieldList:
- IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
try:
FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
@@ -2202,7 +2218,7 @@ class DscBuildData(PlatformBuildClassObject):
if not FieldList:
continue
if pcddefaultvalue and FieldList == pcddefaultvalue:
- IsArray = IsFieldValueAnArray(FieldList)
+ IsArray = _IsFieldValueAnArray(FieldList)
if IsArray:
try:
FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True)
@@ -2221,7 +2237,7 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
continue
for FieldName in FieldList:
- IsArray = IsFieldValueAnArray(FieldList[FieldName][0])
+ IsArray = _IsFieldValueAnArray(FieldList[FieldName][0])
if IsArray:
try:
FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)