mirror of https://github.com/acidanthera/audk.git
BaseTools: Fixed the pcd value override issue.
1. the issue in the overriding value from command line. 2. dec fully value < dec field assign value < dsc fully value < dsc field assign value Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
a68749f39a
commit
06140766c1
|
@ -1551,26 +1551,25 @@ class TopLevelMakefile(BuildFile):
|
|||
if GlobalData.gIgnoreSource:
|
||||
ExtraOption += " --ignore-sources"
|
||||
|
||||
if GlobalData.BuildOptionPcd:
|
||||
for index, option in enumerate(GlobalData.gCommand):
|
||||
if "--pcd" == option and GlobalData.gCommand[index+1]:
|
||||
pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
|
||||
for Item in GlobalData.BuildOptionPcd:
|
||||
if '.'.join(Item[0:2]) == pcdName:
|
||||
pcdValue = Item[2]
|
||||
if pcdValue.startswith('L') or pcdValue.startswith('"'):
|
||||
pcdValue, Size = ParseFieldValue(pcdValue)
|
||||
NewVal = '{'
|
||||
for S in range(Size):
|
||||
NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff)
|
||||
NewVal += ','
|
||||
pcdValue = NewVal[:-1] + '}'
|
||||
break
|
||||
if pcdValue.startswith('{'):
|
||||
pcdValue = 'H' + '"' + pcdValue + '"'
|
||||
ExtraOption += " --pcd " + pcdName + '=' + pcdValue
|
||||
else:
|
||||
ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
|
||||
for index, option in enumerate(GlobalData.gCommand):
|
||||
if "--pcd" == option and GlobalData.gCommand[index+1]:
|
||||
pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
|
||||
for Item in GlobalData.BuildOptionPcd:
|
||||
if '.'.join(Item[0:2]) == pcdName:
|
||||
pcdValue = Item[2]
|
||||
if pcdValue.startswith('L') or pcdValue.startswith('"'):
|
||||
pcdValue, Size = ParseFieldValue(pcdValue)
|
||||
NewVal = '{'
|
||||
for S in range(Size):
|
||||
NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff)
|
||||
NewVal += ','
|
||||
pcdValue = NewVal[:-1] + '}'
|
||||
break
|
||||
if pcdValue.startswith('{'):
|
||||
pcdValue = 'H' + '"' + pcdValue + '"'
|
||||
ExtraOption += " --pcd " + pcdName + '=' + pcdValue
|
||||
else:
|
||||
ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
|
||||
|
||||
MakefileName = self._FILE_NAME_[self._FileType]
|
||||
SubBuildCommandList = []
|
||||
|
|
|
@ -126,6 +126,7 @@ class StructurePcd(PcdClassObject):
|
|||
self.StructName = None
|
||||
self.PcdDefineLineNo = 0
|
||||
self.PkgPath = ""
|
||||
self.DefaultValueFromDec = ""
|
||||
def __repr__(self):
|
||||
return self.TypeName
|
||||
|
||||
|
@ -135,6 +136,8 @@ class StructurePcd(PcdClassObject):
|
|||
self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo]
|
||||
return self.DefaultValues[FieldName]
|
||||
|
||||
def SetDecDefaultValue(self,DefaultValue):
|
||||
self.DefaultValueFromDec = DefaultValue
|
||||
def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):
|
||||
if SkuName not in self.SkuOverrideValues:
|
||||
self.SkuOverrideValues[SkuName] = collections.OrderedDict({})
|
||||
|
@ -175,6 +178,7 @@ class StructurePcd(PcdClassObject):
|
|||
self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
|
||||
self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
|
||||
self.DefaultFromDSC=None
|
||||
self.DefaultValueFromDec = PcdObject.DefaultValueFromDec if PcdObject.DefaultValueFromDec else self.DefaultValueFromDec
|
||||
self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues
|
||||
self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName
|
||||
self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName
|
||||
|
|
|
@ -385,6 +385,7 @@ class DecBuildData(PackageBuildClassObject):
|
|||
struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")
|
||||
struct_pcd.PcdDefineLineNo = LineNo
|
||||
struct_pcd.PkgPath = self.MetaFile.File
|
||||
struct_pcd.SetDecDefaultValue(item.DefaultValue)
|
||||
else:
|
||||
struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
|
||||
|
||||
|
|
|
@ -895,12 +895,11 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
if pcd[2] == "":
|
||||
pcdset.append((pcd[0],pcd[1],pcd[3]))
|
||||
else:
|
||||
pcdobj = self._Pcds.get((pcd[1],pcd[0]))
|
||||
if pcdobj:
|
||||
pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue))
|
||||
else:
|
||||
if (pcd[1],pcd[0]) not in self._Pcds:
|
||||
pcdvalue = pcd[3] if len(pcd) == 4 else pcd[2]
|
||||
pcdset.append((pcd[0],pcd[1],pcdvalue))
|
||||
#else:
|
||||
# remove the settings from command line since it has been handled.
|
||||
GlobalData.BuildOptionPcd = pcdset
|
||||
def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):
|
||||
PredictedFieldType = "VOID*"
|
||||
|
@ -1677,6 +1676,23 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
# Assign field values in PCD
|
||||
#
|
||||
CApp = CApp + "// Default value in Dec \n"
|
||||
DefaultValueFromDec = Pcd.DefaultValueFromDec
|
||||
IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec)
|
||||
if IsArray:
|
||||
try:
|
||||
DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True)
|
||||
except BadExpression:
|
||||
EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" %
|
||||
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))
|
||||
Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
|
||||
if isinstance(Value, str):
|
||||
CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
|
||||
elif IsArray:
|
||||
#
|
||||
# Use memcpy() to copy value into field
|
||||
#
|
||||
CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)
|
||||
CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)
|
||||
for FieldList in [Pcd.DefaultValues]:
|
||||
if not FieldList:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue