mirror of https://github.com/acidanthera/audk.git
BaseTools: Fixed Pcd from command line issue.
Save the pcd command line value in Pcd object 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
6d2d2e6e5b
commit
0f228f19fb
|
@ -916,11 +916,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
|
||||
FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName
|
||||
|
||||
if GlobalData.BuildOptionPcd:
|
||||
for PcdItem in GlobalData.BuildOptionPcd:
|
||||
if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
|
||||
Pcd.DefaultValue = PcdItem[2]
|
||||
break
|
||||
if Pcd.PcdValueFromComm:
|
||||
Pcd.DefaultValue = Pcd.PcdValueFromComm
|
||||
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
TokenNumber = int(Pcd.TokenValue, 0)
|
||||
|
@ -1215,12 +1212,8 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
|||
PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE'
|
||||
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
|
||||
|
||||
if GlobalData.BuildOptionPcd:
|
||||
for PcdItem in GlobalData.BuildOptionPcd:
|
||||
if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
|
||||
Pcd.DefaultValue = PcdItem[2]
|
||||
break
|
||||
|
||||
if Pcd.PcdValueFromComm:
|
||||
Pcd.DefaultValue = Pcd.PcdValueFromComm
|
||||
#
|
||||
# Write PCDs
|
||||
#
|
||||
|
|
|
@ -1551,25 +1551,15 @@ class TopLevelMakefile(BuildFile):
|
|||
if GlobalData.gIgnoreSource:
|
||||
ExtraOption += " --ignore-sources"
|
||||
|
||||
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 pcd in GlobalData.BuildOptionPcd:
|
||||
if pcd[2]:
|
||||
pcdname = '.'.join(pcd[0:3])
|
||||
else:
|
||||
pcdname = '.'.join(pcd[0:2])
|
||||
if pcd[3].startswith('{'):
|
||||
ExtraOption += " --pcd " + pcdname + '=' + 'H' + '"' + pcd[3] + '"'
|
||||
else:
|
||||
ExtraOption += " --pcd " + pcdname + '=' + pcd[3]
|
||||
|
||||
MakefileName = self._FILE_NAME_[self._FileType]
|
||||
SubBuildCommandList = []
|
||||
|
|
|
@ -68,6 +68,7 @@ class PcdClassObject(object):
|
|||
self.DscRawValue = None
|
||||
if IsDsc:
|
||||
self.DscDefaultValue = Value
|
||||
self.PcdValueFromComm = ""
|
||||
|
||||
## Convert the class to a string
|
||||
#
|
||||
|
@ -129,7 +130,6 @@ class StructurePcd(PcdClassObject):
|
|||
self.PkgPath = ""
|
||||
self.DefaultValueFromDec = ""
|
||||
self.ValueChain = dict()
|
||||
self.PcdValueFromComm = ""
|
||||
self.PcdFieldValueFromComm = collections.OrderedDict({})
|
||||
def __repr__(self):
|
||||
return self.TypeName
|
||||
|
@ -177,6 +177,7 @@ class StructurePcd(PcdClassObject):
|
|||
self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
|
||||
self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
|
||||
self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue
|
||||
self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
|
||||
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
|
||||
|
@ -190,7 +191,6 @@ class StructurePcd(PcdClassObject):
|
|||
self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo
|
||||
self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath
|
||||
self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain
|
||||
self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
|
||||
self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm
|
||||
|
||||
## LibraryClassObject
|
||||
|
|
|
@ -893,18 +893,18 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
return Pcds
|
||||
|
||||
def RecoverCommandLinePcd(self):
|
||||
pcdset = []
|
||||
if GlobalData.BuildOptionPcd:
|
||||
for pcd in GlobalData.BuildOptionPcd:
|
||||
if pcd[2] == "":
|
||||
pcdset.append((pcd[0],pcd[1],pcd[3]))
|
||||
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 UpdateCommandLineValue(pcd):
|
||||
if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
|
||||
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
|
||||
pcd.PcdValueFromComm = pcd.DefaultValue
|
||||
elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
|
||||
pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue
|
||||
else:
|
||||
pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").DefaultValue
|
||||
for pcd in self._Pcds:
|
||||
if isinstance(self._Pcds[pcd],StructurePcd) and (self._Pcds[pcd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm):
|
||||
UpdateCommandLineValue(self._Pcds[pcd])
|
||||
|
||||
def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):
|
||||
PredictedFieldType = "VOID*"
|
||||
if ValueStr.startswith('L'):
|
||||
|
@ -1242,6 +1242,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd):
|
||||
self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
|
||||
else:
|
||||
Pcd.PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
|
||||
Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
|
||||
for sku in Pcd.SkuInfoList:
|
||||
SkuInfo = Pcd.SkuInfoList[sku]
|
||||
|
@ -1266,9 +1267,8 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
Pcd.MaxDatumSize = str(MaxSize)
|
||||
else:
|
||||
PcdInDec = self.DecPcds.get((Name,Guid))
|
||||
if isinstance(PcdInDec,StructurePcd):
|
||||
PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0]
|
||||
if PcdInDec:
|
||||
PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0]
|
||||
if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
|
||||
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
|
||||
self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec)
|
||||
|
@ -1711,6 +1711,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
except BadExpression:
|
||||
EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" %
|
||||
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))
|
||||
DefaultValueFromDec = StringToArray(DefaultValueFromDec)
|
||||
Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
|
||||
if isinstance(Value, str):
|
||||
CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
|
||||
|
@ -1850,7 +1851,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||
try:
|
||||
FieldList = ValueExpressionEx(FieldList, "VOID*")(True)
|
||||
except BadExpression:
|
||||
EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %
|
||||
EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from Command: %s" %
|
||||
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
|
||||
Value, ValueSize = ParseFieldValue (FieldList)
|
||||
|
||||
|
|
Loading…
Reference in New Issue