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
|
@ -2146,11 +2146,20 @@ class SkuClass():
|
||||||
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']
|
||||||
|
@ -2190,13 +2199,47 @@ class SkuClass():
|
||||||
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:
|
||||||
|
if len(self.SkuIdSet) == 1:
|
||||||
return self.SkuIdSet[0]
|
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,6 +925,7 @@ 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:
|
||||||
|
if ' ' + Option not in self._BuildOptions[CurKey]:
|
||||||
self._BuildOptions[CurKey] += ' ' + Option
|
self._BuildOptions[CurKey] += ' ' + Option
|
||||||
return self._BuildOptions
|
return self._BuildOptions
|
||||||
|
|
||||||
|
@ -934,13 +937,15 @@ 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:
|
||||||
|
if ' ' + Option not in options[Key]:
|
||||||
options[Key] += ' ' + Option
|
options[Key] += ' ' + Option
|
||||||
return self._ModuleTypeOptions[Edk, ModuleType]
|
return self._ModuleTypeOptions[Edk, ModuleType]
|
||||||
|
|
||||||
|
@ -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,7 +1302,9 @@ 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():
|
||||||
|
inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
|
||||||
|
for FieldList in [Pcd.DefaultValues, inherit_OverrideValues.get(DefaultStoreName)]:
|
||||||
if not FieldList:
|
if not FieldList:
|
||||||
continue
|
continue
|
||||||
for FieldName in FieldList:
|
for FieldName in FieldList:
|
||||||
|
@ -1307,7 +1312,7 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
|
IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
|
||||||
if IsArray:
|
if IsArray:
|
||||||
Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0])
|
Value, ValueSize = ParseFieldValue (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("."));
|
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("."));
|
||||||
else:
|
else:
|
||||||
NewFieldName = ''
|
NewFieldName = ''
|
||||||
while '[' in FieldName:
|
while '[' in FieldName:
|
||||||
|
@ -1318,6 +1323,8 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
while '[' in FieldName:
|
while '[' in FieldName:
|
||||||
FieldName = FieldName.rsplit('[', 1)[0]
|
FieldName = FieldName.rsplit('[', 1)[0]
|
||||||
CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1)
|
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,7 +1343,9 @@ 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():
|
||||||
|
inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
|
||||||
|
for FieldList in [Pcd.DefaultValues, Pcd.DefaultFromDSC,inherit_OverrideValues.get(DefaultStoreName)]:
|
||||||
if not FieldList:
|
if not FieldList:
|
||||||
continue
|
continue
|
||||||
if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
|
if Pcd.DefaultFromDSC and FieldList == Pcd.DefaultFromDSC:
|
||||||
|
@ -1372,7 +1381,8 @@ class DscBuildData(PlatformBuildClassObject):
|
||||||
CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
|
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])
|
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