BaseTools: Enable CODE format in DEC file
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1292. Enable CODE format in DEC File. 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>
This commit is contained in:
@ -1796,7 +1796,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
||||||
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
|
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
|
||||||
Value, ValueSize = ParseFieldValue(Value)
|
Value, ValueSize = ParseFieldValue(Value)
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
|
if not Pcd.IsArray:
|
||||||
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
|
||||||
else:
|
else:
|
||||||
NewFieldName = ''
|
NewFieldName = ''
|
||||||
FieldName_ori = FieldName.strip('.')
|
FieldName_ori = FieldName.strip('.')
|
||||||
@ -1805,7 +1806,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
||||||
FieldName = FieldName.split(']', 1)[1]
|
FieldName = FieldName.split(']', 1)[1]
|
||||||
FieldName = NewFieldName + FieldName
|
FieldName = NewFieldName + FieldName
|
||||||
while '[' in FieldName:
|
while '[' in FieldName and not Pcd.IsArray:
|
||||||
FieldName = FieldName.rsplit('[', 1)[0]
|
FieldName = FieldName.rsplit('[', 1)[0]
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
|
||||||
for skuname in Pcd.SkuOverrideValues:
|
for skuname in Pcd.SkuOverrideValues:
|
||||||
@ -1827,7 +1828,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
||||||
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
|
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
|
||||||
Value, ValueSize = ParseFieldValue(Value)
|
Value, ValueSize = ParseFieldValue(Value)
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
|
if not Pcd.IsArray:
|
||||||
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
|
||||||
else:
|
else:
|
||||||
NewFieldName = ''
|
NewFieldName = ''
|
||||||
FieldName_ori = FieldName.strip('.')
|
FieldName_ori = FieldName.strip('.')
|
||||||
@ -1836,7 +1838,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
||||||
FieldName = FieldName.split(']', 1)[1]
|
FieldName = FieldName.split(']', 1)[1]
|
||||||
FieldName = NewFieldName + FieldName
|
FieldName = NewFieldName + FieldName
|
||||||
while '[' in FieldName:
|
while '[' in FieldName and not Pcd.IsArray:
|
||||||
FieldName = FieldName.rsplit('[', 1)[0]
|
FieldName = FieldName.rsplit('[', 1)[0]
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
|
||||||
if Pcd.PcdFieldValueFromFdf:
|
if Pcd.PcdFieldValueFromFdf:
|
||||||
@ -1851,7 +1853,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
||||||
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2]))
|
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2]))
|
||||||
Value, ValueSize = ParseFieldValue(Value)
|
Value, ValueSize = ParseFieldValue(Value)
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
|
if not Pcd.IsArray:
|
||||||
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]);
|
||||||
else:
|
else:
|
||||||
NewFieldName = ''
|
NewFieldName = ''
|
||||||
FieldName_ori = FieldName.strip('.')
|
FieldName_ori = FieldName.strip('.')
|
||||||
@ -1875,7 +1878,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
|
||||||
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2]))
|
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2]))
|
||||||
Value, ValueSize = ParseFieldValue(Value)
|
Value, ValueSize = ParseFieldValue(Value)
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
|
if not Pcd.IsArray:
|
||||||
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]);
|
||||||
else:
|
else:
|
||||||
NewFieldName = ''
|
NewFieldName = ''
|
||||||
FieldName_ori = FieldName.strip('.')
|
FieldName_ori = FieldName.strip('.')
|
||||||
@ -1884,7 +1888,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
||||||
FieldName = FieldName.split(']', 1)[1]
|
FieldName = FieldName.split(']', 1)[1]
|
||||||
FieldName = NewFieldName + FieldName
|
FieldName = NewFieldName + FieldName
|
||||||
while '[' in FieldName:
|
while '[' in FieldName and not Pcd.IsArray:
|
||||||
FieldName = FieldName.rsplit('[', 1)[0]
|
FieldName = FieldName.rsplit('[', 1)[0]
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
|
CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0])
|
||||||
if Pcd.GetPcdMaxSize():
|
if Pcd.GetPcdMaxSize():
|
||||||
@ -1915,10 +1919,11 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
PcdDefValue = Pcd.DefaultValue
|
PcdDefValue = Pcd.DefaultValue
|
||||||
if lastoneisEmpty:
|
if lastoneisEmpty:
|
||||||
if "{CODE(" not in PcdDefValue:
|
if "{CODE(" not in PcdDefValue:
|
||||||
sizebasevalue_plus = "(%s / sizeof(%s) + 1)" % ((DscBuildData.GetStructurePcdMaxSize(Pcd), "".join(r_datatype)))
|
sizebasevalue_plus = "(%s / sizeof(%s) + 1)" % ((DscBuildData.GetStructurePcdMaxSize(Pcd), Pcd.BaseDatumType))
|
||||||
sizebasevalue = "(%s / sizeof(%s))" % ((DscBuildData.GetStructurePcdMaxSize(Pcd), "".join(r_datatype)))
|
sizebasevalue = "(%s / sizeof(%s))" % ((DscBuildData.GetStructurePcdMaxSize(Pcd), Pcd.BaseDatumType))
|
||||||
sizeof = "sizeof(%s)" % Pcd.BaseDatumType
|
sizeof = "sizeof(%s)" % Pcd.BaseDatumType
|
||||||
CApp = ' Size = %s %% %s ? %s : %s ;\n' % ( (DscBuildData.GetStructurePcdMaxSize(Pcd), sizeof, sizebasevalue_plus, sizebasevalue))
|
CApp = ' int ArraySize = %s %% %s ? %s : %s ;\n' % ( (DscBuildData.GetStructurePcdMaxSize(Pcd), sizeof, sizebasevalue_plus, sizebasevalue))
|
||||||
|
CApp += ' Size = ArraySize * sizeof(%s); \n' % Pcd.BaseDatumType
|
||||||
else:
|
else:
|
||||||
CApp = " Size = 0;\n"
|
CApp = " Size = 0;\n"
|
||||||
else:
|
else:
|
||||||
@ -1978,9 +1983,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))
|
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))
|
||||||
DefaultValueFromDec = StringToArray(DefaultValueFromDec)
|
DefaultValueFromDec = StringToArray(DefaultValueFromDec)
|
||||||
Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
|
Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
|
||||||
if isinstance(Value, str):
|
if IsArray:
|
||||||
CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
|
|
||||||
elif IsArray:
|
|
||||||
#
|
#
|
||||||
# Use memcpy() to copy value into field
|
# Use memcpy() to copy value into field
|
||||||
#
|
#
|
||||||
@ -1989,6 +1992,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
else:
|
else:
|
||||||
CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)
|
CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)
|
||||||
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
|
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
|
||||||
|
elif isinstance(Value, str):
|
||||||
|
CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
|
||||||
for index in Pcd.DefaultValues:
|
for index in Pcd.DefaultValues:
|
||||||
FieldList = Pcd.DefaultValues[index]
|
FieldList = Pcd.DefaultValues[index]
|
||||||
if not FieldList:
|
if not FieldList:
|
||||||
@ -2008,9 +2013,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))
|
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))
|
||||||
|
|
||||||
indicator = self.GetIndicator(index, FieldName,Pcd)
|
indicator = self.GetIndicator(index, FieldName,Pcd)
|
||||||
if isinstance(Value, str):
|
if IsArray:
|
||||||
CApp = CApp + ' %s = %s; // From %s Line %d Value %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
|
||||||
elif IsArray:
|
|
||||||
#
|
#
|
||||||
# Use memcpy() to copy value into field
|
# Use memcpy() to copy value into field
|
||||||
#
|
#
|
||||||
@ -2019,7 +2022,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d) || (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize, Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
CApp = CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d) || (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize, Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
|
CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
|
||||||
CApp = CApp + ' memcpy (&%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
|
CApp = CApp + ' memcpy (&%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
|
||||||
|
elif isinstance(Value, str):
|
||||||
|
CApp = CApp + ' %s = %s; // From %s Line %d Value %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
else:
|
else:
|
||||||
if '[' in FieldName and ']' in FieldName:
|
if '[' in FieldName and ']' in FieldName:
|
||||||
Index = int(FieldName.split('[')[1].split(']')[0])
|
Index = int(FieldName.split('[')[1].split(']')[0])
|
||||||
|
@ -192,6 +192,10 @@ class MetaFileParser(object):
|
|||||||
self._Version = 0
|
self._Version = 0
|
||||||
self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)}
|
self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)}
|
||||||
|
|
||||||
|
self._PcdCodeValue = ""
|
||||||
|
self._PcdDataTypeCODE = False
|
||||||
|
self._CurrentPcdName = ""
|
||||||
|
|
||||||
## Store the parsed data in table
|
## Store the parsed data in table
|
||||||
def _Store(self, *Args):
|
def _Store(self, *Args):
|
||||||
return self._Table.Insert(*Args)
|
return self._Table.Insert(*Args)
|
||||||
@ -483,6 +487,39 @@ class MetaFileParser(object):
|
|||||||
|
|
||||||
return Macros
|
return Macros
|
||||||
|
|
||||||
|
def ProcessMultipleLineCODEValue(self,Content):
|
||||||
|
CODEBegin = False
|
||||||
|
CODELine = ""
|
||||||
|
continuelinecount = 0
|
||||||
|
newContent = []
|
||||||
|
for Index in range(0, len(Content)):
|
||||||
|
Line = Content[Index]
|
||||||
|
if CODEBegin:
|
||||||
|
CODELine = CODELine + Line
|
||||||
|
continuelinecount +=1
|
||||||
|
if ")}" in Line:
|
||||||
|
newContent.append(CODELine)
|
||||||
|
for _ in range(continuelinecount):
|
||||||
|
newContent.append("")
|
||||||
|
CODEBegin = False
|
||||||
|
CODELine = ""
|
||||||
|
continuelinecount = 0
|
||||||
|
else:
|
||||||
|
if not Line:
|
||||||
|
newContent.append(Line)
|
||||||
|
continue
|
||||||
|
if "{CODE(" not in Line:
|
||||||
|
newContent.append(Line)
|
||||||
|
continue
|
||||||
|
elif CODEPattern.findall(Line):
|
||||||
|
newContent.append(Line)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
CODEBegin = True
|
||||||
|
CODELine = Line
|
||||||
|
|
||||||
|
return newContent
|
||||||
|
|
||||||
_SectionParser = {}
|
_SectionParser = {}
|
||||||
|
|
||||||
## INF file parser class
|
## INF file parser class
|
||||||
@ -907,9 +944,6 @@ class DscParser(MetaFileParser):
|
|||||||
#
|
#
|
||||||
self._IdMapping = {-1:-1}
|
self._IdMapping = {-1:-1}
|
||||||
|
|
||||||
self._PcdCodeValue = ""
|
|
||||||
self._PcdDataTypeCODE = False
|
|
||||||
self._CurrentPcdName = ""
|
|
||||||
self._Content = None
|
self._Content = None
|
||||||
|
|
||||||
## Parser starter
|
## Parser starter
|
||||||
@ -1140,38 +1174,6 @@ class DscParser(MetaFileParser):
|
|||||||
def _LibraryInstanceParser(self):
|
def _LibraryInstanceParser(self):
|
||||||
self._ValueList[0] = self._CurrentLine
|
self._ValueList[0] = self._CurrentLine
|
||||||
|
|
||||||
def ProcessMultipleLineCODEValue(self,Content):
|
|
||||||
CODEBegin = False
|
|
||||||
CODELine = ""
|
|
||||||
continuelinecount = 0
|
|
||||||
newContent = []
|
|
||||||
for Index in range(0, len(Content)):
|
|
||||||
Line = Content[Index]
|
|
||||||
if CODEBegin:
|
|
||||||
CODELine = CODELine + Line
|
|
||||||
continuelinecount +=1
|
|
||||||
if ")}" in Line:
|
|
||||||
newContent.append(CODELine)
|
|
||||||
for _ in range(continuelinecount):
|
|
||||||
newContent.append("")
|
|
||||||
CODEBegin = False
|
|
||||||
CODELine = ""
|
|
||||||
continuelinecount = 0
|
|
||||||
else:
|
|
||||||
if not Line:
|
|
||||||
newContent.append(Line)
|
|
||||||
continue
|
|
||||||
if "{CODE(" not in Line:
|
|
||||||
newContent.append(Line)
|
|
||||||
continue
|
|
||||||
elif CODEPattern.findall(Line):
|
|
||||||
newContent.append(Line)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
CODEBegin = True
|
|
||||||
CODELine = Line
|
|
||||||
|
|
||||||
return newContent
|
|
||||||
|
|
||||||
def _DecodeCODEData(self):
|
def _DecodeCODEData(self):
|
||||||
pass
|
pass
|
||||||
@ -1778,6 +1780,8 @@ class DecParser(MetaFileParser):
|
|||||||
self._include_flag = False
|
self._include_flag = False
|
||||||
self._package_flag = False
|
self._package_flag = False
|
||||||
|
|
||||||
|
self._RestofValue = ""
|
||||||
|
|
||||||
## Parser starter
|
## Parser starter
|
||||||
def Start(self):
|
def Start(self):
|
||||||
Content = ''
|
Content = ''
|
||||||
@ -1786,6 +1790,8 @@ class DecParser(MetaFileParser):
|
|||||||
except:
|
except:
|
||||||
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)
|
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)
|
||||||
|
|
||||||
|
Content = self.ProcessMultipleLineCODEValue(Content)
|
||||||
|
|
||||||
self._DefinesCount = 0
|
self._DefinesCount = 0
|
||||||
for Index in range(0, len(Content)):
|
for Index in range(0, len(Content)):
|
||||||
Line, Comment = CleanString2(Content[Index])
|
Line, Comment = CleanString2(Content[Index])
|
||||||
@ -1983,6 +1989,7 @@ class DecParser(MetaFileParser):
|
|||||||
#
|
#
|
||||||
@ParseMacro
|
@ParseMacro
|
||||||
def _PcdParser(self):
|
def _PcdParser(self):
|
||||||
|
|
||||||
if self._CurrentStructurePcdName:
|
if self._CurrentStructurePcdName:
|
||||||
self._ValueList[0] = self._CurrentStructurePcdName
|
self._ValueList[0] = self._CurrentStructurePcdName
|
||||||
|
|
||||||
@ -2028,7 +2035,29 @@ class DecParser(MetaFileParser):
|
|||||||
self._ValueList[1] = TAB_SPLIT.join(PcdNames[2:])
|
self._ValueList[1] = TAB_SPLIT.join(PcdNames[2:])
|
||||||
self._ValueList[2] = PcdTockens[1]
|
self._ValueList[2] = PcdTockens[1]
|
||||||
if not self._CurrentStructurePcdName:
|
if not self._CurrentStructurePcdName:
|
||||||
|
if self._PcdDataTypeCODE:
|
||||||
|
if ")}" in self._CurrentLine:
|
||||||
|
ValuePart,RestofValue = self._CurrentLine.split(")}")
|
||||||
|
self._PcdCodeValue = self._PcdCodeValue + "\n " + ValuePart
|
||||||
|
self._CurrentLine = "|".join((self._CurrentPcdName, self._PcdCodeValue,RestofValue))
|
||||||
|
self._PcdDataTypeCODE = False
|
||||||
|
self._PcdCodeValue = ""
|
||||||
|
else:
|
||||||
|
self._PcdCodeValue = self._PcdCodeValue + "\n " + self._CurrentLine
|
||||||
|
self._ValueList = None
|
||||||
|
return
|
||||||
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)
|
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)
|
||||||
|
self._CurrentPcdName = TokenList[0]
|
||||||
|
if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"):
|
||||||
|
if ")}" in self._CurrentLine:
|
||||||
|
self._PcdDataTypeCODE = False
|
||||||
|
self._PcdCodeValue = ""
|
||||||
|
else:
|
||||||
|
self._PcdDataTypeCODE = True
|
||||||
|
self._PcdCodeValue = TokenList[1].strip()
|
||||||
|
self._ValueList = None
|
||||||
|
return
|
||||||
|
|
||||||
self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
||||||
ValueRe = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*')
|
ValueRe = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*')
|
||||||
# check PCD information
|
# check PCD information
|
||||||
|
@ -149,7 +149,7 @@ def ByteArrayForamt(Value):
|
|||||||
IsByteArray = False
|
IsByteArray = False
|
||||||
SplitNum = 16
|
SplitNum = 16
|
||||||
ArrayList = []
|
ArrayList = []
|
||||||
if Value.startswith('{') and Value.endswith('}'):
|
if Value.startswith('{') and Value.endswith('}') and not Value.startswith("{CODE("):
|
||||||
Value = Value[1:-1]
|
Value = Value[1:-1]
|
||||||
ValueList = Value.split(',')
|
ValueList = Value.split(',')
|
||||||
if len(ValueList) >= SplitNum:
|
if len(ValueList) >= SplitNum:
|
||||||
|
Reference in New Issue
Block a user