mirror of https://github.com/acidanthera/audk.git
BaseTools: Support Structure PCD value assignment in DEC/DSC
https://bugzilla.tianocore.org/show_bug.cgi?id=542 This is pure BaseTools enhancement to support PCD with one structure. User can specify PCD value based on its structure field. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
parent
309e37a229
commit
ae7b6df816
|
@ -316,8 +316,8 @@ class WorkspaceAutoGen(AutoGen):
|
|||
|
||||
EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)
|
||||
|
||||
if Progress:
|
||||
Progress.Start("\nProcessing meta-data")
|
||||
# if Progress:
|
||||
# Progress.Start("\nProcessing meta-data")
|
||||
|
||||
if self.FdfFile:
|
||||
#
|
||||
|
@ -1557,12 +1557,19 @@ class PlatformAutoGen(AutoGen):
|
|||
if pcd not in self._PlatformPcds.keys():
|
||||
self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]
|
||||
|
||||
for item in self._PlatformPcds:
|
||||
if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
|
||||
self._PlatformPcds[item].DatumType = "VOID*"
|
||||
|
||||
if (self.Workspace.ArchList[-1] == self.Arch):
|
||||
for Pcd in self._DynamicPcdList:
|
||||
# just pick the a value to determine whether is unicode string type
|
||||
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
|
||||
if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
|
||||
Pcd.DatumType = "VOID*"
|
||||
|
||||
PcdValue = Sku.DefaultValue
|
||||
if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):
|
||||
# if found PCD which datum value is unicode string the insert to left size of UnicodeIndex
|
||||
|
@ -4059,7 +4066,7 @@ class ModuleAutoGen(AutoGen):
|
|||
elif BoolValue == 'FALSE':
|
||||
Pcd.DefaultValue = '0'
|
||||
|
||||
if Pcd.DatumType != 'VOID*':
|
||||
if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
HexFormat = '0x%02x'
|
||||
if Pcd.DatumType == 'UINT16':
|
||||
HexFormat = '0x%04x'
|
||||
|
|
|
@ -869,7 +869,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH):
|
|||
TokenCNameList.append(TokenCName)
|
||||
|
||||
def GetPcdSize(Pcd):
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
Value = Pcd.DefaultValue
|
||||
if Value in [None, '']:
|
||||
return 1
|
||||
|
@ -889,6 +889,8 @@ def GetPcdSize(Pcd):
|
|||
return 1
|
||||
if Pcd.DatumType == 'BOOLEAN':
|
||||
return 1
|
||||
else:
|
||||
return Pcd.MaxDatumSize
|
||||
|
||||
|
||||
## Create code for module PCDs
|
||||
|
@ -951,16 +953,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if Pcd.DatumType not in gDatumSizeStringDatabase:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
|
||||
DatumSize = gDatumSizeStringDatabase[Pcd.DatumType]
|
||||
DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType]
|
||||
GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName
|
||||
SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName
|
||||
SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName
|
||||
DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*']
|
||||
DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*']
|
||||
GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName
|
||||
SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName
|
||||
SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName
|
||||
GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName
|
||||
|
||||
PcdExCNameList = []
|
||||
|
@ -980,7 +978,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
|
@ -990,7 +988,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
|
@ -1009,7 +1007,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
else:
|
||||
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
|
||||
else:
|
||||
|
@ -1087,7 +1085,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
ExtraData="[%s]" % str(Info))
|
||||
if not Value.endswith('U'):
|
||||
Value += 'U'
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
|
@ -1120,15 +1118,25 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
# skip casting for fixed at build since it breaks ARM assembly.
|
||||
# Long term we need PCD macros that work in assembly
|
||||
#
|
||||
elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
|
||||
elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']:
|
||||
Value = "((%s)%s)" % (Pcd.DatumType, Value)
|
||||
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']:
|
||||
# handle structure PCD
|
||||
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
|
||||
ArraySize = int(Pcd.MaxDatumSize, 0)
|
||||
Array = '[%d]' % ArraySize
|
||||
|
||||
if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
PcdValueName = '_PCD_PATCHABLE_VALUE_' + TokenCName
|
||||
else:
|
||||
PcdValueName = '_PCD_VALUE_' + TokenCName
|
||||
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
#
|
||||
# For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed.
|
||||
#
|
||||
|
@ -1176,7 +1184,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName))
|
||||
|
||||
if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
|
||||
else:
|
||||
|
@ -1239,22 +1247,18 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if Pcd.DatumType not in gDatumSizeStringDatabase:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
|
||||
DatumType = Pcd.DatumType
|
||||
DatumSize = gDatumSizeStringDatabaseH[DatumType]
|
||||
DatumSizeLib= gDatumSizeStringDatabaseLib[DatumType]
|
||||
GetModeName = '_PCD_GET_MODE_' + DatumSize + '_' + TokenCName
|
||||
SetModeName = '_PCD_SET_MODE_' + DatumSize + '_' + TokenCName
|
||||
SetModeStatusName = '_PCD_SET_MODE_' + DatumSize + '_S_' + TokenCName
|
||||
DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*']
|
||||
DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*']
|
||||
GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName
|
||||
SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName
|
||||
SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName
|
||||
GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName
|
||||
|
||||
Type = ''
|
||||
Array = ''
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
if Pcd.DefaultValue[0]== '{':
|
||||
Type = '(VOID *)'
|
||||
Array = '[]'
|
||||
|
@ -1279,7 +1283,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
|
@ -1289,7 +1293,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
|
@ -1310,7 +1314,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
else:
|
||||
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName))
|
||||
if DatumType == 'VOID*':
|
||||
if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
|
||||
else:
|
||||
|
@ -1318,7 +1322,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName))
|
||||
if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
|
||||
if DatumType == 'VOID*':
|
||||
if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
ArraySize = int(Pcd.MaxDatumSize, 0)
|
||||
if Pcd.DefaultValue[0] == 'L':
|
||||
ArraySize = ArraySize / 2
|
||||
|
@ -1329,7 +1333,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array))
|
||||
AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName))
|
||||
PcdDataSize = GetPcdSize(Pcd)
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, TokenCName, TokenCName))
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, TokenCName, TokenCName))
|
||||
AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pcd.MaxDatumSize))
|
||||
|
@ -1346,12 +1350,14 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName
|
||||
if DatumType == 'VOID*' and Array == '[]':
|
||||
DatumType = ['UINT8', 'UINT16'][Pcd.DefaultValue[0] == 'L']
|
||||
if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']:
|
||||
DatumType = 'UINT8'
|
||||
AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array))
|
||||
AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName))
|
||||
AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
|
||||
|
||||
if PcdItemType == TAB_PCDS_FIXED_AT_BUILD and (key in Info.ConstPcd or (Info.IsLibrary and not Info._ReferenceModules)):
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:
|
||||
AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName))
|
||||
else:
|
||||
AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue))
|
||||
|
|
|
@ -1158,6 +1158,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
|||
VarCheckTab = VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER()
|
||||
i = 0
|
||||
ReorderedDynPcdList = GetOrderedDynamicPcdList(Platform.DynamicPcdList, Platform.PcdTokenNumber)
|
||||
for item in ReorderedDynPcdList:
|
||||
if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
|
||||
item.DatumType = "VOID*"
|
||||
for Pcd in ReorderedDynPcdList:
|
||||
VoidStarTypeCurrSize = []
|
||||
i += 1
|
||||
|
|
|
@ -86,6 +86,7 @@ MIGRATION_ERROR = 0xF010
|
|||
PCD_VALIDATION_INFO_ERROR = 0xF011
|
||||
PCD_VARIABLE_ATTRIBUTES_ERROR = 0xF012
|
||||
PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR = 0xF013
|
||||
PCD_STRUCTURE_PCD_ERROR = 0xF014
|
||||
ABORT_ERROR = 0xFFFE
|
||||
UNKNOWN_ERROR = 0xFFFF
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ BuildOptionPcd = []
|
|||
#
|
||||
MixedPcd = {}
|
||||
|
||||
# Structure Pcd dict
|
||||
gStructurePcd = {}
|
||||
|
||||
# Pcd name for the Pcd which used in the Conditional directives
|
||||
gConditionalPcds = []
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ from CommonDataClass.DataClass import *
|
|||
from Parsing import GetSplitValueList
|
||||
from Common.LongFilePathSupport import OpenLongFilePath as open
|
||||
from Common.MultipleWorkspace import MultipleWorkspace as mws
|
||||
import uuid
|
||||
|
||||
## Regular expression used to find out place holders in string template
|
||||
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
|
||||
|
@ -1471,6 +1472,100 @@ def AnalyzePcdExpression(Setting):
|
|||
|
||||
return FieldList
|
||||
|
||||
def ParseFieldValue (Value):
|
||||
if type(Value) == type(0):
|
||||
return Value, (Value.bit_length() + 7) / 8
|
||||
if type(Value) <> type(''):
|
||||
raise ValueError
|
||||
Value = Value.strip()
|
||||
if Value.startswith('UINT8') and Value.endswith(')'):
|
||||
Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1])
|
||||
if Size > 1:
|
||||
raise ValueError
|
||||
return Value, 1
|
||||
if Value.startswith('UINT16') and Value.endswith(')'):
|
||||
Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1])
|
||||
if Size > 2:
|
||||
raise ValueError
|
||||
return Value, 2
|
||||
if Value.startswith('UINT32') and Value.endswith(')'):
|
||||
Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1])
|
||||
if Size > 4:
|
||||
raise ValueError
|
||||
return Value, 4
|
||||
if Value.startswith('UINT64') and Value.endswith(')'):
|
||||
Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1])
|
||||
if Size > 8:
|
||||
raise ValueError
|
||||
return Value, 8
|
||||
if Value.startswith('GUID') and Value.endswith(')'):
|
||||
Value = Value.split('(', 1)[1][:-1].strip()
|
||||
if Value[0] == '{' and Value[-1] == '}':
|
||||
Value = Value[1:-1].strip()
|
||||
Value = Value.split('{', 1)
|
||||
Value = [Item.strip()[2:] for Item in (Value[0] + Value[1][:-1]).split(',')]
|
||||
Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11])
|
||||
if Value[0] == '"' and Value[-1] == '"':
|
||||
Value = Value[1:-1]
|
||||
Value = "'" + uuid.UUID(Value).get_bytes_le() + "'"
|
||||
Value, Size = ParseFieldValue(Value)
|
||||
return Value, 16
|
||||
if Value.startswith('L"') and Value.endswith('"'):
|
||||
# Unicode String
|
||||
List = list(Value[2:-1])
|
||||
List.reverse()
|
||||
Value = 0
|
||||
for Char in List:
|
||||
Value = (Value << 16) | ord(Char)
|
||||
return Value, (len(List) + 1) * 2
|
||||
if Value.startswith('"') and Value.endswith('"'):
|
||||
# ASCII String
|
||||
List = list(Value[1:-1])
|
||||
List.reverse()
|
||||
Value = 0
|
||||
for Char in List:
|
||||
Value = (Value << 8) | ord(Char)
|
||||
return Value, len(List) + 1
|
||||
if Value.startswith("L'") and Value.endswith("'"):
|
||||
# Unicode Character Constant
|
||||
List = list(Value[2:-1])
|
||||
List.reverse()
|
||||
Value = 0
|
||||
for Char in List:
|
||||
Value = (Value << 16) | ord(Char)
|
||||
return Value, len(List) * 2
|
||||
if Value.startswith("'") and Value.endswith("'"):
|
||||
# Character constant
|
||||
List = list(Value[1:-1])
|
||||
List.reverse()
|
||||
Value = 0
|
||||
for Char in List:
|
||||
Value = (Value << 8) | ord(Char)
|
||||
return Value, len(List)
|
||||
if Value.startswith('{') and Value.endswith('}'):
|
||||
# Byte array
|
||||
Value = Value[1:-1]
|
||||
List = [Item.strip() for Item in Value.split(',')]
|
||||
List.reverse()
|
||||
Value = 0
|
||||
for Item in List:
|
||||
ItemValue, Size = ParseFieldValue(Item)
|
||||
if Size > 1:
|
||||
raise ValueError
|
||||
Value = (Value << 8) | ItemValue
|
||||
return Value, len(List)
|
||||
if Value.lower().startswith('0x'):
|
||||
Value = int(Value, 16)
|
||||
return Value, (Value.bit_length() + 7) / 8
|
||||
if Value[0].isdigit():
|
||||
Value = int(Value, 10)
|
||||
return Value, (Value.bit_length() + 7) / 8
|
||||
if Value.lower() == 'true':
|
||||
return 1, 1
|
||||
if Value.lower() == 'false':
|
||||
return 0, 1
|
||||
return Value, 1
|
||||
|
||||
## AnalyzeDscPcd
|
||||
#
|
||||
# Analyze DSC PCD value, since there is no data type info in DSC
|
||||
|
@ -1504,19 +1599,19 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
|
|||
Value = FieldList[0]
|
||||
Size = ''
|
||||
if len(FieldList) > 1:
|
||||
Type = FieldList[1]
|
||||
# Fix the PCD type when no DataType input
|
||||
if Type == 'VOID*':
|
||||
DataType = 'VOID*'
|
||||
else:
|
||||
if FieldList[1].upper().startswith("0X") or FieldList[1].isdigit():
|
||||
Size = FieldList[1]
|
||||
else:
|
||||
DataType = FieldList[1]
|
||||
|
||||
if len(FieldList) > 2:
|
||||
Size = FieldList[2]
|
||||
if DataType == 'VOID*':
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
else:
|
||||
if DataType == "":
|
||||
IsValid = (len(FieldList) <= 1)
|
||||
return [Value, '', Size], IsValid, 0
|
||||
else:
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
# Value, Size = ParseFieldValue(Value)
|
||||
return [str(Value), '', str(Size)], IsValid, 0
|
||||
elif PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT):
|
||||
Value = FieldList[0]
|
||||
Size = Type = ''
|
||||
|
@ -1534,10 +1629,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
|
|||
Size = str(len(Value.split(",")))
|
||||
else:
|
||||
Size = str(len(Value) -2 + 1 )
|
||||
if DataType == 'VOID*':
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
else:
|
||||
if DataType == "":
|
||||
IsValid = (len(FieldList) <= 1)
|
||||
else:
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
return [Value, Type, Size], IsValid, 0
|
||||
elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD):
|
||||
VpdOffset = FieldList[0]
|
||||
|
@ -1550,10 +1645,11 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
|
|||
Size = FieldList[1]
|
||||
if len(FieldList) > 2:
|
||||
Value = FieldList[2]
|
||||
if DataType == 'VOID*':
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
if DataType == "":
|
||||
IsValid = (len(FieldList) <= 1)
|
||||
else:
|
||||
IsValid = (len(FieldList) <= 2)
|
||||
IsValid = (len(FieldList) <= 3)
|
||||
|
||||
return [VpdOffset, Size, Value], IsValid, 2
|
||||
elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
|
||||
HiiString = FieldList[0]
|
||||
|
@ -1682,7 +1778,7 @@ def CheckPcdDatum(Type, Value):
|
|||
return False, "Invalid value [%s] of type [%s];"\
|
||||
" must be a hexadecimal, decimal or octal in C language format." % (Value, Type)
|
||||
else:
|
||||
return False, "Invalid type [%s]; must be one of VOID*, BOOLEAN, UINT8, UINT16, UINT32, UINT64." % (Type)
|
||||
return True, "StructurePcd"
|
||||
|
||||
return True, ""
|
||||
|
||||
|
|
|
@ -246,7 +246,6 @@ class ToolDefClassObject(object):
|
|||
Value = Value.replace(Ref, self.MacroDictionary[Ref])
|
||||
else:
|
||||
Value = Value.replace(Ref, self.MacroDictionary[Ref.upper()])
|
||||
|
||||
MacroReference = gMacroRefPattern.findall(Value)
|
||||
for Ref in MacroReference:
|
||||
if Ref not in self.MacroDictionary:
|
||||
|
|
|
@ -77,6 +77,16 @@ MODEL_PCD_DYNAMIC = 4008
|
|||
MODEL_PCD_DYNAMIC_DEFAULT = 4009
|
||||
MODEL_PCD_DYNAMIC_VPD = 4010
|
||||
MODEL_PCD_DYNAMIC_HII = 4011
|
||||
MODEL_PCD_TYPE_LIST = [MODEL_PCD_FIXED_AT_BUILD,
|
||||
MODEL_PCD_PATCHABLE_IN_MODULE,
|
||||
MODEL_PCD_FEATURE_FLAG,
|
||||
MODEL_PCD_DYNAMIC_DEFAULT,
|
||||
MODEL_PCD_DYNAMIC_HII,
|
||||
MODEL_PCD_DYNAMIC_VPD,
|
||||
MODEL_PCD_DYNAMIC_EX_DEFAULT,
|
||||
MODEL_PCD_DYNAMIC_EX_HII,
|
||||
MODEL_PCD_DYNAMIC_EX_VPD
|
||||
]
|
||||
|
||||
MODEL_META_DATA_HEADER_COMMENT = 5000
|
||||
MODEL_META_DATA_HEADER = 5001
|
||||
|
|
|
@ -16,6 +16,7 @@ import Common.LongFilePathOs as os
|
|||
from Common.Misc import sdict
|
||||
from Common.Misc import RealPath2
|
||||
from Common.BuildToolError import *
|
||||
import collections
|
||||
|
||||
## PcdClassObject
|
||||
#
|
||||
|
@ -106,6 +107,63 @@ class PcdClassObject(object):
|
|||
def __hash__(self):
|
||||
return hash((self.TokenCName, self.TokenSpaceGuidCName))
|
||||
|
||||
class StructurePcd(PcdClassObject):
|
||||
def __init__(self, StructuredPcdIncludeFile="", Packages=None, Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, validateranges=[], validlists=[], expressions=[]):
|
||||
super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, validlists, expressions)
|
||||
self.StructuredPcdIncludeFile = StructuredPcdIncludeFile
|
||||
self.PackageDecs = Packages
|
||||
self.DefaultStoreName = ['STANDARD']
|
||||
self.DefaultValues = collections.OrderedDict({})
|
||||
self.PcdMode = None
|
||||
self.SkuOverrideValues = collections.OrderedDict({})
|
||||
self.FlexibleFieldName = None
|
||||
|
||||
def __repr__(self):
|
||||
return self.TypeName
|
||||
|
||||
def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0):
|
||||
self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo]
|
||||
return self.DefaultValues[FieldName]
|
||||
|
||||
def AddOverrideValue (self, FieldName, Value, SkuName, FileName="", LineNo=0):
|
||||
if SkuName not in self.SkuOverrideValues:
|
||||
self.SkuOverrideValues[SkuName] = collections.OrderedDict({})
|
||||
self.SkuOverrideValues[SkuName][FieldName] = [Value.strip(), FileName, LineNo]
|
||||
return self.SkuOverrideValues[SkuName][FieldName]
|
||||
|
||||
def SetPcdMode (self, PcdMode):
|
||||
self.PcdMode = PcdMode
|
||||
|
||||
def SetFlexibleFieldName (self, FlexibleFieldName):
|
||||
self.FlexibleFieldName = FlexibleFieldName
|
||||
|
||||
def copy(self, PcdObject):
|
||||
self.TokenCName = PcdObject.TokenCName if PcdObject.TokenCName else self.TokenCName
|
||||
self.TokenSpaceGuidCName = PcdObject.TokenSpaceGuidCName if PcdObject.TokenSpaceGuidCName else PcdObject.TokenSpaceGuidCName
|
||||
self.TokenSpaceGuidValue = PcdObject.TokenSpaceGuidValue if PcdObject.TokenSpaceGuidValue else self.TokenSpaceGuidValue
|
||||
self.Type = PcdObject.Type if PcdObject.Type else self.Type
|
||||
self.DatumType = PcdObject.DatumType if PcdObject.DatumType else self.DatumType
|
||||
self.DefaultValue = PcdObject.DefaultValue if PcdObject.DefaultValue else self.DefaultValue
|
||||
self.TokenValue = PcdObject.TokenValue if PcdObject.TokenValue else self.TokenValue
|
||||
self.MaxDatumSize = PcdObject.MaxDatumSize if PcdObject.MaxDatumSize else self.MaxDatumSize
|
||||
self.SkuInfoList = PcdObject.SkuInfoList if PcdObject.SkuInfoList else self.SkuInfoList
|
||||
self.Phase = PcdObject.Phase if PcdObject.Phase else self.Phase
|
||||
self.Pending = PcdObject.Pending if PcdObject.Pending else self.Pending
|
||||
self.IsOverrided = PcdObject.IsOverrided if PcdObject.IsOverrided else self.IsOverrided
|
||||
self.IsFromBinaryInf = PcdObject.IsFromBinaryInf if PcdObject.IsFromBinaryInf else self.IsFromBinaryInf
|
||||
self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc
|
||||
self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges
|
||||
self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
|
||||
self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
|
||||
if type(PcdObject) is StructurePcd:
|
||||
self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile
|
||||
self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs
|
||||
self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
|
||||
self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
|
||||
self.DefaultFromDSC=None
|
||||
self.OverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues
|
||||
self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName
|
||||
|
||||
## LibraryClassObject
|
||||
#
|
||||
# This Class defines LibraryClassObject used in BuildDatabase
|
||||
|
|
|
@ -0,0 +1,462 @@
|
|||
## @file
|
||||
# This file is used to create a database used by build tool
|
||||
#
|
||||
# Copyright (c) 2017, 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
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
from Common.String import *
|
||||
from Common.DataType import *
|
||||
from Common.Misc import *
|
||||
from types import *
|
||||
|
||||
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject
|
||||
|
||||
## Platform build information from DEC file
|
||||
#
|
||||
# This class is used to retrieve information stored in database and convert them
|
||||
# into PackageBuildClassObject form for easier use for AutoGen.
|
||||
#
|
||||
class DecBuildData(PackageBuildClassObject):
|
||||
# dict used to convert PCD type in database to string used by build tool
|
||||
_PCD_TYPE_STRING_ = {
|
||||
MODEL_PCD_FIXED_AT_BUILD : "FixedAtBuild",
|
||||
MODEL_PCD_PATCHABLE_IN_MODULE : "PatchableInModule",
|
||||
MODEL_PCD_FEATURE_FLAG : "FeatureFlag",
|
||||
MODEL_PCD_DYNAMIC : "Dynamic",
|
||||
MODEL_PCD_DYNAMIC_DEFAULT : "Dynamic",
|
||||
MODEL_PCD_DYNAMIC_HII : "DynamicHii",
|
||||
MODEL_PCD_DYNAMIC_VPD : "DynamicVpd",
|
||||
MODEL_PCD_DYNAMIC_EX : "DynamicEx",
|
||||
MODEL_PCD_DYNAMIC_EX_DEFAULT : "DynamicEx",
|
||||
MODEL_PCD_DYNAMIC_EX_HII : "DynamicExHii",
|
||||
MODEL_PCD_DYNAMIC_EX_VPD : "DynamicExVpd",
|
||||
}
|
||||
|
||||
# dict used to convert part of [Defines] to members of DecBuildData directly
|
||||
_PROPERTY_ = {
|
||||
#
|
||||
# Required Fields
|
||||
#
|
||||
TAB_DEC_DEFINES_PACKAGE_NAME : "_PackageName",
|
||||
TAB_DEC_DEFINES_PACKAGE_GUID : "_Guid",
|
||||
TAB_DEC_DEFINES_PACKAGE_VERSION : "_Version",
|
||||
TAB_DEC_DEFINES_PKG_UNI_FILE : "_PkgUniFile",
|
||||
}
|
||||
|
||||
|
||||
## Constructor of DecBuildData
|
||||
#
|
||||
# Initialize object of DecBuildData
|
||||
#
|
||||
# @param FilePath The path of package description file
|
||||
# @param RawData The raw data of DEC file
|
||||
# @param BuildDataBase Database used to retrieve module information
|
||||
# @param Arch The target architecture
|
||||
# @param Platform (not used for DecBuildData)
|
||||
# @param Macros Macros used for replacement in DSC file
|
||||
#
|
||||
def __init__(self, File, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):
|
||||
self.MetaFile = File
|
||||
self._PackageDir = File.Dir
|
||||
self._RawData = RawData
|
||||
self._Bdb = BuildDataBase
|
||||
self._Arch = Arch
|
||||
self._Target = Target
|
||||
self._Toolchain = Toolchain
|
||||
self._Clear()
|
||||
|
||||
## XXX[key] = value
|
||||
def __setitem__(self, key, value):
|
||||
self.__dict__[self._PROPERTY_[key]] = value
|
||||
|
||||
## value = XXX[key]
|
||||
def __getitem__(self, key):
|
||||
return self.__dict__[self._PROPERTY_[key]]
|
||||
|
||||
## "in" test support
|
||||
def __contains__(self, key):
|
||||
return key in self._PROPERTY_
|
||||
|
||||
## Set all internal used members of DecBuildData to None
|
||||
def _Clear(self):
|
||||
self._Header = None
|
||||
self._PackageName = None
|
||||
self._Guid = None
|
||||
self._Version = None
|
||||
self._PkgUniFile = None
|
||||
self._Protocols = None
|
||||
self._Ppis = None
|
||||
self._Guids = None
|
||||
self._Includes = None
|
||||
self._LibraryClasses = None
|
||||
self._Pcds = None
|
||||
self.__Macros = None
|
||||
self._PrivateProtocols = None
|
||||
self._PrivatePpis = None
|
||||
self._PrivateGuids = None
|
||||
self._PrivateIncludes = None
|
||||
|
||||
## Get current effective macros
|
||||
def _GetMacros(self):
|
||||
if self.__Macros == None:
|
||||
self.__Macros = {}
|
||||
self.__Macros.update(GlobalData.gGlobalDefines)
|
||||
return self.__Macros
|
||||
|
||||
## Get architecture
|
||||
def _GetArch(self):
|
||||
return self._Arch
|
||||
|
||||
## Set architecture
|
||||
#
|
||||
# Changing the default ARCH to another may affect all other information
|
||||
# because all information in a platform may be ARCH-related. That's
|
||||
# why we need to clear all internal used members, in order to cause all
|
||||
# information to be re-retrieved.
|
||||
#
|
||||
# @param Value The value of ARCH
|
||||
#
|
||||
def _SetArch(self, Value):
|
||||
if self._Arch == Value:
|
||||
return
|
||||
self._Arch = Value
|
||||
self._Clear()
|
||||
|
||||
## Retrieve all information in [Defines] section
|
||||
#
|
||||
# (Retriving all [Defines] information in one-shot is just to save time.)
|
||||
#
|
||||
def _GetHeaderInfo(self):
|
||||
RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch]
|
||||
for Record in RecordList:
|
||||
Name = Record[1]
|
||||
if Name in self:
|
||||
self[Name] = Record[2]
|
||||
self._Header = 'DUMMY'
|
||||
|
||||
## Retrieve package name
|
||||
def _GetPackageName(self):
|
||||
if self._PackageName == None:
|
||||
if self._Header == None:
|
||||
self._GetHeaderInfo()
|
||||
if self._PackageName == None:
|
||||
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", File=self.MetaFile)
|
||||
return self._PackageName
|
||||
|
||||
## Retrieve file guid
|
||||
def _GetFileGuid(self):
|
||||
if self._Guid == None:
|
||||
if self._Header == None:
|
||||
self._GetHeaderInfo()
|
||||
if self._Guid == None:
|
||||
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", File=self.MetaFile)
|
||||
return self._Guid
|
||||
|
||||
## Retrieve package version
|
||||
def _GetVersion(self):
|
||||
if self._Version == None:
|
||||
if self._Header == None:
|
||||
self._GetHeaderInfo()
|
||||
if self._Version == None:
|
||||
self._Version = ''
|
||||
return self._Version
|
||||
|
||||
## Retrieve protocol definitions (name/value pairs)
|
||||
def _GetProtocol(self):
|
||||
if self._Protocols == None:
|
||||
#
|
||||
# tdict is a special kind of dict, used for selecting correct
|
||||
# protocol defition for given ARCH
|
||||
#
|
||||
ProtocolDict = tdict(True)
|
||||
PrivateProtocolDict = tdict(True)
|
||||
NameList = []
|
||||
PrivateNameList = []
|
||||
PublicNameList = []
|
||||
# find out all protocol definitions for specific and 'common' arch
|
||||
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch]
|
||||
for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:
|
||||
if PrivateFlag == 'PRIVATE':
|
||||
if Name not in PrivateNameList:
|
||||
PrivateNameList.append(Name)
|
||||
PrivateProtocolDict[Arch, Name] = Guid
|
||||
if Name in PublicNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
else:
|
||||
if Name not in PublicNameList:
|
||||
PublicNameList.append(Name)
|
||||
if Name in PrivateNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
if Name not in NameList:
|
||||
NameList.append(Name)
|
||||
ProtocolDict[Arch, Name] = Guid
|
||||
# use sdict to keep the order
|
||||
self._Protocols = sdict()
|
||||
self._PrivateProtocols = sdict()
|
||||
for Name in NameList:
|
||||
#
|
||||
# limit the ARCH to self._Arch, if no self._Arch found, tdict
|
||||
# will automatically turn to 'common' ARCH for trying
|
||||
#
|
||||
self._Protocols[Name] = ProtocolDict[self._Arch, Name]
|
||||
for Name in PrivateNameList:
|
||||
self._PrivateProtocols[Name] = PrivateProtocolDict[self._Arch, Name]
|
||||
return self._Protocols
|
||||
|
||||
## Retrieve PPI definitions (name/value pairs)
|
||||
def _GetPpi(self):
|
||||
if self._Ppis == None:
|
||||
#
|
||||
# tdict is a special kind of dict, used for selecting correct
|
||||
# PPI defition for given ARCH
|
||||
#
|
||||
PpiDict = tdict(True)
|
||||
PrivatePpiDict = tdict(True)
|
||||
NameList = []
|
||||
PrivateNameList = []
|
||||
PublicNameList = []
|
||||
# find out all PPI definitions for specific arch and 'common' arch
|
||||
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch]
|
||||
for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:
|
||||
if PrivateFlag == 'PRIVATE':
|
||||
if Name not in PrivateNameList:
|
||||
PrivateNameList.append(Name)
|
||||
PrivatePpiDict[Arch, Name] = Guid
|
||||
if Name in PublicNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
else:
|
||||
if Name not in PublicNameList:
|
||||
PublicNameList.append(Name)
|
||||
if Name in PrivateNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
if Name not in NameList:
|
||||
NameList.append(Name)
|
||||
PpiDict[Arch, Name] = Guid
|
||||
# use sdict to keep the order
|
||||
self._Ppis = sdict()
|
||||
self._PrivatePpis = sdict()
|
||||
for Name in NameList:
|
||||
#
|
||||
# limit the ARCH to self._Arch, if no self._Arch found, tdict
|
||||
# will automatically turn to 'common' ARCH for trying
|
||||
#
|
||||
self._Ppis[Name] = PpiDict[self._Arch, Name]
|
||||
for Name in PrivateNameList:
|
||||
self._PrivatePpis[Name] = PrivatePpiDict[self._Arch, Name]
|
||||
return self._Ppis
|
||||
|
||||
## Retrieve GUID definitions (name/value pairs)
|
||||
def _GetGuid(self):
|
||||
if self._Guids == None:
|
||||
#
|
||||
# tdict is a special kind of dict, used for selecting correct
|
||||
# GUID defition for given ARCH
|
||||
#
|
||||
GuidDict = tdict(True)
|
||||
PrivateGuidDict = tdict(True)
|
||||
NameList = []
|
||||
PrivateNameList = []
|
||||
PublicNameList = []
|
||||
# find out all protocol definitions for specific and 'common' arch
|
||||
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]
|
||||
for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:
|
||||
if PrivateFlag == 'PRIVATE':
|
||||
if Name not in PrivateNameList:
|
||||
PrivateNameList.append(Name)
|
||||
PrivateGuidDict[Arch, Name] = Guid
|
||||
if Name in PublicNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
else:
|
||||
if Name not in PublicNameList:
|
||||
PublicNameList.append(Name)
|
||||
if Name in PrivateNameList:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)
|
||||
if Name not in NameList:
|
||||
NameList.append(Name)
|
||||
GuidDict[Arch, Name] = Guid
|
||||
# use sdict to keep the order
|
||||
self._Guids = sdict()
|
||||
self._PrivateGuids = sdict()
|
||||
for Name in NameList:
|
||||
#
|
||||
# limit the ARCH to self._Arch, if no self._Arch found, tdict
|
||||
# will automatically turn to 'common' ARCH for trying
|
||||
#
|
||||
self._Guids[Name] = GuidDict[self._Arch, Name]
|
||||
for Name in PrivateNameList:
|
||||
self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name]
|
||||
return self._Guids
|
||||
|
||||
## Retrieve public include paths declared in this package
|
||||
def _GetInclude(self):
|
||||
if self._Includes == None:
|
||||
self._Includes = []
|
||||
self._PrivateIncludes = []
|
||||
PublicInclues = []
|
||||
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]
|
||||
Macros = self._Macros
|
||||
Macros["EDK_SOURCE"] = GlobalData.gEcpSource
|
||||
for Record in RecordList:
|
||||
File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)
|
||||
LineNo = Record[-1]
|
||||
# validate the path
|
||||
ErrorCode, ErrorInfo = File.Validate()
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
|
||||
|
||||
# avoid duplicate include path
|
||||
if File not in self._Includes:
|
||||
self._Includes.append(File)
|
||||
if Record[4] == 'PRIVATE':
|
||||
if File not in self._PrivateIncludes:
|
||||
self._PrivateIncludes.append(File)
|
||||
if File in PublicInclues:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)
|
||||
else:
|
||||
if File not in PublicInclues:
|
||||
PublicInclues.append(File)
|
||||
if File in self._PrivateIncludes:
|
||||
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)
|
||||
|
||||
return self._Includes
|
||||
|
||||
## Retrieve library class declarations (not used in build at present)
|
||||
def _GetLibraryClass(self):
|
||||
if self._LibraryClasses == None:
|
||||
#
|
||||
# tdict is a special kind of dict, used for selecting correct
|
||||
# library class declaration for given ARCH
|
||||
#
|
||||
LibraryClassDict = tdict(True)
|
||||
LibraryClassSet = set()
|
||||
RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch]
|
||||
Macros = self._Macros
|
||||
for LibraryClass, File, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:
|
||||
File = PathClass(NormPath(File, Macros), self._PackageDir, Arch=self._Arch)
|
||||
# check the file validation
|
||||
ErrorCode, ErrorInfo = File.Validate()
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
|
||||
LibraryClassSet.add(LibraryClass)
|
||||
LibraryClassDict[Arch, LibraryClass] = File
|
||||
self._LibraryClasses = sdict()
|
||||
for LibraryClass in LibraryClassSet:
|
||||
self._LibraryClasses[LibraryClass] = LibraryClassDict[self._Arch, LibraryClass]
|
||||
return self._LibraryClasses
|
||||
|
||||
## Retrieve PCD declarations
|
||||
def _GetPcds(self):
|
||||
if self._Pcds == None:
|
||||
self._Pcds = sdict()
|
||||
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
|
||||
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
|
||||
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
|
||||
self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC))
|
||||
self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
|
||||
return self._Pcds
|
||||
|
||||
|
||||
def ProcessStructurePcd(self, StructurePcdRawDataSet):
|
||||
s_pcd_set = dict()
|
||||
for s_pcd,LineNo in StructurePcdRawDataSet:
|
||||
if s_pcd.TokenSpaceGuidCName not in s_pcd_set:
|
||||
s_pcd_set[s_pcd.TokenSpaceGuidCName] = []
|
||||
s_pcd_set[s_pcd.TokenSpaceGuidCName].append((s_pcd,LineNo))
|
||||
|
||||
str_pcd_set = []
|
||||
for pcdname in s_pcd_set:
|
||||
dep_pkgs = []
|
||||
struct_pcd = StructurePcd()
|
||||
for item,LineNo in s_pcd_set[pcdname]:
|
||||
if "<HeaderFiles>" in item.TokenCName:
|
||||
struct_pcd.StructuredPcdIncludeFile = item.DefaultValue
|
||||
elif "<Packages>" in item.TokenCName:
|
||||
dep_pkgs.append(item.DefaultValue)
|
||||
elif item.DatumType == item.TokenCName:
|
||||
struct_pcd.copy(item)
|
||||
struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip()
|
||||
struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")
|
||||
else:
|
||||
struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
|
||||
|
||||
struct_pcd.PackageDecs = dep_pkgs
|
||||
|
||||
str_pcd_set.append(struct_pcd)
|
||||
|
||||
return str_pcd_set
|
||||
|
||||
## Retrieve PCD declarations for given type
|
||||
def _GetPcd(self, Type):
|
||||
Pcds = sdict()
|
||||
#
|
||||
# tdict is a special kind of dict, used for selecting correct
|
||||
# PCD declaration for given ARCH
|
||||
#
|
||||
PcdDict = tdict(True, 3)
|
||||
# for summarizing PCD
|
||||
PcdSet = set()
|
||||
# find out all PCDs of the 'type'
|
||||
|
||||
StrPcdSet = []
|
||||
RecordList = self._RawData[Type, self._Arch]
|
||||
for TokenSpaceGuid, PcdCName, Setting, Arch, PrivateFlag, Dummy1, Dummy2 in RecordList:
|
||||
PcdDict[Arch, PcdCName, TokenSpaceGuid] = (Setting,Dummy2)
|
||||
PcdSet.add((PcdCName, TokenSpaceGuid))
|
||||
|
||||
for PcdCName, TokenSpaceGuid in PcdSet:
|
||||
#
|
||||
# limit the ARCH to self._Arch, if no self._Arch found, tdict
|
||||
# will automatically turn to 'common' ARCH and try again
|
||||
#
|
||||
Setting,LineNo = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]
|
||||
if Setting == None:
|
||||
continue
|
||||
|
||||
DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)
|
||||
validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
|
||||
PcdObj = PcdClassObject(
|
||||
PcdCName,
|
||||
TokenSpaceGuid,
|
||||
self._PCD_TYPE_STRING_[Type],
|
||||
DatumType,
|
||||
DefaultValue,
|
||||
TokenNumber,
|
||||
'',
|
||||
{},
|
||||
False,
|
||||
None,
|
||||
list(validateranges),
|
||||
list(validlists),
|
||||
list(expressions)
|
||||
)
|
||||
if "." in TokenSpaceGuid:
|
||||
StrPcdSet.append((PcdObj,LineNo))
|
||||
else:
|
||||
Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj
|
||||
|
||||
StructurePcds = self.ProcessStructurePcd(StrPcdSet)
|
||||
for pcd in StructurePcds:
|
||||
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
|
||||
|
||||
return Pcds
|
||||
|
||||
|
||||
_Macros = property(_GetMacros)
|
||||
Arch = property(_GetArch, _SetArch)
|
||||
PackageName = property(_GetPackageName)
|
||||
Guid = property(_GetFileGuid)
|
||||
Version = property(_GetVersion)
|
||||
|
||||
Protocols = property(_GetProtocol)
|
||||
Ppis = property(_GetPpi)
|
||||
Guids = property(_GetGuid)
|
||||
Includes = property(_GetInclude)
|
||||
LibraryClasses = property(_GetLibraryClass)
|
||||
Pcds = property(_GetPcds)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -19,6 +19,7 @@ import Common.LongFilePathOs as os
|
|||
import re
|
||||
import time
|
||||
import copy
|
||||
import md5
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
import Common.GlobalData as GlobalData
|
||||
|
@ -1116,6 +1117,11 @@ class DscParser(MetaFileParser):
|
|||
def _PcdParser(self):
|
||||
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)
|
||||
self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
||||
PcdNameTockens = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
||||
if len(PcdNameTockens) == 2:
|
||||
self._ValueList[0], self._ValueList[1] = PcdNameTockens[0], PcdNameTockens[1]
|
||||
elif len(PcdNameTockens) == 3:
|
||||
self._ValueList[0], self._ValueList[1] = ".".join((PcdNameTockens[0], PcdNameTockens[1])), PcdNameTockens[2]
|
||||
if len(TokenList) == 2:
|
||||
self._ValueList[2] = TokenList[1]
|
||||
if self._ValueList[0] == '' or self._ValueList[1] == '':
|
||||
|
@ -1134,7 +1140,7 @@ class DscParser(MetaFileParser):
|
|||
|
||||
# Validate the datum type of Dynamic Defaul PCD and DynamicEx Default PCD
|
||||
ValueList = GetSplitValueList(self._ValueList[2])
|
||||
if len(ValueList) > 1 and ValueList[1] != TAB_VOID \
|
||||
if len(ValueList) > 1 and ValueList[1] in [TAB_UINT8 , TAB_UINT16, TAB_UINT32 , TAB_UINT64] \
|
||||
and self._ItemType in [MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT]:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "The datum type '%s' of PCD is wrong" % ValueList[1],
|
||||
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
|
@ -1560,7 +1566,7 @@ class DscParser(MetaFileParser):
|
|||
EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self._FileWithError, Line=self._LineIndex + 1,
|
||||
ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2]))
|
||||
PcdValue = ValList[Index]
|
||||
if PcdValue:
|
||||
if PcdValue and "." not in self._ValueList[0]:
|
||||
try:
|
||||
ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)
|
||||
except WrnExpression, Value:
|
||||
|
@ -1574,7 +1580,10 @@ class DscParser(MetaFileParser):
|
|||
if (not self._DirectiveEvalStack) or (False not in self._DirectiveEvalStack):
|
||||
GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue
|
||||
self._Symbols[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue
|
||||
self._ValueList[2] = '|'.join(ValList)
|
||||
try:
|
||||
self._ValueList[2] = '|'.join(ValList)
|
||||
except Exception:
|
||||
print ValList
|
||||
|
||||
def __ProcessComponent(self):
|
||||
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
|
||||
|
@ -1655,6 +1664,10 @@ class DecParser(MetaFileParser):
|
|||
self._AllPCDs = [] # Only for check duplicate PCD
|
||||
self._AllPcdDict = {}
|
||||
|
||||
self._CurrentStructurePcdName = ""
|
||||
self._include_flag = False
|
||||
self._package_flag = False
|
||||
|
||||
## Parser starter
|
||||
def Start(self):
|
||||
Content = ''
|
||||
|
@ -1847,105 +1860,143 @@ class DecParser(MetaFileParser):
|
|||
#
|
||||
@ParseMacro
|
||||
def _PcdParser(self):
|
||||
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)
|
||||
self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
||||
ValueRe = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*')
|
||||
# check PCD information
|
||||
if self._ValueList[0] == '' or self._ValueList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check format of token space GUID CName
|
||||
if not ValueRe.match(self._ValueList[0]):
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "The format of the token space GUID CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check format of PCD CName
|
||||
if not ValueRe.match(self._ValueList[1]):
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "The format of the PCD CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check PCD datum information
|
||||
if len(TokenList) < 2 or TokenList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum information given",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
if self._CurrentStructurePcdName:
|
||||
self._ValueList[0] = self._CurrentStructurePcdName
|
||||
|
||||
if "|" not in self._CurrentLine:
|
||||
if "<HeaderFiles>" == self._CurrentLine:
|
||||
self._include_flag = True
|
||||
self._ValueList = None
|
||||
return
|
||||
if "<Packages>" == self._CurrentLine:
|
||||
self._package_flag = True
|
||||
self._ValueList = None
|
||||
return
|
||||
|
||||
if self._include_flag:
|
||||
self._ValueList[1] = "<HeaderFiles>_" + md5.new(self._CurrentLine).hexdigest()
|
||||
self._ValueList[2] = self._CurrentLine
|
||||
self._include_flag = False
|
||||
if self._package_flag and "}" != self._CurrentLine:
|
||||
self._ValueList[1] = "<Packages>_" + md5.new(self._CurrentLine).hexdigest()
|
||||
self._ValueList[2] = self._CurrentLine
|
||||
if self._CurrentLine == "}":
|
||||
self._package_flag = False
|
||||
self._ValueList = None
|
||||
return
|
||||
else:
|
||||
PcdTockens = self._CurrentLine.split(TAB_VALUE_SPLIT)
|
||||
PcdNames = PcdTockens[0].split(TAB_SPLIT)
|
||||
if len(PcdNames) == 2:
|
||||
self._CurrentStructurePcdName = ""
|
||||
else:
|
||||
self._ValueList[1] = PcdNames[2]
|
||||
self._ValueList[2] = PcdTockens[1]
|
||||
if not self._CurrentStructurePcdName:
|
||||
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)
|
||||
self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)
|
||||
ValueRe = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*')
|
||||
# check PCD information
|
||||
if self._ValueList[0] == '' or self._ValueList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check format of token space GUID CName
|
||||
if not ValueRe.match(self._ValueList[0]):
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "The format of the token space GUID CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check format of PCD CName
|
||||
if not ValueRe.match(self._ValueList[1]):
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "The format of the PCD CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check PCD datum information
|
||||
if len(TokenList) < 2 or TokenList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum information given",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
|
||||
|
||||
ValueRe = re.compile(r'^\s*L?\".*\|.*\"')
|
||||
PtrValue = ValueRe.findall(TokenList[1])
|
||||
ValueRe = re.compile(r'^\s*L?\".*\|.*\"')
|
||||
PtrValue = ValueRe.findall(TokenList[1])
|
||||
|
||||
# Has VOID* type string, may contain "|" character in the string.
|
||||
if len(PtrValue) != 0:
|
||||
ptrValueList = re.sub(ValueRe, '', TokenList[1])
|
||||
ValueList = AnalyzePcdExpression(ptrValueList)
|
||||
ValueList[0] = PtrValue[0]
|
||||
else:
|
||||
ValueList = AnalyzePcdExpression(TokenList[1])
|
||||
# Has VOID* type string, may contain "|" character in the string.
|
||||
if len(PtrValue) != 0:
|
||||
ptrValueList = re.sub(ValueRe, '', TokenList[1])
|
||||
ValueList = AnalyzePcdExpression(ptrValueList)
|
||||
ValueList[0] = PtrValue[0]
|
||||
else:
|
||||
ValueList = AnalyzePcdExpression(TokenList[1])
|
||||
|
||||
|
||||
# check if there's enough datum information given
|
||||
if len(ValueList) != 3:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Datum information given",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check default value
|
||||
if ValueList[0] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing DefaultValue in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check datum type
|
||||
if ValueList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumType in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check token of the PCD
|
||||
if ValueList[2] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check if there's enough datum information given
|
||||
if len(ValueList) != 3:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Datum information given",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check default value
|
||||
if ValueList[0] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing DefaultValue in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check datum type
|
||||
if ValueList[1] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumType in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check token of the PCD
|
||||
if ValueList[2] == '':
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token in PCD Datum information",
|
||||
ExtraData=self._CurrentLine + \
|
||||
" (<TokenSpaceGuidCName>.<PcdCName>|<DefaultValue>|<DatumType>|<Token>)",
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
|
||||
PcdValue = ValueList[0]
|
||||
if PcdValue:
|
||||
try:
|
||||
ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True)
|
||||
except WrnExpression, Value:
|
||||
ValueList[0] = Value.result
|
||||
PcdValue = ValueList[0]
|
||||
if PcdValue:
|
||||
try:
|
||||
ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True)
|
||||
except WrnExpression, Value:
|
||||
ValueList[0] = Value.result
|
||||
|
||||
if ValueList[0] == 'True':
|
||||
ValueList[0] = '1'
|
||||
if ValueList[0] == 'False':
|
||||
ValueList[0] = '0'
|
||||
if ValueList[0] == 'True':
|
||||
ValueList[0] = '1'
|
||||
if ValueList[0] == 'False':
|
||||
ValueList[0] = '0'
|
||||
|
||||
# check format of default value against the datum type
|
||||
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
|
||||
if not IsValid:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, Cause, ExtraData=self._CurrentLine,
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
# check format of default value against the datum type
|
||||
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
|
||||
if not IsValid:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID, Cause, ExtraData=self._CurrentLine,
|
||||
File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
|
||||
if ValueList[0] in ['True', 'true', 'TRUE']:
|
||||
ValueList[0] = '1'
|
||||
elif ValueList[0] in ['False', 'false', 'FALSE']:
|
||||
ValueList[0] = '0'
|
||||
if Cause == "StructurePcd":
|
||||
self._CurrentStructurePcdName = TAB_SPLIT.join(self._ValueList[0:2])
|
||||
self._ValueList[0] = self._CurrentStructurePcdName
|
||||
self._ValueList[1] = ValueList[1].strip()
|
||||
|
||||
# check for duplicate PCD definition
|
||||
if (self._Scope[0], self._ValueList[0], self._ValueList[1]) in self._AllPCDs:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID,
|
||||
"The same PCD name and GUID have been already defined",
|
||||
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
else:
|
||||
self._AllPCDs.append((self._Scope[0], self._ValueList[0], self._ValueList[1]))
|
||||
self._AllPcdDict[TAB_SPLIT.join(self._ValueList[0:2])] = ValueList[0]
|
||||
if ValueList[0] in ['True', 'true', 'TRUE']:
|
||||
ValueList[0] = '1'
|
||||
elif ValueList[0] in ['False', 'false', 'FALSE']:
|
||||
ValueList[0] = '0'
|
||||
|
||||
self._ValueList[2] = ValueList[0].strip() + '|' + ValueList[1].strip() + '|' + ValueList[2].strip()
|
||||
# check for duplicate PCD definition
|
||||
if (self._Scope[0], self._ValueList[0], self._ValueList[1]) in self._AllPCDs:
|
||||
EdkLogger.error('Parser', FORMAT_INVALID,
|
||||
"The same PCD name and GUID have been already defined",
|
||||
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
|
||||
else:
|
||||
self._AllPCDs.append((self._Scope[0], self._ValueList[0], self._ValueList[1]))
|
||||
self._AllPcdDict[TAB_SPLIT.join(self._ValueList[0:2])] = ValueList[0]
|
||||
|
||||
self._ValueList[2] = ValueList[0].strip() + '|' + ValueList[1].strip() + '|' + ValueList[2].strip()
|
||||
|
||||
_SectionParser = {
|
||||
MODEL_META_DATA_HEADER : MetaFileParser._DefineParser,
|
||||
|
|
|
@ -15,6 +15,7 @@ from Common.Misc import sdict
|
|||
from Common.DataType import SUP_MODULE_USER_DEFINED
|
||||
from BuildClassObject import LibraryClassObject
|
||||
import Common.GlobalData as GlobalData
|
||||
from Workspace.BuildClassObject import StructurePcd
|
||||
|
||||
## Get all packages from platform for specified arch, target and toolchain
|
||||
#
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue