mirror of https://github.com/acidanthera/audk.git
BaseTools: Fixed the issue of structure pcd filed sku inherit override
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Feng Bob C <bob.c.feng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
8ac167890f
commit
c05c2c0526
|
@ -2145,12 +2145,21 @@ class SkuClass():
|
||||||
def __init__(self,SkuIdentifier='', SkuIds=None):
|
def __init__(self,SkuIdentifier='', SkuIds=None):
|
||||||
if SkuIds is None:
|
if SkuIds is None:
|
||||||
SkuIds = {}
|
SkuIds = {}
|
||||||
|
|
||||||
|
for SkuName in SkuIds:
|
||||||
|
SkuId = SkuIds[SkuName][0]
|
||||||
|
skuid_num = int(SkuId,16) if SkuId.upper().startswith("0X") else int(SkuId)
|
||||||
|
if skuid_num > 0xFFFF:
|
||||||
|
EdkLogger.error("build", PARAMETER_INVALID,
|
||||||
|
ExtraData = "SKU-ID [%s] must less than 65535"
|
||||||
|
% (SkuName))
|
||||||
|
|
||||||
self.AvailableSkuIds = sdict()
|
self.AvailableSkuIds = sdict()
|
||||||
self.SkuIdSet = []
|
self.SkuIdSet = []
|
||||||
self.SkuIdNumberSet = []
|
self.SkuIdNumberSet = []
|
||||||
self.SkuData = SkuIds
|
self.SkuData = SkuIds
|
||||||
self.__SkuInherit = {}
|
self.__SkuInherit = {}
|
||||||
|
self.__SkuIdentifier = SkuIdentifier
|
||||||
if SkuIdentifier == '' or SkuIdentifier is None:
|
if SkuIdentifier == '' or SkuIdentifier is None:
|
||||||
self.SkuIdSet = ['DEFAULT']
|
self.SkuIdSet = ['DEFAULT']
|
||||||
self.SkuIdNumberSet = ['0U']
|
self.SkuIdNumberSet = ['0U']
|
||||||
|
@ -2189,14 +2198,48 @@ class SkuClass():
|
||||||
for item in self.SkuData.values():
|
for item in self.SkuData.values():
|
||||||
self.__SkuInherit[item[1]]=item[2] if item[2] else "DEFAULT"
|
self.__SkuInherit[item[1]]=item[2] if item[2] else "DEFAULT"
|
||||||
return self.__SkuInherit.get(skuname,"DEFAULT")
|
return self.__SkuInherit.get(skuname,"DEFAULT")
|
||||||
|
|
||||||
|
def GetSkuChain(self,sku):
|
||||||
|
skulist = [sku]
|
||||||
|
nextsku = sku
|
||||||
|
while 1:
|
||||||
|
nextsku = self.GetNextSkuId(nextsku)
|
||||||
|
skulist.append(nextsku)
|
||||||
|
if nextsku == "DEFAULT":
|
||||||
|
break
|
||||||
|
skulist.reverse()
|
||||||
|
return skulist
|
||||||
|
def SkuOverrideOrder(self):
|
||||||
|
skuorderset = []
|
||||||
|
for skuname in self.SkuIdSet:
|
||||||
|
skuorderset.append(self.GetSkuChain(skuname))
|
||||||
|
|
||||||
|
skuorder = []
|
||||||
|
for index in range(max([len(item) for item in skuorderset])):
|
||||||
|
for subset in skuorderset:
|
||||||
|
if index > len(subset)-1:
|
||||||
|
continue
|
||||||
|
if subset[index] in skuorder:
|
||||||
|
continue
|
||||||
|
skuorder.append(subset[index])
|
||||||
|
|
||||||
|
return skuorder
|
||||||
|
|
||||||
def __SkuUsageType(self):
|
def __SkuUsageType(self):
|
||||||
|
|
||||||
|
if self.__SkuIdentifier.upper() == "ALL":
|
||||||
|
return SkuClass.MULTIPLE
|
||||||
|
|
||||||
if len(self.SkuIdSet) == 1:
|
if len(self.SkuIdSet) == 1:
|
||||||
if self.SkuIdSet[0] == 'DEFAULT':
|
if self.SkuIdSet[0] == 'DEFAULT':
|
||||||
return SkuClass.DEFAULT
|
return SkuClass.DEFAULT
|
||||||
else:
|
else:
|
||||||
return SkuClass.SINGLE
|
return SkuClass.SINGLE
|
||||||
|
elif len(self.SkuIdSet) == 2:
|
||||||
|
if 'DEFAULT' in self.SkuIdSet:
|
||||||
|
return SkuClass.SINGLE
|
||||||
|
else:
|
||||||
|
return SkuClass.MULTIPLE
|
||||||
else:
|
else:
|
||||||
return SkuClass.MULTIPLE
|
return SkuClass.MULTIPLE
|
||||||
def DumpSkuIdArrary(self):
|
def DumpSkuIdArrary(self):
|
||||||
|
@ -2219,7 +2262,10 @@ class SkuClass():
|
||||||
|
|
||||||
def __GetSystemSkuID(self):
|
def __GetSystemSkuID(self):
|
||||||
if self.__SkuUsageType() == SkuClass.SINGLE:
|
if self.__SkuUsageType() == SkuClass.SINGLE:
|
||||||
return self.SkuIdSet[0]
|
if len(self.SkuIdSet) == 1:
|
||||||
|
return self.SkuIdSet[0]
|
||||||
|
else:
|
||||||
|
return self.SkuIdSet[0] if self.SkuIdSet[0] != 'DEFAULT' else self.SkuIdSet[1]
|
||||||
else:
|
else:
|
||||||
return 'DEFAULT'
|
return 'DEFAULT'
|
||||||
def __GetAvailableSkuIdNumber(self):
|
def __GetAvailableSkuIdNumber(self):
|
||||||
|
|
|
@ -916,6 +916,8 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
for CodeBase in (EDKII_NAME, EDK_NAME):
|
for CodeBase in (EDKII_NAME, EDK_NAME):
|
||||||
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase]
|
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase]
|
||||||
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
|
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
|
||||||
|
if Dummy3.upper() != 'COMMON':
|
||||||
|
continue
|
||||||
CurKey = (ToolChainFamily, ToolChain, CodeBase)
|
CurKey = (ToolChainFamily, ToolChain, CodeBase)
|
||||||
#
|
#
|
||||||
# Only flags can be appended
|
# Only flags can be appended
|
||||||
|
@ -923,7 +925,8 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
if CurKey not in self._BuildOptions or not ToolChain.endswith('_FLAGS') or Option.startswith('='):
|
if CurKey not in self._BuildOptions or not ToolChain.endswith('_FLAGS') or Option.startswith('='):
|
||||||
self._BuildOptions[CurKey] = Option
|
self._BuildOptions[CurKey] = Option
|
||||||
else:
|
else:
|
||||||
self._BuildOptions[CurKey] += ' ' + Option
|
if ' ' + Option not in self._BuildOptions[CurKey]:
|
||||||
|
self._BuildOptions[CurKey] += ' ' + Option
|
||||||
return self._BuildOptions
|
return self._BuildOptions
|
||||||
|
|
||||||
def GetBuildOptionsByModuleType(self, Edk, ModuleType):
|
def GetBuildOptionsByModuleType(self, Edk, ModuleType):
|
||||||
|
@ -934,14 +937,16 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
self._ModuleTypeOptions[Edk, ModuleType] = options
|
self._ModuleTypeOptions[Edk, ModuleType] = options
|
||||||
DriverType = '%s.%s' % (Edk, ModuleType)
|
DriverType = '%s.%s' % (Edk, ModuleType)
|
||||||
CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
|
CommonDriverType = '%s.%s' % ('COMMON', ModuleType)
|
||||||
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, DriverType]
|
RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch]
|
||||||
for ToolChainFamily, ToolChain, Option, Arch, Type, Dummy3, Dummy4,Dummy5 in RecordList:
|
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
|
||||||
if Type == DriverType or Type == CommonDriverType:
|
Type = Dummy2 + '.' + Dummy3
|
||||||
|
if Type.upper() == DriverType.upper() or Type.upper() == CommonDriverType.upper():
|
||||||
Key = (ToolChainFamily, ToolChain, Edk)
|
Key = (ToolChainFamily, ToolChain, Edk)
|
||||||
if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='):
|
if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='):
|
||||||
options[Key] = Option
|
options[Key] = Option
|
||||||
else:
|
else:
|
||||||
options[Key] += ' ' + Option
|
if ' ' + Option not in options[Key]:
|
||||||
|
options[Key] += ' ' + Option
|
||||||
return self._ModuleTypeOptions[Edk, ModuleType]
|
return self._ModuleTypeOptions[Edk, ModuleType]
|
||||||
|
|
||||||
def GetStructurePcdInfo(self, PcdSet):
|
def GetStructurePcdInfo(self, PcdSet):
|
||||||
|
@ -1021,8 +1026,6 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
if S_pcd_set:
|
if S_pcd_set:
|
||||||
GlobalData.gStructurePcd[self.Arch] = S_pcd_set
|
GlobalData.gStructurePcd[self.Arch] = S_pcd_set
|
||||||
for stru_pcd in S_pcd_set.values():
|
for stru_pcd in S_pcd_set.values():
|
||||||
if stru_pcd.Type not in DynamicPcdType:
|
|
||||||
continue
|
|
||||||
for skuid in SkuIds:
|
for skuid in SkuIds:
|
||||||
if skuid in stru_pcd.SkuOverrideValues:
|
if skuid in stru_pcd.SkuOverrideValues:
|
||||||
continue
|
continue
|
||||||
|
@ -1299,25 +1302,29 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
# OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)
|
# OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)
|
||||||
#
|
#
|
||||||
CApp = CApp + ' Size = sizeof(%s);\n' % (Pcd.DatumType)
|
CApp = CApp + ' Size = sizeof(%s);\n' % (Pcd.DatumType)
|
||||||
for FieldList in [Pcd.DefaultValues, OverrideValues.get(DefaultStoreName)]:
|
for skuname in self.SkuIdMgr.SkuOverrideOrder():
|
||||||
if not FieldList:
|
inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
|
||||||
continue
|
for FieldList in [Pcd.DefaultValues, inherit_OverrideValues.get(DefaultStoreName)]:
|
||||||
for FieldName in FieldList:
|
if not FieldList:
|
||||||
FieldName = "." + FieldName
|
continue
|
||||||
IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
|
for FieldName in FieldList:
|
||||||
if IsArray:
|
FieldName = "." + FieldName
|
||||||
Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0])
|
IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."));
|
if IsArray:
|
||||||
else:
|
Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0])
|
||||||
NewFieldName = ''
|
CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0));\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."));
|
||||||
while '[' in FieldName:
|
else:
|
||||||
NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'
|
NewFieldName = ''
|
||||||
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
while '[' in FieldName:
|
||||||
FieldName = FieldName.split(']', 1)[1]
|
NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'
|
||||||
FieldName = NewFieldName + FieldName
|
ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
|
||||||
while '[' in FieldName:
|
FieldName = FieldName.split(']', 1)[1]
|
||||||
FieldName = FieldName.rsplit('[', 1)[0]
|
FieldName = NewFieldName + FieldName
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1)
|
while '[' in FieldName:
|
||||||
|
FieldName = FieldName.rsplit('[', 1)[0]
|
||||||
|
CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1)
|
||||||
|
if skuname == SkuName:
|
||||||
|
break
|
||||||
|
|
||||||
#
|
#
|
||||||
# Allocate and zero buffer for the PCD
|
# Allocate and zero buffer for the PCD
|
||||||
|
@ -1336,43 +1343,46 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
#
|
#
|
||||||
# Assign field values in PCD
|
# Assign field values in PCD
|
||||||
#
|
#
|
||||||
for FieldList in [Pcd.DefaultValues, Pcd.DefaultFromDSC,OverrideValues.get(DefaultStoreName)]:
|
for skuname in self.SkuIdMgr.SkuOverrideOrder():
|
||||||
if not FieldList:
|
inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
|
||||||
continue
|
for FieldList in [Pcd.DefaultValues, Pcd.DefaultFromDSC,inherit_OverrideValues.get(DefaultStoreName)]:
|
||||||
if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
|
if not FieldList:
|
||||||
IsArray = self.IsFieldValueAnArray(FieldList)
|
continue
|
||||||
Value, ValueSize = ParseFieldValue (FieldList)
|
if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
|
||||||
if isinstance(Value, str):
|
IsArray = self.IsFieldValueAnArray(FieldList)
|
||||||
CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC)
|
Value, ValueSize = ParseFieldValue (FieldList)
|
||||||
elif IsArray:
|
if isinstance(Value, str):
|
||||||
|
CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC)
|
||||||
|
elif IsArray:
|
||||||
#
|
#
|
||||||
# Use memcpy() to copy value into field
|
# Use memcpy() to copy value into field
|
||||||
#
|
#
|
||||||
CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC)
|
CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC)
|
||||||
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
|
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for FieldName in FieldList:
|
for FieldName in FieldList:
|
||||||
IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
|
IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
|
||||||
try:
|
try:
|
||||||
Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
|
Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
|
||||||
except Exception:
|
except Exception:
|
||||||
print FieldList[FieldName][0]
|
print FieldList[FieldName][0]
|
||||||
if isinstance(Value, str):
|
if isinstance(Value, str):
|
||||||
CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
elif IsArray:
|
elif IsArray:
|
||||||
#
|
#
|
||||||
# Use memcpy() to copy value into field
|
# Use memcpy() to copy value into field
|
||||||
#
|
#
|
||||||
CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)
|
CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)
|
||||||
CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
CApp = CApp + ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
|
CApp = CApp + ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
|
||||||
else:
|
|
||||||
if ValueSize > 4:
|
|
||||||
CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
|
||||||
else:
|
else:
|
||||||
CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
if ValueSize > 4:
|
||||||
|
CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
|
else:
|
||||||
|
CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
||||||
|
if skuname == SkuName:
|
||||||
|
break
|
||||||
#
|
#
|
||||||
# Set new PCD value and size
|
# Set new PCD value and size
|
||||||
#
|
#
|
||||||
|
@ -1410,7 +1420,9 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
if not Pcd.SkuOverrideValues:
|
if not Pcd.SkuOverrideValues:
|
||||||
InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp)
|
InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp)
|
||||||
else:
|
else:
|
||||||
for SkuName in Pcd.SkuOverrideValues:
|
for SkuName in self.SkuIdMgr.SkuOverrideOrder():
|
||||||
|
if SkuName not in Pcd.SkuOverrideValues:
|
||||||
|
continue
|
||||||
for DefaultStoreName in Pcd.DefaultStoreName:
|
for DefaultStoreName in Pcd.DefaultStoreName:
|
||||||
Pcd = StructuredPcds[PcdName]
|
Pcd = StructuredPcds[PcdName]
|
||||||
InitByteValue, CApp = self.GenerateInitializeFunc(SkuName, DefaultStoreName, Pcd, InitByteValue, CApp)
|
InitByteValue, CApp = self.GenerateInitializeFunc(SkuName, DefaultStoreName, Pcd, InitByteValue, CApp)
|
||||||
|
@ -1424,7 +1436,9 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
if not Pcd.SkuOverrideValues:
|
if not Pcd.SkuOverrideValues:
|
||||||
CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
|
CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
|
||||||
else:
|
else:
|
||||||
for SkuName in Pcd.SkuOverrideValues:
|
for SkuName in self.SkuIdMgr.SkuOverrideOrder():
|
||||||
|
if SkuName not in Pcd.SkuOverrideValues:
|
||||||
|
continue
|
||||||
for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]:
|
for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]:
|
||||||
CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
|
CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
|
||||||
CApp = CApp + '}\n'
|
CApp = CApp + '}\n'
|
||||||
|
|
Loading…
Reference in New Issue